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