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