#include "EXPR_API.h"#include "EX_Error.h"#include "EXPR_Lock.h"#include <UT/UT_SmallObject.h>#include <UT/UT_String.h>#include <SYS/SYS_Types.h>Go to the source code of this file.
Classes | |
| union | EV_TOKENVALUE |
| union used to hold a token's value More... | |
| struct | EV_SYMBOL |
| class representing a symbol operated upon by expressions More... | |
| struct | EV_TYPEDEF |
| struct | EV_OPERATOR |
| struct describing an operator's characteristics More... | |
| class | EV_FUNCTION |
| struct | EV_ChangeOpReferenceParms |
| class | EV_EXPRESSION |
| struct | EV_SYMTABLE |
| struct | EV_FUNCHELP |
Defines | |
| #define | EV_OPTIMIZE0 0 |
| #define | EV_OPTIMIZE1 1 |
| #define | MAX_RECURSION 20 |
| #define | EV_NHELPARGS 10 |
| #define | EX_USERFLAGMASK (0x03ffffff | EV_EXFUNC_REF) |
| #define | OP_PLUS 1 |
| #define | OP_MINUS 2 |
| #define | OP_TIMES 3 |
| #define | OP_DIVIDE 4 |
| #define | OP_POWER 5 |
| #define | OP_MOD 6 |
| #define | OP_NOT 7 |
| #define | OP_EQ 8 |
| #define | OP_NE 9 |
| #define | OP_LT 10 |
| #define | OP_LE 11 |
| #define | OP_GT 12 |
| #define | OP_GE 13 |
| #define | OP_LOGAND 14 |
| #define | OP_LOGOR 15 |
| #define | OP_COMMA 16 |
| #define | OP_QUESTION 20 |
| #define | OP_COLON 21 |
| #define | OP_AND 22 |
| #define | OP_OR 23 |
| #define | OP_DOT 24 |
| #define | OP_TILDE 25 |
| #define | OP_AT 26 |
| #define | OP_SBRACKET 30 |
| #define | OP_BRACE 31 |
| #define | OP_EQUATE 32 |
| #define | MAX_OPERATOR_TOKEN 32 |
| #define | EV_SYMTRANSIENT 0x04000000 |
| Symbol is result of operation. | |
| #define | EV_SYMCONSTANT 0x08000000 |
| Symbol has a constant value. | |
| #define | EV_FLAGS_SET 0x10000000 |
| User flags have been set. | |
| #define | EV_SYMEXPAND 0x20000000 |
| String should be expanded. | |
| #define | EV_EXFUNC_REF 0x40000000 |
| Refers to an expression function. | |
| #define | EV_FOR_EXFUNC 0x80000000 |
| #define | EV_TYPEFLOAT 0 |
| Float type of symbol. | |
| #define | EV_TYPESTRING 1 |
| String type of symbol. | |
| #define | EV_TYPEUNIXVAR 2 |
| Unix variable type. | |
| #define | EV_TYPEEXPANDVAR 4 |
| Variable of form ${foo$x}. | |
| #define | EV_TYPEVECTOR 5 |
| Vector. | |
| #define | EV_TYPEMATRIX 6 |
| #define | EV_TYPE_LOCAL_VAR 10 |
| A node local variable. | |
| #define | EV_TYPE_UNRESOLVED_VAR 11 |
| An unknown variable. | |
| #define | EV_TYPE_DEFINE 12 |
| A node local variable. | |
| #define | EV_TYPE_GLOBAL_VAR 20 |
| A global variable. | |
| #define | EV_TYPE_CPPSYMBOL 45 |
| A symbol inside a function. | |
| #define | EV_TYPE_UNRESOLVED_CPPSYMBOL 46 |
| #define | EV_START_FN(name) |
| #define | EV_START_FNNA(name) |
| #define | EV_START_FUNC(name) |
| #define | EV_END_FN(answer) result->value.fval = (answer) |
| #define | EV_END_FNS(answer) result->value.sval = (answer) |
Typedefs | |
| typedef char *(* | ev_Expander )(const char *str, int thread) |
| typedef void(* | EXPRopDependencyCallback )(EV_FUNCTION *me, EV_SYMBOL **argv, void *ref_id) |
| typedef void(* | EXPRopChangeRefCallback )(EV_FUNCTION *me, EV_SYMBOL **argv, char *new_args[], const char *new_fullpath, const char *old_fullpath, const char *old_cwd, const char *chan_name, const char *old_chan_name) |
| typedef void(* | EXPRfuncCallback )(EV_FUNCTION *me, EV_SYMBOL *result, EV_SYMBOL **argv, int thread, unsigned &func_flags) |
| typedef struct EV_TYPEDEF | EV_TYPEDEF |
| typedef struct EV_OPERATOR | EV_OPERATOR |
| typedef struct EV_FUNCHELP | EV_FUNCHELP |
| typedef struct EV_SYMTABLE | EV_SYMTABLE |
Enumerations | |
| enum | EV_InlineFuncReturnType { EV_EXPR_RETURN_NONE, EV_EXPR_RETURN_FLOAT, EV_EXPR_RETURN_STRING, EV_EXPR_RETURN_VECTOR, EV_EXPR_RETURN_MATRIX } |
Functions | |
| EXPR_API void | ev_InitFloat (void) |
| EXPR_API void | ev_InitString (void) |
| initialize string operations | |
| EXPR_API void | ev_InitVariable (void) |
| EXPR_API void | ev_InitVector (void) |
| initialize vector operations | |
| EXPR_API void | ev_InitMatrix (void) |
| initialize matrix operations | |
| EXPR_API void | ev_InitUserFunc (void) |
| EXPR_API int | ev_GetNFunctions () |
| EXPR_API EV_FUNCTION * | ev_GetFunction (int i) |
| EXPR_API EV_TYPEDEF * | ev_GetTypeDef (int key) |
| EXPR_API int | ev_FindFunction (const char *name) |
| EXPR_API void | ev_SetFunctionDependencyCallbacks (const char *func, EXPRopDependencyCallback depend_cb, EXPRopChangeRefCallback changeref_cb) |
| EXPR_API EV_EXPRESSION * | ev_AllocExpr (EV_InlineFuncReturnType rettype) |
| EXPR_API int | ev_ChangeExpr (EV_EXPRESSION *expr, const char *source) |
| EXPR_API void | ev_UnresolveVars (EV_EXPRESSION *expr, int thread) |
| EXPR_API fpreal | ev_EvaluateFloat (EV_EXPRESSION *expr, int thread) |
| EXPR_API void | ev_EvaluateString (UT_String &result, EV_EXPRESSION *expr, int thread) |
| EXPR_API int | ev_EvaluateVector (EV_EXPRESSION *expr, ev_Vector &result, int thread) |
| EXPR_API int | ev_EvaluateMatrix (EV_EXPRESSION *expr, ev_Matrix &result, int thread) |
| EXPR_API void | ev_FreeExpr (EV_EXPRESSION *expr) |
| EXPR_API void | ev_UpdateOpDependency (EV_EXPRESSION *expr, void *ref_id, int thread) |
| EXPR_API int | ev_ChangeOpReference (EV_EXPRESSION *expr, const char *new_fullpath, const char *old_fullpath, const char *old_cwd, const char *chan_name, const char *old_chan_name, int thread) |
| EXPR_API EV_SYMBOL * | ev_Evaluate (EV_EXPRESSION *expr, EV_InlineFuncReturnType func_ret_type, int thread) |
| EXPR_API void | ev_SetExpander (ev_Expander expander) |
| EXPR_API EXPR_GlobalStaticLock & | ev_GlobalEvalLock () |
| template<typename LOCK_SCOPE , typename LOCK > | |
| bool | EXPRsafeEvalLock (LOCK_SCOPE &lock_scope, LOCK &lock) |
| EXPR_API void | ev_AddType (EV_TYPEDEF *type) |
| EXPR_API void | ev_AddVariableType (EV_TYPEDEF *type, int atEnd) |
| EXPR_API void | ev_DeleteVariableType (EV_TYPEDEF *type) |
| EXPR_API void | ev_AddOperator (EV_OPERATOR *op, int level) |
| EXPR_API void | ev_AddFunction (EV_FUNCTION *func) |
| EXPR_API void | ev_DeleteFunction (EV_FUNCTION *func) |
| EXPR_API void | ev_SetOptimization (int level) |
| EXPR_API void | ev_SetFunctionInstanceAllocator (const char *function, void *(*alloc)(), void(*free)(void *)) |
| Functions for supplying state data for custom expressions. | |
| EXPR_API void * | ev_GetFunctionData (int thread) |
| EXPR_API bool | ev_SaveCompiledCode (EV_EXPRESSION *expr, ostream &os, int thread) |
| EXPR_API bool | ev_LoadCompiledCode (EV_EXPRESSION *expr, UT_IStream &is, int thread) |
| EXPR_API EV_SYMBOL * | ev_AllocSymbol (int type, int thread) |
| EXPR_API void | ev_FreeSymbol (EV_SYMBOL *symbol, int thread) |
| EXPR_API void | ev_setSafeMode (bool safe_mode) |
| EXPR_API bool | ev_isInSafeMode () |
| EXPR_API bool | ev_isKeyword (const char *string) |
| #define EV_END_FN | ( | answer | ) | result->value.fval = (answer) |
| #define EV_END_FNS | ( | answer | ) | result->value.sval = (answer) |
| #define EV_EXFUNC_REF 0x40000000 |
| #define EV_FOR_EXFUNC 0x80000000 |
| #define EV_START_FN | ( | name | ) |
Value:
static void name(EV_FUNCTION *, EV_SYMBOL *result,\ EV_SYMBOL **argv, int thread, unsigned &func_flags)
| #define EV_START_FNNA | ( | name | ) |
Value:
static void name(EV_FUNCTION *, EV_SYMBOL *result, \ EV_SYMBOL **, int thread, unsigned &func_flags)
| #define EV_START_FUNC | ( | name | ) |
| #define EV_SYMCONSTANT 0x08000000 |
| #define EV_SYMTRANSIENT 0x04000000 |
Symbol is result of operation.
These flags are common to symbols, operators and functions
NOTE: The high 8 bits of the flag are reserved for internal use User flags should start at not go higher than 0x800000
Note: when changing this definition, update EX_USERFLAGMASK
| #define EV_TYPE_DEFINE 12 |
| #define EV_TYPE_LOCAL_VAR 10 |
| #define EV_TYPE_UNRESOLVED_CPPSYMBOL 46 |
| #define EV_TYPEFLOAT 0 |
Float type of symbol.
Implicit types known by expression language
DON'T CHANGE THESE VALUES - They are saved as ints for compiled expressions.
| #define MAX_OPERATOR_TOKEN 32 |
| #define OP_AND 22 |
| #define OP_AT 26 |
| #define OP_BRACE 31 |
| #define OP_COLON 21 |
| #define OP_COMMA 16 |
| #define OP_DIVIDE 4 |
| #define OP_DOT 24 |
| #define OP_EQ 8 |
| #define OP_EQUATE 32 |
| #define OP_GE 13 |
| #define OP_GT 12 |
| #define OP_LE 11 |
| #define OP_LOGAND 14 |
| #define OP_LOGOR 15 |
| #define OP_LT 10 |
| #define OP_MINUS 2 |
| #define OP_MOD 6 |
| #define OP_NE 9 |
| #define OP_NOT 7 |
| #define OP_OR 23 |
| #define OP_PLUS 1 |
| #define OP_POWER 5 |
| #define OP_QUESTION 20 |
| #define OP_SBRACKET 30 |
| #define OP_TILDE 25 |
| #define OP_TIMES 3 |
| typedef char*(* ev_Expander)(const char *str, int thread) |
| typedef struct EV_FUNCHELP EV_FUNCHELP |
| typedef struct EV_OPERATOR EV_OPERATOR |
| typedef struct EV_SYMTABLE EV_SYMTABLE |
| typedef struct EV_TYPEDEF EV_TYPEDEF |
| typedef void(* EXPRfuncCallback)(EV_FUNCTION *me, EV_SYMBOL *result, EV_SYMBOL **argv, int thread, unsigned &func_flags) |
| typedef void(* EXPRopChangeRefCallback)(EV_FUNCTION *me, EV_SYMBOL **argv, char *new_args[], const char *new_fullpath, const char *old_fullpath, const char *old_cwd, const char *chan_name, const char *old_chan_name) |
| typedef void(* EXPRopDependencyCallback)(EV_FUNCTION *me, EV_SYMBOL **argv, void *ref_id) |
This is an enumeration of the type of return values that an inline function may be expected to return. Setting this value to EV_EXPR_RETURN_NONE will disallow an expression from supporting inline functions.
| EXPR_API void ev_AddFunction | ( | EV_FUNCTION * | func | ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API void ev_AddOperator | ( | EV_OPERATOR * | op, | |
| int | level | |||
| ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API void ev_AddType | ( | EV_TYPEDEF * | type | ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API void ev_AddVariableType | ( | EV_TYPEDEF * | type, | |
| int | atEnd | |||
| ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API EV_EXPRESSION* ev_AllocExpr | ( | EV_InlineFuncReturnType | rettype | ) |
| EXPR_API EV_SYMBOL* ev_AllocSymbol | ( | int | type, | |
| int | thread | |||
| ) |
Functions used internally by type declarations
| EXPR_API int ev_ChangeExpr | ( | EV_EXPRESSION * | expr, | |
| const char * | source | |||
| ) |
| EXPR_API int ev_ChangeOpReference | ( | EV_EXPRESSION * | expr, | |
| const char * | new_fullpath, | |||
| const char * | old_fullpath, | |||
| const char * | old_cwd, | |||
| const char * | chan_name, | |||
| const char * | old_chan_name, | |||
| int | thread | |||
| ) |
| EXPR_API void ev_DeleteFunction | ( | EV_FUNCTION * | func | ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API void ev_DeleteVariableType | ( | EV_TYPEDEF * | type | ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API EV_SYMBOL* ev_Evaluate | ( | EV_EXPRESSION * | expr, | |
| EV_InlineFuncReturnType | func_ret_type, | |||
| int | thread | |||
| ) |
| EXPR_API fpreal ev_EvaluateFloat | ( | EV_EXPRESSION * | expr, | |
| int | thread | |||
| ) |
| EXPR_API int ev_EvaluateMatrix | ( | EV_EXPRESSION * | expr, | |
| ev_Matrix & | result, | |||
| int | thread | |||
| ) |
| EXPR_API void ev_EvaluateString | ( | UT_String & | result, | |
| EV_EXPRESSION * | expr, | |||
| int | thread | |||
| ) |
| EXPR_API int ev_EvaluateVector | ( | EV_EXPRESSION * | expr, | |
| ev_Vector & | result, | |||
| int | thread | |||
| ) |
| EXPR_API int ev_FindFunction | ( | const char * | name | ) |
| EXPR_API void ev_FreeExpr | ( | EV_EXPRESSION * | expr | ) |
| EXPR_API void ev_FreeSymbol | ( | EV_SYMBOL * | symbol, | |
| int | thread | |||
| ) |
Functions used internally by type declarations
| EXPR_API EV_FUNCTION* ev_GetFunction | ( | int | i | ) |
| EXPR_API void* ev_GetFunctionData | ( | int | thread | ) |
From within an expression function, use this to retrieve the data created by the alloc function specified in ev_SetFunctionInstanceAllocator().
| thread | Thread id supplied to the expression function callback |
| EXPR_API int ev_GetNFunctions | ( | ) |
| EXPR_API EV_TYPEDEF* ev_GetTypeDef | ( | int | key | ) |
| EXPR_API EXPR_GlobalStaticLock& ev_GlobalEvalLock | ( | ) |
The global evaluation lock is a global mutex for protecting any non-threadsafe evaluation (both expressions and node) code. This is necessary to guard against code that might access global objects.
| EXPR_API void ev_InitFloat | ( | void | ) |
initialize floating point operations Float initialization will automatically initialize vector/matrix
| EXPR_API void ev_InitMatrix | ( | void | ) |
initialize matrix operations
| EXPR_API void ev_InitString | ( | void | ) |
initialize string operations
| EXPR_API void ev_InitUserFunc | ( | void | ) |
| EXPR_API void ev_InitVariable | ( | void | ) |
| EXPR_API void ev_InitVector | ( | void | ) |
initialize vector operations
| EXPR_API bool ev_isInSafeMode | ( | ) |
These functions put the expression evaluator into/out of "safe" mode. In safe mode, certain functions will not be executed.
| EXPR_API bool ev_isKeyword | ( | const char * | string | ) |
These functions put the expression evaluator into/out of "safe" mode. In safe mode, certain functions will not be executed.
| EXPR_API bool ev_LoadCompiledCode | ( | EV_EXPRESSION * | expr, | |
| UT_IStream & | is, | |||
| int | thread | |||
| ) |
These functions save and load compiled expressions.
| EXPR_API bool ev_SaveCompiledCode | ( | EV_EXPRESSION * | expr, | |
| ostream & | os, | |||
| int | thread | |||
| ) |
These functions save and load compiled expressions.
| EXPR_API void ev_SetExpander | ( | ev_Expander | expander | ) |
| EXPR_API void ev_SetFunctionDependencyCallbacks | ( | const char * | func, | |
| EXPRopDependencyCallback | depend_cb, | |||
| EXPRopChangeRefCallback | changeref_cb | |||
| ) |
| EXPR_API void ev_SetFunctionInstanceAllocator | ( | const char * | function, | |
| void *(*)() | alloc, | |||
| void(*)(void *) | free | |||
| ) |
Functions for supplying state data for custom expressions.
This function specifies the constructor/destructor functions for the state data.
| function | Name of the custom expression function | |
| alloc | This allocates and initializes the state data | |
| free | This deallocates the state data |
| EXPR_API void ev_SetOptimization | ( | int | level | ) |
Functions for expansion of library Add operators, type definitions and functions.
| EXPR_API void ev_setSafeMode | ( | bool | safe_mode | ) |
These functions put the expression evaluator into/out of "safe" mode. In safe mode, certain functions will not be executed.
| EXPR_API void ev_UnresolveVars | ( | EV_EXPRESSION * | expr, | |
| int | thread | |||
| ) |
| EXPR_API void ev_UpdateOpDependency | ( | EV_EXPRESSION * | expr, | |
| void * | ref_id, | |||
| int | thread | |||
| ) |
| bool EXPRsafeEvalLock | ( | LOCK_SCOPE & | lock_scope, | |
| LOCK & | lock | |||
| ) | [inline] |
If you have a local lock section that also tries to obtain the global eval lock, then deadlock's might occur. Therefore for all such locks, you should use this template function to detect such situations. If it returns false, then a potential deadlock was found.
1.5.9