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