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

Method SetExpression

trinity/Curves/Tr2CurveScalarExpression.cpp:169–201  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

167
168// --------------------------------------------------------------------------------
169void Tr2CurveScalarExpression::SetExpression( const std::string& expression )
170{
171 if( expression.empty() )
172 {
173 m_expression = expression;
174 return;
175 }
176
177 CcpParser::Variable s_variables[] = {
178 { "time", 0, offsetof( Arguments, m_time ) },
179 { "input1", 0, offsetof( Arguments, m_input1 ) },
180 { "input2", 0, offsetof( Arguments, m_input2 ) },
181 { "input3", 0, offsetof( Arguments, m_input3 ) },
182 { "input4", 0, offsetof( Arguments, m_input4 ) },
183 };
184
185 CcpParser::FunctionView functionView[] = { s_functions };
186 CcpParser::ConstantView constantView[] = { s_constants };
187 CcpParser::VariableView variableView[] = { s_variables };
188
189 CcpParser::Externals externals;
190 externals.functions = functionView;
191 externals.variables = variableView;
192 externals.constants = constantView;
193 auto result = CcpParser::Parse( expression.c_str(), externals, m_program );
194 if( !result )
195 {
196 CCP_LOGERR( "Tr2CurveScalarExpression::SetExpression invalid expression \"%s\": %s", expression.c_str(), ToString( result, expression.c_str() ).c_str() );
197 return;
198 }
199 m_tempArena.reset( new uint8_t[m_program.GetTempArenaSize()] );
200 m_expression = expression;
201}
202
203// --------------------------------------------------------------------------------
204float Tr2CurveScalarExpression::GetInputValue( int index ) 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