| 376 | } |
| 377 | |
| 378 | BlueStdResult Tr2CurveVector3Expression::EvaluateExpression( const char* expression, float& value ) const |
| 379 | { |
| 380 | CcpParser::Variable s_variables[] = { |
| 381 | { "time", 0, offsetof( Arguments, m_time ) }, |
| 382 | { "input1", 0, offsetof( Arguments, m_input1 ) }, |
| 383 | { "input2", 0, offsetof( Arguments, m_input2 ) }, |
| 384 | { "input3", 0, offsetof( Arguments, m_input3 ) }, |
| 385 | { "input4", 0, offsetof( Arguments, m_input4 ) }, |
| 386 | }; |
| 387 | |
| 388 | CcpParser::FunctionView functionView[] = { s_functions }; |
| 389 | CcpParser::ConstantView constantView[] = { s_constants }; |
| 390 | CcpParser::VariableView variableView[] = { s_variables }; |
| 391 | |
| 392 | CcpParser::Externals externals; |
| 393 | externals.functions = functionView; |
| 394 | externals.variables = variableView; |
| 395 | externals.constants = constantView; |
| 396 | CcpParser::Program program; |
| 397 | auto result = CcpParser::Parse( expression, externals, program ); |
| 398 | if( !result ) |
| 399 | { |
| 400 | return BlueStdResult( BLUE_STD_RESULT_VALUE_ERROR, ToString( result, expression ).c_str() ); |
| 401 | } |
| 402 | std::unique_ptr<uint8_t[]> tempArena( new uint8_t[program.GetTempArenaSize()] ); |
| 403 | auto self = this; |
| 404 | void* buffers[] = { (void*)&m_arguments, (void*)&self }; |
| 405 | value = program.Eval( buffers, tempArena.get() ); |
| 406 | return BlueStdResult(); |
| 407 | } |