MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetExpression

Method SetExpression

trinity/Curves/Tr2CurveVector3Expression.cpp:141–173  ·  view source on GitHub ↗

--------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

139
140// --------------------------------------------------------------------------------
141void Tr2CurveVector3Expression::SetExpression( size_t index, const std::string& expression )
142{
143 if( expression.empty() )
144 {
145 m_expressions[index] = expression;
146 return;
147 }
148
149 CcpParser::Variable s_variables[] = {
150 { "time", 0, offsetof( Arguments, m_time ) },
151 { "input1", 0, offsetof( Arguments, m_input1 ) },
152 { "input2", 0, offsetof( Arguments, m_input2 ) },
153 { "input3", 0, offsetof( Arguments, m_input3 ) },
154 { "input4", 0, offsetof( Arguments, m_input4 ) },
155 };
156
157 CcpParser::FunctionView functionView[] = { s_functions };
158 CcpParser::ConstantView constantView[] = { s_constants };
159 CcpParser::VariableView variableView[] = { s_variables };
160
161 CcpParser::Externals externals;
162 externals.functions = functionView;
163 externals.variables = variableView;
164 externals.constants = constantView;
165 auto result = CcpParser::Parse( expression.c_str(), externals, m_programs[index] );
166 if( !result )
167 {
168 CCP_LOGERR( "Tr2CurveVector3Expression::SetExpression invalid expression \"%s\": %s", expression.c_str(), ToString( result, expression.c_str() ).c_str() );
169 return;
170 }
171 m_tempArena.reset( new uint8_t[std::max( m_programs[0].GetTempArenaSize(), std::max( m_programs[1].GetTempArenaSize(), m_programs[2].GetTempArenaSize() ) )] );
172 m_expressions[index] = expression;
173}
174
175// --------------------------------------------------------------------------------
176std::string Tr2CurveVector3Expression::GetExpressionX() const

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.85
emptyMethod · 0.80
resetMethod · 0.80
ToStringFunction · 0.50

Tested by

no test coverage detected