Go to the documentation of this file.
11 #ifndef __GA_IntrinsicMacros__
12 #define __GA_IntrinsicMacros__
125 #define GA_START_INTRINSIC_DEF(CLASS, NUM_INTRINSICS) \
128 class _ga_intrinsicEvaluator##CLASS \
131 typedef GA_Size (*cbTupleSize)(const CLASS *obj); \
132 typedef GA_Size (*cbEvalI)(const CLASS *obj, int64 *v, GA_Size size); \
133 typedef GA_Size (*cbEvalF)(const CLASS *obj, fpreal64 *v, GA_Size size); \
134 typedef GA_Size (*cbEvalS)(const CLASS *obj, UT_String &s); \
135 typedef GA_Size (*cbEvalSA)(const CLASS *obj, UT_StringArray &s); \
136 typedef GA_Size (*cbEvalD)(const CLASS *obj, UT_OptionsHolder &s); \
137 typedef GA_Size (*cbEvalDA)(const CLASS *obj, UT_Array<UT_OptionsHolder> &s); \
138 typedef GA_Size (*cbSetI)(CLASS *obj, const int64 *v, GA_Size size); \
139 typedef GA_Size (*cbSetF)(CLASS *obj, const fpreal64 *v, GA_Size size); \
140 typedef GA_Size (*cbSetS)(CLASS *obj, const char **v, GA_Size size); \
141 typedef GA_Size (*cbSetSA)(CLASS *obj, const UT_StringArray &v); \
142 typedef GA_Size (*cbSetD)(CLASS *obj, const UT_OptionsHolder *v, GA_Size size); \
143 typedef GA_Size (*cbSetDA)(CLASS *obj, const UT_Array<UT_OptionsHolder> &v); \
144 static GA_Size failTS(const CLASS *) { return 0; } \
145 static GA_Size failI(const CLASS *, int64 *, GA_Size) { UT_ASSERT(0); return 0; } \
146 static GA_Size failF(const CLASS *, fpreal64 *, GA_Size) { UT_ASSERT(0); return 0; } \
147 static GA_Size failS(const CLASS *, UT_String &) { UT_ASSERT(0); return 0; } \
148 static GA_Size failSA(const CLASS *, UT_StringArray &) { UT_ASSERT(0); return 0; } \
149 static GA_Size failD(const CLASS *, UT_OptionsHolder &) { UT_ASSERT(0); return 0; } \
150 static GA_Size failDA(const CLASS *, UT_Array<UT_OptionsHolder> &) { UT_ASSERT(0); return 0; } \
151 static GA_Size failI(CLASS *, const int64 *, GA_Size) { UT_ASSERT(0); return 0; } \
152 static GA_Size failF(CLASS *, const fpreal64 *, GA_Size) { UT_ASSERT(0); return 0; } \
153 static GA_Size failS(CLASS *, const char **, GA_Size) { UT_ASSERT(0); return 0; } \
154 static GA_Size failSA(CLASS *, const UT_StringArray &) { UT_ASSERT(0); return 0; } \
155 static GA_Size failD(CLASS *, const UT_OptionsHolder *, GA_Size) { UT_ASSERT(0); return 0; } \
156 static GA_Size failDA(CLASS *, const UT_Array<UT_OptionsHolder> &) { UT_ASSERT(0); return 0; } \
164 , myStore(GA_STORECLASS_INVALID) \
165 , myTupleSizeCB(failTS) \
180 , myCollapseSingletons(true) \
183 GA_Size getTupleSize(const CLASS *o) const \
185 if (myTupleSize > 0) return myTupleSize; \
186 return myTupleSizeCB(o); \
189 fprintf(stderr, "Intrinsic[%d] := {\n", myId); \
190 fprintf(stderr, " 'name' : '%s'\n", myName); \
191 fprintf(stderr, " 'tuple' : %d\n", (int)myTupleSize); \
192 fprintf(stderr, " 'storage' : %s\n", GAstorageClass(myStore));\
193 fprintf(stderr, " 'ro' : %d\n", myReadOnly); \
194 fprintf(stderr, " 'tuple()' : %p\n", myTupleSizeCB); \
195 fprintf(stderr, " 'options' : %p\n", myOptions); \
196 fprintf(stderr, " 'I()' : %p\n", myI); \
197 fprintf(stderr, " 'F()' : %p\n", myF); \
198 fprintf(stderr, " 'S()' : %p\n", myS); \
199 fprintf(stderr, " 'SA()' : %p\n", mySA); \
200 fprintf(stderr, " 'D()' : %p\n", myD); \
201 fprintf(stderr, " 'DA()' : %p\n", myDA); \
202 fprintf(stderr, " 'setI()' : %p\n", mySetI); \
203 fprintf(stderr, " 'setF()' : %p\n", mySetF); \
204 fprintf(stderr, " 'setSS()' : %p\n", mySetSS); \
205 fprintf(stderr, " 'setSA()' : %p\n", mySetSA); \
206 fprintf(stderr, " 'setDS()' : %p\n", mySetDS); \
207 fprintf(stderr, " 'setDA()' : %p\n", mySetDA); \
209 bool valid(int index) const \
211 if (myName && myId >= 0 && myStore != GA_STORECLASS_INVALID \
212 && (myTupleSize > 0 || myTupleSizeCB) \
213 && (myI || myF || myS || mySA)) \
215 fprintf(stderr, "Warning: missing intrinsic for %s[%d]\n", \
219 cbTupleSize myTupleSizeCB; \
232 const char *myName; \
233 const UT_Options *myOptions; \
234 GA_Size myTupleSize; \
236 GA_StorageClass myStore; \
238 bool myCollapseSingletons; \
240 Eval myEval[NUM_INTRINSICS]; \
241 int entries() const { return NUM_INTRINSICS; } \
242 bool valid(int i) const { return myEval[i].valid(i); } \
243 GA_Size getTupleSize(int i, const CLASS *o) const \
244 { return myEval[i].getTupleSize(o); } \
245 GA_Size evalI(int i, const CLASS *o, int64 *v, GA_Size n) const \
246 { return myEval[i].myI(o, v, n); } \
247 GA_Size evalF(int i, const CLASS *o, fpreal64 *v, GA_Size n) const \
248 { return myEval[i].myF(o, v, n); } \
249 GA_Size evalS(int i, const CLASS *o, UT_String &v) const \
250 { return myEval[i].myS(o, v); } \
251 GA_Size evalSA(int i, const CLASS *o, UT_StringArray &v) const \
252 { return myEval[i].mySA(o, v); } \
253 GA_Size evalD(int i, const CLASS *o, UT_OptionsHolder &v) const \
254 { return myEval[i].myD(o, v); } \
255 GA_Size evalDA(int i, const CLASS *o, UT_Array<UT_OptionsHolder> &v) const \
256 { return myEval[i].myDA(o, v); } \
257 GA_Size setI(int i, CLASS *o, const int64 *v, GA_Size n) const \
258 { return myEval[i].mySetI(o, v, n); } \
259 GA_Size setF(int i, CLASS *o, const fpreal64 *v, GA_Size n) const \
260 { return myEval[i].mySetF(o, v, n); } \
261 GA_Size setSS(int i, CLASS *o, const char **v, GA_Size n) const \
262 { return myEval[i].mySetSS(o, v, n); } \
263 GA_Size setSA(int i, CLASS *o, const UT_StringArray &v) const \
264 { return myEval[i].mySetSA(o, v); } \
265 GA_Size setDS(int i, CLASS *o, const UT_OptionsHolder *v, GA_Size n) const \
266 { return myEval[i].mySetDS(o, v, n); } \
267 GA_Size setDA(int i, CLASS *o, const UT_Array<UT_OptionsHolder> &v) const \
268 { return myEval[i].mySetDA(o, v); } \
269 GA_StorageClass getStorageClass(int i) const \
270 { return myEval[i].myStore; } \
271 const char *getName(int i) const { return myEval[i].myName; } \
272 int getId(int i) const { return myEval[i].myId; } \
273 bool getReadOnly(int i) const { return myEval[i].myReadOnly; } \
274 bool getCollapseSingletons(int i) const \
275 { return myEval[i].myCollapseSingletons; } \
276 const UT_Options *getOptions(int i) const \
277 { return myEval[i].myOptions; } \
278 _ga_intrinsicEvaluator##CLASS() {
280 #define GA_END_INTRINSIC_DEF(CLASS, BASECLASS) \
283 static GA_IntrinsicDef _theIntrinsics##CLASS; \
284 static _ga_intrinsicEvaluator##CLASS _theEval##CLASS; \
286 GA_IntrinsicManager::Registrar \
287 CLASS::registerIntrinsics(GA_PrimitiveDefinition &defn) \
289 GA_IntrinsicManager::Registrar r(BASECLASS::registerIntrinsics(defn)); \
290 using Collapse = GA_IntrinsicManager::CollapseSingletons; \
291 if (r.start(_theIntrinsics##CLASS)) \
293 for (int i = 0; i < _theEval##CLASS.entries(); ++i) \
295 UT_ASSERT(_theEval##CLASS.getName(i)); \
296 if (_theEval##CLASS.valid(i)) \
298 r.addAttribute(_theEval##CLASS.getStorageClass(i), \
299 _theEval##CLASS.getName(i), \
300 _theEval##CLASS.getId(i), \
301 _theEval##CLASS.getReadOnly(i), \
302 _theEval##CLASS.getCollapseSingletons(i) ? \
303 Collapse::YES : Collapse::NO, \
304 _theEval##CLASS.getOptions(i)); \
311 CLASS::localIntrinsicTupleSize(const GA_IntrinsicEval &eval) const \
313 int id = eval.getUserId(_theIntrinsics##CLASS); \
314 if (id >= 0 && id < _theEval##CLASS.entries()) \
315 return _theEval##CLASS.getTupleSize(id, this); \
316 return BASECLASS::localIntrinsicTupleSize(eval); \
319 CLASS::localGetIntrinsicI(const GA_IntrinsicEval &eval, \
320 int64 *v, GA_Size size) const \
322 int id = eval.getUserId(_theIntrinsics##CLASS); \
323 if (id >= 0 && id < _theEval##CLASS.entries()) \
324 return _theEval##CLASS.evalI(id, this, v, size); \
325 return BASECLASS::localGetIntrinsicI(eval, v, size); \
328 CLASS::localGetIntrinsicF(const GA_IntrinsicEval &eval, \
329 fpreal64 *v, GA_Size size) const \
331 int id = eval.getUserId(_theIntrinsics##CLASS); \
332 if (id >= 0 && id < _theEval##CLASS.entries()) \
333 return _theEval##CLASS.evalF(id, this, v, size); \
334 return BASECLASS::localGetIntrinsicF(eval, v, size); \
337 CLASS::localGetIntrinsicS(const GA_IntrinsicEval &eval, \
338 UT_String &v) const \
340 int id = eval.getUserId(_theIntrinsics##CLASS); \
341 if (id >= 0 && id < _theEval##CLASS.entries()) \
342 return _theEval##CLASS.evalS(id, this, v); \
343 return BASECLASS::localGetIntrinsicS(eval, v); \
346 CLASS::localGetIntrinsicSA(const GA_IntrinsicEval &eval, \
347 UT_StringArray &v) const \
349 int id = eval.getUserId(_theIntrinsics##CLASS); \
350 if (id >= 0 && id < _theEval##CLASS.entries()) \
351 return _theEval##CLASS.evalSA(id, this, v); \
352 return BASECLASS::localGetIntrinsicSA(eval, v); \
355 CLASS::localGetIntrinsicD(const GA_IntrinsicEval &eval, \
356 UT_OptionsHolder &v) const \
358 int id = eval.getUserId(_theIntrinsics##CLASS); \
359 if (id >= 0 && id < _theEval##CLASS.entries()) \
360 return _theEval##CLASS.evalD(id, this, v); \
361 return BASECLASS::localGetIntrinsicD(eval, v); \
364 CLASS::localGetIntrinsicDA(const GA_IntrinsicEval &eval, \
365 UT_Array<UT_OptionsHolder> &v) const \
367 int id = eval.getUserId(_theIntrinsics##CLASS); \
368 if (id >= 0 && id < _theEval##CLASS.entries()) \
369 return _theEval##CLASS.evalDA(id, this, v); \
370 return BASECLASS::localGetIntrinsicDA(eval, v); \
373 CLASS::localSetIntrinsicI(const GA_IntrinsicEval &eval, \
374 const int64 *v, GA_Size size) \
376 int id = eval.getUserId(_theIntrinsics##CLASS); \
377 if (id >= 0 && id < _theEval##CLASS.entries()) \
378 return _theEval##CLASS.setI(id, this, v, size); \
379 return BASECLASS::localSetIntrinsicI(eval, v, size); \
382 CLASS::localSetIntrinsicF(const GA_IntrinsicEval &eval, \
383 const fpreal64 *v, GA_Size size) \
385 int id = eval.getUserId(_theIntrinsics##CLASS); \
386 if (id >= 0 && id < _theEval##CLASS.entries()) \
387 return _theEval##CLASS.setF(id, this, v, size); \
388 return BASECLASS::localSetIntrinsicF(eval, v, size); \
391 CLASS::localSetIntrinsicSS(const GA_IntrinsicEval &eval, \
392 const char **v, GA_Size size) \
394 int id = eval.getUserId(_theIntrinsics##CLASS); \
395 if (id >= 0 && id < _theEval##CLASS.entries()) \
396 return _theEval##CLASS.setSS(id, this, v, size); \
397 return BASECLASS::localSetIntrinsicSS(eval, v, size); \
400 CLASS::localSetIntrinsicSA(const GA_IntrinsicEval &eval, \
401 const UT_StringArray &v) \
403 int id = eval.getUserId(_theIntrinsics##CLASS); \
404 if (id >= 0 && id < _theEval##CLASS.entries()) \
405 return _theEval##CLASS.setSA(id, this, v); \
406 return BASECLASS::localSetIntrinsicSA(eval, v); \
409 CLASS::localSetIntrinsicDS(const GA_IntrinsicEval &eval, \
410 const UT_OptionsHolder *v, GA_Size size) \
412 int id = eval.getUserId(_theIntrinsics##CLASS); \
413 if (id >= 0 && id < _theEval##CLASS.entries()) \
414 return _theEval##CLASS.setDS(id, this, v, size); \
415 return BASECLASS::localSetIntrinsicDS(eval, v, size); \
418 CLASS::localSetIntrinsicDA(const GA_IntrinsicEval &eval, \
419 const UT_Array<UT_OptionsHolder> &v) \
421 int id = eval.getUserId(_theIntrinsics##CLASS); \
422 if (id >= 0 && id < _theEval##CLASS.entries()) \
423 return _theEval##CLASS.setDA(id, this, v); \
424 return BASECLASS::localSetIntrinsicDA(eval, v); \
428 #define GA_INTRINSIC_DEF(ID, NAME, TUPLESIZE, STORAGE) \
429 myEval[ID].myId = ID; \
430 myEval[ID].myName = NAME; \
431 myEval[ID].myStore = STORAGE; \
432 myEval[ID].myTupleSize = TUPLESIZE;
433 #define GA_INTRINSIC_DEF_VARYING(ID, NAME, TUPLESIZE_FUNC, STORAGE) \
434 myEval[ID].myId = ID; \
435 myEval[ID].myName = NAME; \
436 myEval[ID].myStore = STORAGE; \
437 myEval[ID].myTupleSizeCB = TUPLESIZE_FUNC;
442 #define GA_INTRINSIC_OPTIONS(ID, OPTIONS) \
443 myEval[ID].myOptions = &OPTIONS;
448 #define GA_INTRINSIC_COLLAPSE_SINGLETONS(ID, BOOL) \
449 myEval[ID].myCollapseSingletons = BOOL;
452 #define GA_INTRINSIC_DEF_I(ID, NAME, TUPLESIZE) \
453 GA_INTRINSIC_DEF(ID, NAME, TUPLESIZE, GA_STORECLASS_INT)
455 #define GA_INTRINSIC_DEF_VARYING_I(ID, NAME, TUPLESIZE_FUNC) \
456 GA_INTRINSIC_DEF_VARYING(ID, NAME, TUPLESIZE_FUNC, GA_STORECLASS_INT)
458 #define GA_INTRINSIC_I(CLASS, ID, NAME, EVAL) { \
460 static GA_Size eval(const CLASS *o, int64 *v, GA_Size) \
461 { v[0] = EVAL(o); return 1; } \
462 static GA_Size evalF(const CLASS *o, fpreal64 *v, GA_Size) \
463 { v[0] = EVAL(o); return 1; } \
465 GA_INTRINSIC_DEF_I(ID, NAME, 1) \
466 myEval[ID].myI = callbacks::eval; \
467 myEval[ID].myF = callbacks::evalF; \
469 #define GA_INTRINSIC_CONST_I(CLASS, ID, NAME, VALUE) { \
471 static GA_Size eval(const CLASS *, int64 *v, GA_Size) \
472 { v[0] = VALUE; return 1; } \
473 static GA_Size evalF(const CLASS *, fpreal64 *v, GA_Size) \
474 { v[0] = VALUE; return 1; } \
476 GA_INTRINSIC_DEF_I(ID, NAME, 1) \
477 myEval[ID].myI = callbacks::eval; \
478 myEval[ID].myF = callbacks::evalF; \
480 #define GA_INTRINSIC_METHOD_I(CLASS, ID, NAME, METHOD) { \
482 static GA_Size eval(const CLASS *o, int64 *v, GA_Size) \
483 { v[0] = o->METHOD(); return 1; } \
484 static GA_Size evalF(const CLASS *o, fpreal64 *v, GA_Size) \
485 { v[0] = o->METHOD(); return 1; } \
487 GA_INTRINSIC_DEF_I(ID, NAME, 1) \
488 myEval[ID].myI = callbacks::eval; \
489 myEval[ID].myF = callbacks::evalF; \
491 #define GA_INTRINSIC_TUPLE_I(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
493 static GA_Size evalF(const CLASS *o, fpreal64 *v, GA_Size sz) \
494 { int64 tmp[TUPLESIZE]; \
495 int result = EVAL(o, tmp, SYSmin(sz, TUPLESIZE)); \
496 for (int i = 0; i < SYSmin(sz, TUPLESIZE); i++) \
500 GA_INTRINSIC_DEF_I(ID, NAME, TUPLESIZE) \
501 myEval[ID].myI = EVAL; \
502 myEval[ID].myF = callbacks::evalF; \
504 #define GA_INTRINSIC_TUPLE_METHOD_I(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
506 static GA_Size eval(const CLASS *o, int64 *v, GA_Size sz) \
507 { return o->EVAL(v, sz); } \
508 static GA_Size evalF(const CLASS *o, fpreal64 *v, GA_Size sz) \
509 { int64 tmp[TUPLESIZE]; \
510 int result = o->EVAL(tmp, SYSmin(sz, TUPLESIZE)); \
511 for (exint i = 0; i < SYSmin(sz, TUPLESIZE); i++) { v[i] = tmp[i]; } \
514 GA_INTRINSIC_DEF_I(ID, NAME, TUPLESIZE) \
515 myEval[ID].myI = callbacks::eval; \
517 #define GA_INTRINSIC_ARRAY_I(CLASS, ID, NAME, ARRAY_TYPE, METHOD) { \
519 static GA_Size tsize(const CLASS *o) { return o->METHOD().entries(); } \
520 static GA_Size eval(const CLASS *o, int64 *v, GA_Size size) \
522 const ARRAY_TYPE &array = o->METHOD(); \
523 size = SYSmin(size, array.entries()); \
524 for (exint i = 0; i < size; ++i) { v[i] = array(i); } \
528 GA_INTRINSIC_DEF_VARYING_I(ID, NAME, callbacks::tsize) \
529 myEval[ID].myI = callbacks::eval; \
531 #define GA_INTRINSIC_VARYING_I(CLASS, ID, NAME, TSIZE, EVAL) { \
532 GA_INTRINSIC_DEF_VARYING_I(ID, NAME, TSIZE) \
533 myEval[ID].myI = EVAL; \
536 #define GA_INTRINSIC_SET_I(CLASS, ID, SETFUNC) { \
538 static GA_Size setFunc(CLASS *o, const int64 *v, GA_Size sz) \
539 { return SETFUNC(o, v[0]) ? 1 : 0; } \
540 static GA_Size setFuncF(CLASS *o, const fpreal64 *v, GA_Size sz) \
541 { return SETFUNC(o, v[0]) ? 1 : 0; } \
543 myEval[ID].mySetI = callbacks::setFunc; \
544 myEval[ID].mySetF = callbacks::setFuncF; \
545 myEval[ID].myReadOnly = false; \
547 #define GA_INTRINSIC_SET_METHOD_I(CLASS, ID, METHOD) { \
549 static GA_Size setFunc(CLASS *o, const int64 *v, GA_Size sz) \
550 { return o->METHOD(v[0]) ? 1 : 0; } \
551 static GA_Size setFuncF(CLASS *o, const fpreal64 *v, GA_Size sz) \
552 { return o->METHOD(v[0]) ? 1 : 0; } \
554 myEval[ID].mySetI = callbacks::setFunc; \
555 myEval[ID].mySetF = callbacks::setFuncF; \
556 myEval[ID].myReadOnly = false; \
558 #define GA_INTRINSIC_SET_TUPLE_I(CLASS, ID, SETFUNC) { \
560 static GA_Size setFunc(CLASS *o, const int64 *v, GA_Size sz) \
561 { return SETFUNC(o, v, sz); } \
562 static GA_Size setFuncF(CLASS *o, const fpreal64 *v, GA_Size sz) \
564 int64 *tmp = (int64 *)UTstackAlloc(sizeof(int64) * sz); \
565 for (exint i = 0; i < sz; i++) { tmp[i] = v[i]; } \
566 int result = SETFUNC(o, tmp, sz); \
571 myEval[ID].mySetI = callbacks::setFunc; \
572 myEval[ID].mySetF = callbacks::setFuncF; \
573 myEval[ID].myReadOnly = false; \
575 #define GA_INTRINSIC_SET_TUPLE_METHOD_I(CLASS, ID, METHOD) { \
577 static GA_Size setFunc(CLASS *o, const int64 *v, GA_Size sz) \
578 { return o->METHOD(v[0], sz); } \
579 static GA_Size setFuncF(CLASS *o, const fpreal64 *v, GA_Size sz) \
581 int64 *tmp = (int64 *)UTstackAlloc(sizeof(int64) * sz); \
582 for (exint i = 0; i < sz; i++) { tmp[i] = v[i]; } \
583 int result = o->SETFUNC(tmp, sz); \
588 myEval[ID].mySetI = callbacks::setFunc; \
589 myEval[ID].mySetF = callbacks::setFuncF; \
590 myEval[ID].myReadOnly = false; \
594 #define GA_INTRINSIC_DEF_F(ID, NAME, TUPLESIZE) \
595 GA_INTRINSIC_DEF(ID, NAME, TUPLESIZE, GA_STORECLASS_FLOAT)
597 #define GA_INTRINSIC_DEF_VARYING_F(ID, NAME, TUPLESIZE_FUNC) \
598 GA_INTRINSIC_DEF_VARYING(ID, NAME, TUPLESIZE_FUNC, GA_STORECLASS_FLOAT)
600 #define GA_INTRINSIC_F(CLASS, ID, NAME, EVAL) { \
602 static GA_Size eval(const CLASS *o, fpreal64 *v, GA_Size) \
603 { v[0] = EVAL(o); return 1; } \
605 GA_INTRINSIC_DEF_F(ID, NAME, 1) \
606 myEval[ID].myF = callbacks::eval; \
608 #define GA_INTRINSIC_CONST_F(CLASS, ID, NAME, VALUE) { \
610 static GA_Size eval(const CLASS *, fpreal64 *v, GA_Size) \
611 { v[0] = VALUE; return 1; } \
613 GA_INTRINSIC_DEF_F(ID, NAME, 1) \
614 myEval[ID].myF = callbacks::eval; \
616 #define GA_INTRINSIC_METHOD_F(CLASS, ID, NAME, METHOD) { \
618 static GA_Size eval(const CLASS *o, fpreal64 *v, GA_Size) \
619 { v[0] = o->METHOD(); return 1; } \
621 GA_INTRINSIC_DEF_F(ID, NAME, 1) \
622 myEval[ID].myF = callbacks::eval; \
624 #define GA_INTRINSIC_TUPLE_F(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
625 GA_INTRINSIC_DEF_F(ID, NAME, TUPLESIZE) \
626 myEval[ID].myF = EVAL; \
628 #define GA_INTRINSIC_TUPLE_METHOD_F(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
630 static GA_Size eval(const CLASS *o, fpreal64 *v, GA_Size sz) \
631 { return o->EVAL(v, sz); } \
633 GA_INTRINSIC_DEF_F(ID, NAME, TUPLESIZE) \
634 myEval[ID].myF = callbacks::eval; \
636 #define GA_INTRINSIC_ARRAY_F(CLASS, ID, NAME, ARRAY_TYPE, METHOD) { \
638 static GA_Size tsize(const CLASS *o) { return o->METHOD().entries(); } \
639 static GA_Size eval(const CLASS *o, fpreal64 *v, GA_Size size) \
641 const ARRAY_TYPE &array = o->METHOD(); \
642 size = SYSmin(size, array.entries()); \
643 for (exint i = 0; i < size; ++i) { v[i] = array(i); } \
647 GA_INTRINSIC_DEF_VARYING_F(ID, NAME, callbacks::tsize) \
648 myEval[ID].myF = callbacks::eval; \
650 #define GA_INTRINSIC_VARYING_F(CLASS, ID, NAME, TSIZE, EVAL) { \
651 GA_INTRINSIC_DEF_VARYING_F(ID, NAME, TSIZE) \
652 myEval[ID].myF = EVAL; \
655 #define GA_INTRINSIC_SET_F(CLASS, ID, SETFUNC) { \
657 static GA_Size setFunc(CLASS *o, const fpreal64 *v, GA_Size sz) \
658 { SETFUNC(o, v[0]); return 1; } \
660 myEval[ID].mySetF = callbacks::setFunc; \
661 myEval[ID].myReadOnly = false; \
663 #define GA_INTRINSIC_SET_METHOD_F(CLASS, ID, METHOD) { \
665 static GA_Size setFunc(CLASS *o, const fpreal64 *v, GA_Size sz) \
666 { o->METHOD(v[0]); return 1; } \
668 myEval[ID].mySetF = callbacks::setFunc; \
669 myEval[ID].myReadOnly = false; \
671 #define GA_INTRINSIC_SET_TUPLE_F(CLASS, ID, SETFUNC) { \
673 static GA_Size setFunc(CLASS *o, const fpreal64 *v, GA_Size sz) \
674 { return SETFUNC(o, v, sz); } \
676 myEval[ID].mySetF = callbacks::setFunc; \
677 myEval[ID].myReadOnly = false; \
679 #define GA_INTRINSIC_SET_TUPLE_METHOD_F(CLASS, ID, METHOD) { \
681 static GA_Size setFunc(CLASS *o, const fpreal64 *v, GA_Size sz) \
682 { return o->METHOD(v[0], sz); } \
684 myEval[ID].mySetF = callbacks::setFunc; \
685 myEval[ID].myReadOnly = false; \
689 #define GA_INTRINSIC_DEF_S(ID, NAME, TUPLESIZE) \
690 GA_INTRINSIC_DEF(ID, NAME, TUPLESIZE, GA_STORECLASS_STRING)
692 #define GA_INTRINSIC_DEF_VARYING_S(ID, NAME, TUPLESIZE_FUNC) \
693 GA_INTRINSIC_DEF_VARYING(ID, NAME, TUPLESIZE_FUNC, GA_STORECLASS_STRING)
695 #define GA_INTRINSIC_S(CLASS, ID, NAME, EVAL) { \
697 static GA_Size evalS(const CLASS *o, UT_String &v) \
698 { v = EVAL(o); return 1; } \
699 static GA_Size evalSA(const CLASS *o, UT_StringArray &v) \
700 { v.append(EVAL(o)); return 1; } \
702 GA_INTRINSIC_DEF_S(ID, NAME, 1) \
703 myEval[ID].myS = callbacks::evalS; \
704 myEval[ID].mySA = callbacks::evalSA; \
706 #define GA_INTRINSIC_CONST_S(CLASS, ID, NAME, VALUE) { \
708 static GA_Size evalS(const CLASS *, UT_String &v) \
709 { v = VALUE; return 1; } \
710 static GA_Size evalSA(const CLASS *, UT_StringArray &v) \
711 { v.append(VALUE); return 1; } \
713 GA_INTRINSIC_DEF_S(ID, NAME, 1) \
714 myEval[ID].myS = callbacks::evalS; \
715 myEval[ID].mySA = callbacks::evalSA; \
717 #define GA_INTRINSIC_METHOD_S(CLASS, ID, NAME, METHOD) { \
719 static GA_Size evalS(const CLASS *o, UT_String &v) \
720 { v = o->METHOD(); return 1; } \
721 static GA_Size evalSA(const CLASS *o, UT_StringArray &v) \
722 { v.append(o->METHOD()); return 1; } \
724 GA_INTRINSIC_DEF_S(ID, NAME, 1) \
725 myEval[ID].myS = callbacks::evalS; \
726 myEval[ID].mySA = callbacks::evalSA; \
728 #define GA_INTRINSIC_TUPLE_S(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
729 GA_INTRINSIC_DEF_S(ID, NAME, TUPLESIZE) \
730 myEval[ID].mySA = EVAL; \
732 #define GA_INTRINSIC_TUPLE_METHOD_S(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
734 static GA_Size evalSA(const CLASS *o, UT_StringArray &v) \
735 { o->EVAL(v); return v.entries(); } \
737 GA_INTRINSIC_DEF_S(ID, NAME, TUPLESIZE) \
738 myEval[ID].mySA = callbacks::eval; \
740 #define GA_INTRINSIC_ARRAY_S(CLASS, ID, NAME, ARRAY_TYPE, METHOD) { \
742 static GA_Size tsize(const CLASS *o) { return o->METHOD().entries(); } \
743 static GA_Size eval(const CLASS *o, UT_StringArray &v) \
745 const ARRAY_TYPE &array = o->METHOD(); \
746 for (exint i = 0; i < size; ++i) { v[i].append(array(i)); } \
747 return v.entries(); \
750 GA_INTRINSIC_DEF_VARYING_S(ID, NAME, callbacks::tsize) \
751 myEval[ID].mySA = callbacks::eval; \
753 #define GA_INTRINSIC_VARYING_S(CLASS, ID, NAME, TSIZE, EVAL) { \
754 GA_INTRINSIC_DEF_VARYING_S(ID, NAME, TSIZE) \
755 myEval[ID].mySA = EVAL; \
758 #define GA_INTRINSIC_SET_S(CLASS, ID, SETFUNC) { \
760 static GA_Size setSS(CLASS *o, const char **v, GA_Size sz) \
761 { return SETFUNC(o, v[0]) ? 1 : 0; } \
762 static GA_Size setSA(CLASS *o, const UT_StringArray &a) \
763 { return SETFUNC(o, a(0)) ? 1 : 0; } \
765 myEval[ID].mySetSS = callbacks::setSS; \
766 myEval[ID].mySetSA = callbacks::setSA; \
767 myEval[ID].myReadOnly = false; \
769 #define GA_INTRINSIC_SET_METHOD_S(CLASS, ID, METHOD) { \
771 static GA_Size setSS(CLASS *o, const char **v, GA_Size) \
772 { return o->METHOD(v[0]) ? 1 : 0; } \
773 static GA_Size setSA(CLASS *o, const UT_StringArray &a) \
774 { return o->METHOD(a(0)) ? 1 : 0; } \
776 myEval[ID].mySetSS = callbacks::setSS; \
777 myEval[ID].mySetSA = callbacks::setSA; \
778 myEval[ID].myReadOnly = false; \
780 #define GA_INTRINSIC_SET_TUPLE_S(CLASS, ID, SETFUNC) { \
782 static GA_Size setSA(CLASS *o, const UT_StringArray &a) \
783 { return SETFUNC(o, a); } \
784 static GA_Size setSS(CLASS *o, const char **v, GA_Size sz) \
786 UT_StringArray array; \
788 for (exint i = 0; i < sz; ++i) array(i) = v[i]; \
789 return SETFUNC(o, array); \
792 myEval[ID].mySetSS = callbacks::setSS; \
793 myEval[ID].mySetSA = callbacks::setSA; \
794 myEval[ID].myReadOnly = false; \
796 #define GA_INTRINSIC_SET_TUPLE_METHOD_S(CLASS, ID, METHOD) { \
798 static GA_Size setSA(CLASS *o, const UT_StringArray &a) \
799 { return o->METHOD(a); } \
800 static GA_Size setSS(CLASS *o, const char **v, GA_Size sz) \
802 UT_StringArray array; \
804 for (exint i = 0; i < sz; ++i) array(i) = v[i]; \
805 return o->METHOD(array); \
808 myEval[ID].mySetSS = callbacks::setSS; \
809 myEval[ID].mySetSA = callbacks::setSA; \
810 myEval[ID].myReadOnly = false; \
814 #define GA_INTRINSIC_DEF_D(ID, NAME, TUPLESIZE) \
815 GA_INTRINSIC_DEF(ID, NAME, TUPLESIZE, GA_STORECLASS_DICT)
817 #define GA_INTRINSIC_DEF_VARYING_D(ID, NAME, TUPLESIZE_FUNC) \
818 GA_INTRINSIC_DEF_VARYING(ID, NAME, TUPLESIZE_FUNC, GA_STORECLASS_DICT)
820 #define GA_INTRINSIC_D(CLASS, ID, NAME, EVAL) { \
822 static GA_Size evalD(const CLASS *o, UT_OptionsHolder &v) \
823 { v = EVAL(o); return 1; } \
824 static GA_Size evalDA(const CLASS *o, UT_Array<UT_OptionsHolder> &v) \
825 { v.append(EVAL(o)); return 1; } \
827 GA_INTRINSIC_DEF_D(ID, NAME, 1) \
828 myEval[ID].myD = callbacks::evalD; \
829 myEval[ID].myDA = callbacks::evalDA; \
831 #define GA_INTRINSIC_CONST_D(CLASS, ID, NAME, VALUE) { \
833 static GA_Size evalD(const CLASS *, UT_OptionsHolder &v) \
834 { v = VALUE; return 1; } \
835 static GA_Size evalDA(const CLASS *, UT_Array<UT_OptionsHolder> &v) \
836 { v.append(VALUE); return 1; } \
838 GA_INTRINSIC_DEF_D(ID, NAME, 1) \
839 myEval[ID].myD = callbacks::evalD; \
840 myEval[ID].myDA = callbacks::evalDA; \
842 #define GA_INTRINSIC_METHOD_D(CLASS, ID, NAME, METHOD) { \
844 static GA_Size evalD(const CLASS *o, UT_OptionsHolder &v) \
845 { v = o->METHOD(); return 1; } \
846 static GA_Size evalDA(const CLASS *o, UT_Array<UT_OptionsHolder> &v) \
847 { v.append(o->METHOD()); return 1; } \
849 GA_INTRINSIC_DEF_D(ID, NAME, 1) \
850 myEval[ID].myD = callbacks::evalD; \
851 myEval[ID].myDA = callbacks::evalDA; \
853 #define GA_INTRINSIC_TUPLE_D(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
854 GA_INTRINSIC_DEF_D(ID, NAME, TUPLESIZE) \
855 myEval[ID].myDA = EVAL; \
857 #define GA_INTRINSIC_TUPLE_METHOD_D(CLASS, ID, NAME, TUPLESIZE, EVAL) { \
859 static GA_Size evalDA(const CLASS *o, UT_Array<UT_OptionsHolder> &v) \
860 { o->EVAL(v); return v.entries(); } \
862 GA_INTRINSIC_DEF_D(ID, NAME, TUPLESIZE) \
863 myEval[ID].myDA = callbacks::eval; \
865 #define GA_INTRINSIC_ARRAY_D(CLASS, ID, NAME, ARRAY_TYPE, METHOD) { \
867 static GA_Size tsize(const CLASS *o) { return o->METHOD().entries(); } \
868 static GA_Size eval(const CLASS *o, UT_Array<UT_OptionsHolder> &v) \
870 const ARRAY_TYPE &array = o->METHOD(); \
871 for (exint i = 0; i < size; ++i) { v[i].append(array(i)); } \
872 return v.entries(); \
875 GA_INTRINSIC_DEF_VARYING_D(ID, NAME, callbacks::tsize) \
876 myEval[ID].myDA = callbacks::eval; \
878 #define GA_INTRINSIC_VARYING_D(CLASS, ID, NAME, TSIZE, EVAL) { \
879 GA_INTRINSIC_DEF_VARYING_D(ID, NAME, TSIZE) \
880 myEval[ID].myDA = EVAL; \
883 #define GA_INTRINSIC_SET_D(CLASS, ID, SETFUNC) { \
885 static GA_Size setDS(CLASS *o, const UT_OptionsHolder *v, GA_Size sz) \
886 { return SETFUNC(o, v[0]) ? 1 : 0; } \
887 static GA_Size setDA(CLASS *o, const UT_Array<UT_OptionsHolder> &a) \
888 { return SETFUNC(o, a(0)) ? 1 : 0; } \
890 myEval[ID].mySetDS = callbacks::setDS; \
891 myEval[ID].mySetDA = callbacks::setDA; \
892 myEval[ID].myReadOnly = false; \
894 #define GA_INTRINSIC_SET_METHOD_D(CLASS, ID, METHOD) { \
896 static GA_Size setDS(CLASS *o, const UT_OptionsHolder *v, GA_Size) \
897 { return o->METHOD(v[0]) ? 1 : 0; } \
898 static GA_Size setDA(CLASS *o, const UT_Array<UT_OptionsHolder> &a) \
899 { return o->METHOD(a(0)) ? 1 : 0; } \
901 myEval[ID].mySetDS = callbacks::setDS; \
902 myEval[ID].mySetDA = callbacks::setDA; \
903 myEval[ID].myReadOnly = false; \
905 #define GA_INTRINSIC_SET_TUPLE_D(CLASS, ID, SETFUNC) { \
907 static GA_Size setDA(CLASS *o, const UT_Array<UT_OptionsHolder> &a) \
908 { return SETFUNC(o, a); } \
909 static GA_Size setDS(CLASS *o, const UT_OptionsHolder *v, GA_Size sz) \
911 UT_Array<UT_OptionsHolder> array; \
913 for (exint i = 0; i < sz; ++i) array(i) = v[i]; \
914 return SETFUNC(o, array); \
917 myEval[ID].mySetDS = callbacks::setDS; \
918 myEval[ID].mySetDA = callbacks::setDA; \
919 myEval[ID].myReadOnly = false; \
921 #define GA_INTRINSIC_SET_TUPLE_METHOD_D(CLASS, ID, METHOD) { \
923 static GA_Size setDA(CLASS *o, const UT_Array<UT_OptionsHolder> &a) \
924 { return o->METHOD(a); } \
925 static GA_Size setDS(CLASS *o, const UT_OptionsHolder *v, GA_Size sz) \
927 UT_Array<UT_OptionsHolder> array; \
929 for (exint i = 0; i < sz; ++i) array(i) = v[i]; \
930 return o->METHOD(array); \
933 myEval[ID].mySetDS = callbacks::setDS; \
934 myEval[ID].mySetDA = callbacks::setDA; \
935 myEval[ID].myReadOnly = false; \