HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EXPR.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: EXPR.h (C)
7  *
8  * COMMENTS: Include file for expression library.
9  *
10  */
11 
12 #ifndef __LIBEXPR_H__
13 #define __LIBEXPR_H__
14 
15 #include "EXPR_API.h"
16 #include "EX_Error.h"
17 #include "EXPR_Lock.h"
18 #include <UT/UT_SmallObject.h>
19 #include <UT/UT_String.h>
20 #include <SYS/SYS_Types.h>
21 #include <SYS/SYS_MemoryOrder.h>
22 #include <iosfwd>
23 
24 class ev_Vector;
25 class ev_Matrix;
26 class EX_ExprFunc;
27 class UT_IStream;
28 class UT_WorkBuffer;
29 
30 #define EV_OPTIMIZE0 0 /* No optimization */
31 #define EV_OPTIMIZE1 1 /* Constant folding */
32 
33 #define MAX_RECURSION 20 /* Maximum depth of recursion */
34 
35 #define EV_NHELPARGS 10 /* Maximum # of args in help */
36 
37 typedef char *(*ev_Expander)(const char *str, int thread);
38 
39 /// Valid operator tokens - used by the operator typedef below
40 /// DON'T CHANGE THESE VALUES - They are saved as ints for compiled expressions.
41 /// @{
42 #define OP_PLUS 1 /* + */
43 #define OP_MINUS 2 /* - */
44 #define OP_TIMES 3 /* * */
45 #define OP_DIVIDE 4 /* / */
46 #define OP_POWER 5 /* ^ */
47 #define OP_MOD 6 /* % */
48 #define OP_NOT 7 /* ! */
49 #define OP_EQ 8 /* == */
50 #define OP_NE 9 /* != */
51 #define OP_LT 10 /* < */
52 #define OP_LE 11 /* <= */
53 #define OP_GT 12 /* > */
54 #define OP_GE 13 /* >= */
55 #define OP_LOGAND 14 /* && (logical and) */
56 #define OP_LOGOR 15 /* || (logical or) */
57 #define OP_COMMA 16 /* , almost a NOP */
58 #define OP_QUESTION 20 /* ? */
59 #define OP_COLON 21 /* : */
60 #define OP_AND 22 /* & */
61 #define OP_OR 23 /* | */
62 #define OP_DOT 24 /* . */
63 #define OP_TILDE 25 /* ~ */
64 #define OP_AT 26 /* @ */
65 #define OP_SBRACKET 30 /* [ end square bracket implied */
66 #define OP_BRACE 31 /* { end brace implied */
67 #define OP_EQUATE 32 /* = */
68 #define MAX_OPERATOR_TOKEN 32
69 /// @}
70 
71 /// These flags are common to symbols, operators and functions
72 ///
73 /// NOTE: The high 8 bits of the flag are reserved for internal use
74 /// User flags should start at not go higher than 0x800000
75 ///
76 /// Note: when changing this definition, update EX_USERFLAGMASK
77 /// @{
78 #define EV_SYMTRANSIENT 0x04000000 ///< Symbol is result of operation
79 #define EV_SYMCONSTANT 0x08000000 ///< Symbol has a constant value
80 #define EV_FLAGS_SET 0x10000000 ///< User flags have been set
81 #define EV_SYMEXPAND 0x20000000 ///< String should be expanded
82 #define EV_EXFUNC_REF 0x40000000 ///< Refers to an expression function
83 #define EV_FOR_EXFUNC 0x80000000 ///< Symbol is to be used by expr func
84 /// @}
85 
86 #define EX_USERFLAGMASK (0x03ffffff | EV_EXFUNC_REF)
87 
88 
89 /// Implicit types known by expression language
90 /// - The type identifiers must be positive unique integers
91 /// - Eventhough Variables are handled as a special case, the
92 /// type identifier for each variable type must be unique
93 /// - It is suggested that applications start their typedefs identifiers
94 /// 10 or greater. The identifiers do not have to be sequential.
95 ///
96 /// DON'T CHANGE THESE VALUES - They are saved as ints for compiled expressions.
97 /// @{
98 #define EV_TYPEFLOAT 0 ///< Float type of symbol
99 #define EV_TYPESTRING 1 ///< String type of symbol
100 #define EV_TYPEUNIXVAR 2 ///< Unix variable type
101 #define EV_TYPEEXPANDVAR 4 ///< Variable of form ${foo$x}
102 #define EV_TYPEVECTOR 5 ///< Vector
103 #define EV_TYPEMATRIX 6 ///< Matrix
104 /// @}
105 
106 /// These types are used in Houdini outside of EXPR.
107 /// DON'T CHANGE THESE VALUES - They are saved as ints for compiled expressions.
108 /// @{
109 #define EV_TYPE_LOCAL_VAR 10 ///< A node local variable
110 #define EV_TYPE_UNRESOLVED_VAR 11 ///< An unknown variable
111 #define EV_TYPE_DEFINE 12
112 #define EV_TYPE_GEOATTRIBUTE 13 ///< An attribute reference
113 #define EV_TYPE_GLOBAL_VAR 20 ///< A global variable
114 #define EV_TYPE_CPPSYMBOL 45 ///< A symbol inside a function
115 #define EV_TYPE_UNRESOLVED_CPPSYMBOL 46 ///< An unknown function symbol
116 /// @}
117 
118 /// Typedefs for structures in the expression library
119 /// SYMBOL - any data in the expression (i.e. fpreal, string, variable)
120 /// TYPEDEF - a definition for a type (i.e. fpreal, string, etc.)
121 /// Defines how to handle this data type
122 /// OPERATOR - binary or unary operator which takes symbol(s) and
123 /// performs some action resulting in a new symbol
124 /// FUNCTION - function which takes arguments and performs some action
125 /// on them to produce a new symbol
126 /// EXPRESSION - the type seen to the outside world
127 /// @{
128 class EV_FUNCTION;
129 struct EV_SYMBOL;
130 typedef struct EV_TYPEDEF EV_TYPEDEF;
131 typedef struct EV_OPERATOR EV_OPERATOR;
132 typedef struct EV_FUNCHELP EV_FUNCHELP;
133 /// @}
134 
135 /// This callback is used to scan for op dependencies and add/remove
136 /// dependencies. Unlike evaluation, this callback can have null arguments.
137 /// A null argument signifies a non-constant parameter to the function.
139  EV_SYMBOL **argv,
140  void *ref_id);
142  EV_SYMBOL **argv,
143  char *new_args[],
144  const char *new_fullpath,
145  const char *old_fullpath,
146  const char *old_cwd,
147  const char *chan_name,
148  const char *old_chan_name);
149 
150 /// union used to hold a token's value
151 typedef union {
153  char *sval;
154  void *data;
155 } EV_TOKENVALUE;
156 
157 /// class representing a symbol operated upon by expressions
159 {
160  bool isForExprFunc() const
161  { return ((flag & EV_FOR_EXFUNC) != 0); }
163  { flag |= EV_FOR_EXFUNC; }
164  bool isConstant() const
165  { return ((flag & EV_SYMCONSTANT) != 0); }
166  bool isTransient() const
167  { return ((flag & EV_SYMTRANSIENT) != 0); }
168 
169  unsigned flag; ///< Flag for symbols
170  EV_TYPEDEF *type; ///< Interpretation of data
171  EV_TOKENVALUE value; ///< Token data
172  EV_SYMBOL *next; ///< Used Internally
173  int pos; ///< String pos in expression
174 };
175 
176 struct EV_TYPEDEF {
177  int type;
178  const char *name; /* Name of type */
181  EV_SYMBOL *(*resolveSymbol)(const char *, int thread);
182  const char *(*getName)(EV_SYMBOL *);
184  int (*castFrom)(EV_SYMBOL *me, EV_SYMBOL *from);
187  void (*opDepend)(EV_SYMBOL *src, void *ref_id);
188 
189  EV_TYPEDEF *next; /* Used Internally */
190  EV_TYPEDEF *varnext; /* Used Internally */
191 };
192 
193 /// struct describing an operator's characteristics
194 struct EV_OPERATOR {
195  int flag; ///< Flag for operator
196  int token; ///< OP_ token to identify
197  unsigned char binary; ///< Binary or unary operator
198  int leftType; ///< Data for left side of op
199  int rightType; ///< Data for right side of op
200  int resultType; ///< Resultant type of op
201 
203 
204  EV_OPERATOR *next; ///< Used internally
205 };
206 
207 /// Handy macros for defining expression functions.
208 /// They only differ by which function parameters are supplied to avoid
209 /// unused parameter warnings.
210 /// @{
211 #define EV_START_FN(name) \
212  static void name(EV_FUNCTION *, EV_SYMBOL *result,\
213  EV_SYMBOL **argv, int thread, unsigned &func_flags)
214 #define EV_START_FNNA(name) \
215  static void name(EV_FUNCTION *, EV_SYMBOL *result, \
216  EV_SYMBOL **, int thread, unsigned &func_flags)
217 #define EV_START_FUNC(name) \
218  static void name(EV_FUNCTION *func, EV_SYMBOL *result,\
219  EV_SYMBOL **argv, int thread, unsigned &func_flags)
220 #define EV_END_FN(answer) \
221  result->value.fval = (answer)
222 #define EV_END_FNS(answer) \
223  result->value.sval = (answer)
224 /// @}
225 
227  EV_SYMBOL *result,
228  EV_SYMBOL **argv,
229  int thread,
230  unsigned &func_flags);
231 
232 ///
234 public:
235  EV_FUNCTION(unsigned flag = 0,
236  const char *name = 0,
237  int num_args = 0,
238  int result_type = EV_TYPEFLOAT,
239  const int *argTypes = 0,
240  EXPRfuncCallback callback = 0,
241  EXPRopDependencyCallback dependCB = 0,
242  EXPRopChangeRefCallback changeOpRefCB = 0,
243  int is_safe = 1,
244  bool is_threadsafe = false);
245  virtual ~EV_FUNCTION();
246 
247  virtual int64 getMemoryUsage(bool inclusive) const;
248 
249  unsigned getUserFlags() const { return myUserFlags; }
250  const char *getName() const { return myName; }
251  int getNArgs() const { return myNArgs; }
252  int getResultType() const { return myResultType; }
253  const int *getArgTypes() const { return myArgTypes; }
254  int getArgType(int i) const { return myArgTypes[i]; }
255  const char *getDSOLocation() const { return myDSOLocation; }
256 
257  /// getInstanceData() returns the instance data for the current evaluating
258  /// expression function
259  static void *getInstanceData(int thread);
260  static void setInstanceAllocator(const char *function,
261  void *(*alloc)(), void (*freer)(void *));
262  void setInstanceAllocator(void *(*alloc)(), void (*freer)(void *))
263  {
264  myAllocator = alloc;
265  myFreer = freer;
266  }
267  void *allocInstanceData() { return myAllocator ? myAllocator() : 0; }
268  void freeInstanceData(void *d) { myFreer(d); }
269 
271  {
272  myDependCallback = cb;
273  }
275  {
276  myChangeOpRefCallback = cb;
277  }
278 
279  // isSafe() tells us if we can call this expression function when the
280  // expression evaluator is in "safe" mode.
281  int isSafe() const { return myIsSafe; }
282 
283  void setIsThreadSafe(bool flag) { myIsThreadSafe = flag; }
284  bool isThreadSafe() const { return myIsThreadSafe; }
285 
286 public:
290 
291 private:
292  const char *myName;
293  char *myDSOLocation;
294  int myNArgs;
295  int myResultType;
296  const int *myArgTypes;
297  void *(*myAllocator)();
298  void (*myFreer)(void *);
299  unsigned myUserFlags;
300  unsigned myIsSafe:1,
301  myIsThreadSafe:1;
302 };
303 
304 
305 /// This is an enumeration of the type of return values that an inline
306 /// function may be expected to return. Setting this value to
307 /// EV_EXPR_RETURN_NONE will disallow an expression from supporting inline
308 /// functions.
310 {
316 };
317 
318 
319 /// Structure used as the parameter to ev_ChangeOpReference
320 /// (Currently only used internally)
322 {
323  const char *new_fullpath;
324  const char *old_fullpath;
325  const char *old_cwd;
326  const char *chan_name;
327  const char *old_chan_name;
328 };
329 
330 class in_INSTRUCTION;
331 
333  : public UT_SmallObject<EV_EXPRESSION,
334  UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
335  UT_SMALLOBJECT_PAGESIZE_DEFAULT,
336  UT_SMALLOBJECT_THREADSAFE_ON>
337 {
338 public:
340  {
341  myFlags = 0;
342  mySource = 0;
343  myCompiled = 0;
344  myRecurs = 0;
345  myFunc = 0;
346  myFuncRetType = ret_type;
347  myInExprFunc = false;
348  myNeedResolveVars = false;
349  myIsPureCompiled = false;
350  }
352  {
353  freeExprSpace();
354  }
355 
356  int64 getMemoryUsage(bool inclusive) const;
357 
358  /// Common evaluation functions.
359  /// NOTES:
360  /// - These functions will cast to the desired return type.
361  /// - The thread parameter should be equivalent to SYSgetSTID()
362  /// @{
363  bool evaluate(int thread, fpreal &result);
364  bool evaluate(int thread, UT_String &result);
365  bool evaluate(int thread, ev_Vector &result);
366  bool evaluate(int thread, ev_Matrix &result);
367  /// @}
368 
369  /// Raw evaluation function that does no casting.
370  /// @{
372  { return evaluate(myFuncRetType, thread); }
373  EV_SYMBOL * evaluate(EV_InlineFuncReturnType func_ret_type, int thread);
374  /// @}
375 
376  bool changeExpr(const char *source);
377  void unresolveVars(int thread);
378  void dirtyExpr();
379 
380  /// Dependencies
381  /// @{
382  void updateOpDependency(void *ref_id, int thread);
383  int changeOpReference(const char *new_fullpath,
384  const char *old_fullpath,
385  const char *old_cwd,
386  const char *chan_name,
387  const char *old_chan_name,
388  int thread);
389  /// @}
390 
391  /// Save and load compiled expressions
392  /// @{
393  bool saveCompiledCode(std::ostream &os, int thread);
394  bool loadCompiledCode(UT_IStream &is, int thread);
395  /// @}
396 
397  /// Thread-Safe Flags Access
398  /// @{
399  unsigned int getFlags() const
400  {
401  // Synchronize with SYSstoreFence() in evaluate()
402  // where we set myFlags
403  unsigned flags =
404  *static_cast<unsigned const volatile *>(&myFlags);
405  SYSloadFence();
406  return flags;
407  }
408  bool hasFlag(unsigned int bit) const
409  { return ((getFlags() & bit) != 0); }
410  bool isEvaluated() const
411  { return ((getFlags() & EV_FLAGS_SET) != 0); }
412  SYS_DEPRECATED_REPLACE(17.5, "clearAllFlagsUnsafe")
413  void clearAllFlags()
414  { myFlags = 0; }
415  SYS_DEPRECATED_REPLACE(17.5, "setFlagsUnsafe")
416  void setFlags(unsigned int flags)
417  { myFlags = flags; }
418  SYS_DEPRECATED_REPLACE(17.5, "appendFlagsUnsafe")
419  void appendFlags(unsigned int flag)
420  { myFlags |= flag; }
421  SYS_DEPRECATED_REPLACE(17.5, "setEvaluatedUnsafe")
422  void setEvaluated()
423  { myFlags |= EV_FLAGS_SET; }
424  SYS_DEPRECATED_REPLACE(17.5, "clearFlagsBeforeEvaluationUnsafe")
425  void clearFlagsBeforeEvaluation()
426  { myFlags &= ~(EX_USERFLAGMASK | EV_FLAGS_SET); }
427 
428  /// @}
429 
430  /// Non-Thread-Safe Flags Access. Writes need to be locked using getLock().
431  /// @{
432  unsigned int getFlagsUnsafe() const
433  { return myFlags; }
434  bool hasFlagUnsafe(unsigned int bit) const
435  { return ((myFlags & bit) != 0); }
437  { myFlags = 0; }
438  void setFlagsUnsafe(unsigned int flags)
439  { myFlags = flags; }
440  void appendFlagsUnsafe(unsigned int flag)
441  { myFlags |= flag; }
443  { myFlags |= EV_FLAGS_SET; }
444  bool isEvaluatedUnsafe() const
445  { return ((myFlags & EV_FLAGS_SET) != 0); }
446 
447  /// This function is called before evaluating EXPR expressions and python
448  /// expressions to clear the appropriate flags on the expression.
450  { myFlags &= ~(EX_USERFLAGMASK | EV_FLAGS_SET); }
451  /// @}
452 
453  /// Other accesors
454  /// @{
455  const char * getSource() const
456  { return mySource; }
457  bool isCompiled() const
458  { return (myCompiled != 0); }
459 
460  bool isPureCompiled() const
461  { return myIsPureCompiled; }
462 
463  /// getSingleFunctionInstanceData() returns the instance data for this
464  /// expression's function which must be of form func("literal").
465  /// Returns NULL if this expression doesn't have the right form.
466  void * getSingleFunctionInstanceData(
467  EV_FUNCTION *func, int thread, UT_String &argument);
468 
469  /// isInExprFunc() says whether we are an expression inside a custom expr
470  /// function. It is turned on in EX_ExprFunc.
471  bool isInExprFunc() const
472  { return myInExprFunc; }
473  void setInExprFunc(bool is_inside)
474  { myInExprFunc = is_inside; }
475  /// @}
476 
479  { return myFuncRetType; }
481  { myFuncRetType = ret_type; }
482 
483  /// Return a reference for thread-safe access
484  EXPR_Lock & getLock() const
485  { return myLock; }
486 
487 private: // methods
488  void freeCompiledExpr(EV_SYMBOL *&free_list);
489  bool parseInlineFunc(UT_String &func_call, int thread);
490  int compile(const char *tstring, int thread,
491  bool ignore_bad_vars);
492  int parseExpr(EV_InlineFuncReturnType func_ret_type,
493  int thread, bool ignore_bad_vars);
494  bool freeExprSpace();
495  void doUpdateOpDependency(void *ref_id, int thread);
496  int doChangeOpReference(UT_String &new_source,
498  int thread);
499 
500 private: // data
501  unsigned myFlags; /* Expression flag */
502  char *mySource; /* Readable expression */
503  in_INSTRUCTION *myCompiled; /* Compiled expression */
504  int myRecurs; /* Recursion count */
505  EX_ExprFunc *myFunc; /* Inline function */
506  EV_InlineFuncReturnType myFuncRetType; /* Return type for inline func*/
507  mutable EXPR_Lock myLock;
508  bool myInExprFunc:1;/* Inside a custom EXPR func*/
509  bool myNeedResolveVars:1;
510  // True if the expression was loaded as a compiled
511  // expression, false otherwise.
512  bool myIsPureCompiled:1;
513 };
514 
515 /// initialize floating point operations
516 /// Float initialization will automatically initialize vector/matrix
517 EXPR_API extern void ev_InitFloat(void);
518 /// initialize string operations
519 EXPR_API extern void ev_InitString(void);
520 EXPR_API extern void ev_InitVariable(void);
521 /// initialize vector operations
522 EXPR_API extern void ev_InitVector(void);
523 /// initialize matrix operations
524 EXPR_API extern void ev_InitMatrix(void);
525 EXPR_API extern void ev_InitUserFunc(void);
526 
527 /// Functions for expansion of library
528 /// Add operators, type definitions and functions.
529 /// @{
530 EXPR_API extern void ev_AddType(EV_TYPEDEF *type);
531 EXPR_API extern void ev_AddVariableType(EV_TYPEDEF *type, int atEnd);
533 EXPR_API extern void ev_AddOperator(EV_OPERATOR *op, int level);
536 EXPR_API extern void ev_SetOptimization(int level);
537 /// @}
538 
539 EXPR_API extern void ev_PrintHelp(std::ostream &os, const char *match,
540  const char *keyword,
541  bool full_match_only = false);
542 
543 EXPR_API extern int ev_GetNFunctions();
544 EXPR_API extern EV_FUNCTION *ev_GetFunction(int i);
545 EXPR_API extern EV_TYPEDEF *ev_GetTypeDef(int key);
546 EXPR_API extern int ev_FindFunction(const char *name);
547 
548 /// Functions for supplying state data for custom expressions.
549 // @{
550 
551 /// This function specifies the constructor/destructor functions for the
552 /// state data.
553 /// @param function Name of the custom expression function
554 /// @param alloc This allocates and initializes the state data
555 /// @param free This deallocates the state data
557  const char *function,
558  void *(*alloc)(),
559  void (*free)(void *));
560 
561 /// From within an expression function, use this to retrieve the data created
562 /// by the alloc function specified in ev_SetFunctionInstanceAllocator().
563 /// @param thread Thread id supplied to the expression function callback
564 EXPR_API extern void *ev_GetFunctionData(int thread);
565 
566 // @}
567 
569  const char *func,
570  EXPRopDependencyCallback depend_cb,
571  EXPRopChangeRefCallback changeref_cb);
572 
573 // Basic level of operation as seen by application
575 EXPR_API extern int ev_ChangeExpr(EV_EXPRESSION *expr,
576  const char *source);
577 EXPR_API extern void ev_UnresolveVars(EV_EXPRESSION *expr,
578  int thread);
580  int thread);
582  EV_EXPRESSION *expr,
583  int thread);
584 EXPR_API extern int ev_EvaluateVector(EV_EXPRESSION *expr,
585  ev_Vector &result,
586  int thread);
587 EXPR_API extern int ev_EvaluateMatrix(EV_EXPRESSION *expr,
588  ev_Matrix &result,
589  int thread);
590 EXPR_API extern void ev_FreeExpr(EV_EXPRESSION *expr);
591 
593  void *ref_id, int thread);
595  const char *new_fullpath,
596  const char *old_fullpath,
597  const char *old_cwd,
598  const char *chan_name,
599  const char *old_chan_name,
600  int thread);
602  EV_EXPRESSION *expr,
603  EV_InlineFuncReturnType func_ret_type,
604  int thread);
605 
606 /// These functions save and load compiled expressions.
607 /// @{
608 EXPR_API extern bool ev_SaveCompiledCode(EV_EXPRESSION *expr,
609  std::ostream &os, int thread);
610 EXPR_API extern bool ev_LoadCompiledCode(EV_EXPRESSION *expr,
611  UT_IStream &is, int thread);
612 /// @}
613 
614 /// Functions used internally by type declarations
615 /// @{
616 EXPR_API extern EV_SYMBOL *ev_AllocSymbol(int type, int thread);
617 EXPR_API extern void ev_FreeSymbol(EV_SYMBOL *symbol, int thread);
618 /// @}
619 
620 /// Nice conversion of float to string data. This will do simple checks to try
621 /// to convert integer values more correctly.
622 EXPR_API extern void EXPRftoa(UT_WorkBuffer &buf, fpreal v);
623 
624 /// Following are the defines/typedefs for the language handler
625 /// @{
626 typedef struct EV_SYMTABLE EV_SYMTABLE;
627 
628 struct EV_SYMTABLE { /* Used internally */
629  int flag;
630  char *name;
631  fpreal *value; /* Value of symbol */
632  EV_SYMBOL *sym; /* symbol */
634 };
635 
636 struct EV_FUNCHELP {
637  char *name; /* Name of the function */
638  char *argname[EV_NHELPARGS]; /* Arg names */
639  char *description; /* A brief description */
640 };
641 /// @}
642 
643 EXPR_API extern void ev_SetExpander(ev_Expander expander);
644 
645 /// These functions put the expression evaluator into/out of "safe" mode.
646 /// In safe mode, certain functions will not be executed.
647 /// @{
648 EXPR_API extern void ev_setSafeMode(bool safe_mode);
649 EXPR_API extern bool ev_isInSafeMode();
650 EXPR_API extern bool ev_isKeyword(const char *string);
651 /// @}
652 
653 #endif
const char * old_cwd
Definition: EXPR.h:325
EXPR_API void ev_InitMatrix(void)
initialize matrix operations
EXPR_API void ev_UpdateOpDependency(EV_EXPRESSION *expr, void *ref_id, int thread)
const char * old_fullpath
Definition: EXPR.h:324
int(* castFrom)(EV_SYMBOL *me, EV_SYMBOL *from)
Definition: EXPR.h:184
void setInstanceAllocator(void *(*alloc)(), void(*freer)(void *))
Definition: EXPR.h:262
EXPRopChangeRefCallback myChangeOpRefCallback
Definition: EXPR.h:289
EXPR_API void ev_DeleteVariableType(EV_TYPEDEF *type)
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_setSafeMode(bool safe_mode)
union used to hold a token's value
Definition: EXPR.h:151
void * allocInstanceData()
Definition: EXPR.h:267
GLenum src
Definition: glew.h:2410
void freeInstanceData(void *d)
Definition: EXPR.h:268
void setChangeOpRefCallback(EXPRopChangeRefCallback cb)
Definition: EXPR.h:274
EXPR_API void ev_FreeExpr(EV_EXPRESSION *expr)
void clearFlagsBeforeEvaluationUnsafe()
Definition: EXPR.h:449
GLuint const GLchar * name
Definition: glew.h:1814
const char * getName() const
Definition: EXPR.h:250
void(* freeValue)(EV_SYMBOL *)
Definition: EXPR.h:180
fpreal * value
Definition: EXPR.h:631
void(* EXPRopDependencyCallback)(EV_FUNCTION *me, EV_SYMBOL **argv, void *ref_id)
Definition: EXPR.h:138
void setEvaluatedUnsafe()
Definition: EXPR.h:442
EXPR_API void ev_InitVector(void)
initialize vector operations
const int * getArgTypes() const
Definition: EXPR.h:253
int(* castValue)(EV_SYMBOL *to, EV_SYMBOL *me, int thread)
Definition: EXPR.h:183
int pos
String pos in expression.
Definition: EXPR.h:173
int flag
Flag for operator.
Definition: EXPR.h:195
unsigned flag
Flag for symbols.
Definition: EXPR.h:169
EXPR_API EV_TYPEDEF * ev_GetTypeDef(int key)
EXPR_API EV_SYMBOL * ev_AllocSymbol(int type, int thread)
EXPR_Lock & getLock() const
Return a reference for thread-safe access.
Definition: EXPR.h:484
void setFlagsUnsafe(unsigned int flags)
Definition: EXPR.h:438
#define EV_FOR_EXFUNC
Definition: EXPR.h:83
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
#define SYSloadFence()
bool isConstant() const
Definition: EXPR.h:164
int type
Definition: EXPR.h:177
int leftType
Data for left side of op.
Definition: EXPR.h:198
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
void(* EXPRfuncCallback)(EV_FUNCTION *me, EV_SYMBOL *result, EV_SYMBOL **argv, int thread, unsigned &func_flags)
Definition: EXPR.h:226
unsigned int getFlagsUnsafe() const
Definition: EXPR.h:432
const GLdouble * v
Definition: glew.h:1391
EXPR_API void ev_FreeSymbol(EV_SYMBOL *symbol, int thread)
EV_TYPEDEF * varnext
Definition: EXPR.h:190
EV_EXPRESSION(EV_InlineFuncReturnType ret_type)
Definition: EXPR.h:339
const char * new_fullpath
Definition: EXPR.h:323
bool hasFlagUnsafe(unsigned int bit) const
Definition: EXPR.h:434
int getFlags(int version)
Definition: ImfVersion.h:117
EXPR_API bool ev_SaveCompiledCode(EV_EXPRESSION *expr, std::ostream &os, int thread)
int isSafe() const
Definition: EXPR.h:281
EV_TYPEDEF * type
Interpretation of data.
Definition: EXPR.h:170
EXPR_API fpreal ev_EvaluateFloat(EV_EXPRESSION *expr, int thread)
EXPR_API EV_SYMBOL * ev_Evaluate(EV_EXPRESSION *expr, EV_InlineFuncReturnType func_ret_type, int thread)
int rightType
Data for right side of op.
Definition: EXPR.h:199
EXPR_API int ev_EvaluateMatrix(EV_EXPRESSION *expr, ev_Matrix &result, int thread)
EXPR_API bool ev_isKeyword(const char *string)
int(* getCastType)(EV_SYMBOL *src)
Definition: EXPR.h:186
const char * name
Definition: EXPR.h:178
int token
OP_ token to identify.
Definition: EXPR.h:196
EXPR_API void ev_UnresolveVars(EV_EXPRESSION *expr, int thread)
EXPR_API void * ev_GetFunctionData(int thread)
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
int getNArgs() const
Definition: EXPR.h:251
EV_SYMBOL * next
Used Internally.
Definition: EXPR.h:172
void clearAllFlagsUnsafe()
Definition: EXPR.h:436
EV_TOKENVALUE value
Token data.
Definition: EXPR.h:171
long long int64
Definition: SYS_Types.h:111
EXPR_API void ev_InitVariable(void)
EXPRfuncCallback myCallback
Definition: EXPR.h:287
EXPR_API void ev_InitUserFunc(void)
bool isCompiled() const
Definition: EXPR.h:457
EXPR_API void EXPRftoa(UT_WorkBuffer &buf, fpreal v)
EXPR_API void ev_InitString(void)
initialize string operations
fpreal fval
Definition: EXPR.h:152
EXPR_API int ev_GetNFunctions()
EXPR_API void ev_DeleteFunction(EV_FUNCTION *func)
EV_SYMBOL * evaluate(int thread)
Definition: EXPR.h:371
EXPR_API EV_FUNCTION * ev_GetFunction(int i)
bool isPureCompiled() const
Definition: EXPR.h:460
EXPR_API void ev_SetExpander(ev_Expander expander)
#define EV_TYPEFLOAT
Float type of symbol.
Definition: EXPR.h:98
EXPR_API void ev_InitFloat(void)
const char * chan_name
Definition: EXPR.h:326
char * description
Definition: EXPR.h:639
void(* evaluate)(EV_SYMBOL *, EV_SYMBOL *, EV_SYMBOL *)
Definition: EXPR.h:202
void
Definition: png.h:1083
bool isThreadSafe() const
Definition: EXPR.h:284
EXPR_API void ev_PrintHelp(std::ostream &os, const char *match, const char *keyword, bool full_match_only=false)
EXPR_API int ev_ChangeExpr(EV_EXPRESSION *expr, const char *source)
#define EV_FLAGS_SET
User flags have been set.
Definition: EXPR.h:80
EXPR_API void ev_SetOptimization(int level)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void * data
Definition: EXPR.h:154
EXPR_API bool ev_isInSafeMode()
EXPR_API void ev_AddFunction(EV_FUNCTION *func)
bool isInExprFunc() const
Definition: EXPR.h:471
*Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
char * sval
Definition: EXPR.h:153
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
#define EV_NHELPARGS
Definition: EXPR.h:35
char * argname[EV_NHELPARGS]
Definition: EXPR.h:638
int resultType
Resultant type of op.
Definition: EXPR.h:200
class representing a symbol operated upon by expressions
Definition: EXPR.h:158
bool isEvaluatedUnsafe() const
Definition: EXPR.h:444
#define EV_SYMCONSTANT
Symbol has a constant value.
Definition: EXPR.h:79
#define EV_SYMTRANSIENT
Symbol is result of operation.
Definition: EXPR.h:78
struct describing an operator's characteristics
Definition: EXPR.h:194
bool hasFlag(unsigned int bit) const
Definition: EXPR.h:408
void setIsThreadSafe(bool flag)
Definition: EXPR.h:283
EV_InlineFuncReturnType getInlineFuncRetType() const
Definition: EXPR.h:478
EXPR_API int ev_EvaluateVector(EV_EXPRESSION *expr, ev_Vector &result, int thread)
EXPR_API void ev_AddVariableType(EV_TYPEDEF *type, int atEnd)
void(* copyValue)(EV_SYMBOL *dest, EV_SYMBOL *src, int thread)
Definition: EXPR.h:185
bool isTransient() const
Definition: EXPR.h:166
EXPR_API void ev_AddOperator(EV_OPERATOR *op, int level)
double fpreal
Definition: SYS_Types.h:276
EV_SYMTABLE * next
Definition: EXPR.h:633
GLenum func
Definition: glcorearb.h:782
EXPR_API EV_EXPRESSION * ev_AllocExpr(EV_InlineFuncReturnType rettype)
EV_InlineFuncReturnType
Definition: EXPR.h:309
EXPR_API bool ev_LoadCompiledCode(EV_EXPRESSION *expr, UT_IStream &is, int thread)
void appendFlagsUnsafe(unsigned int flag)
Definition: EXPR.h:440
void setOpDependencyCallback(EXPRopDependencyCallback cb)
Definition: EXPR.h:270
EV_SYMBOL * sym
Definition: EXPR.h:632
char *(* ev_Expander)(const char *str, int thread)
Definition: EXPR.h:37
int getResultType() const
Definition: EXPR.h:252
EV_TYPEDEF * next
Definition: EXPR.h:189
bool isForExprFunc() const
Definition: EXPR.h:160
int flag
Definition: EXPR.h:629
void setForExprFunc()
Definition: EXPR.h:162
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_AddType(EV_TYPEDEF *type)
const char * old_chan_name
Definition: EXPR.h:327
GLuint64EXT * result
Definition: glew.h:14007
char * name
Definition: EXPR.h:637
const char * getSource() const
Definition: EXPR.h:455
EXPRopDependencyCallback myDependCallback
Definition: EXPR.h:288
const char * getDSOLocation() const
Definition: EXPR.h:255
#define EXPR_API
Definition: EXPR_API.h:10
void(* allocValue)(EV_SYMBOL *)
Definition: EXPR.h:179
#define EX_USERFLAGMASK
Definition: EXPR.h:86
unsigned getUserFlags() const
Definition: EXPR.h:249
EXPR_API void ev_EvaluateString(UT_String &result, EV_EXPRESSION *expr, int thread)
void setInExprFunc(bool is_inside)
Definition: EXPR.h:473
~EV_EXPRESSION()
Definition: EXPR.h:351
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2580
EXPR_API int ev_FindFunction(const char *name)
unsigned int getFlags() const
Definition: EXPR.h:399
GLint level
Definition: glew.h:1252
char * name
Definition: EXPR.h:630
void(* opDepend)(EV_SYMBOL *src, void *ref_id)
Definition: EXPR.h:187
unsigned char binary
Binary or unary operator.
Definition: EXPR.h:197
void setInlineFuncRetType(EV_InlineFuncReturnType ret_type)
Definition: EXPR.h:480
bool isEvaluated() const
Definition: EXPR.h:410
int getArgType(int i) const
Definition: EXPR.h:254
EV_OPERATOR * next
Used internally.
Definition: EXPR.h:204
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)
Definition: EXPR.h:141
EXPR_API void ev_SetFunctionDependencyCallbacks(const char *func, EXPRopDependencyCallback depend_cb, EXPRopChangeRefCallback changeref_cb)