HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Defines.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  * COMMENTS:
7  */
8 
9 #ifndef __HOM_Defines_h__
10 #define __HOM_Defines_h__
11 
12 #include <UT/UT_Assert.h>
13 
14 // Unfortunately, we can't compare against UT_ASSERT_LEVEL_PARANOID here,
15 // otherwise the comparison sometimes succeeds under swig when it shouldn't.
16 // So, we instead compare against the numeric value itself.
17 #if UT_ASSERT_LEVEL >= 2
18 #define HOM_DEBUG
19 #endif
20 
21 #ifdef SWIG
22 #define SWIGOUT(x) x
23 #else
24 #define SWIGOUT(x)
25 #endif
26 
27 #if defined(SWIG) && defined(SWIGPYTHON)
28 #define SWIGPYTHONOUT(x) x
29 #else
30 #define SWIGPYTHONOUT(x)
31 #endif
32 
33 // Define a synonym for hboost::any to customize a typemap for arguments that
34 // are to hold values to be inserted into a UT_Options object. SWIG allows
35 // typemaps to be defined for each typename independently.
36 #include <hboost/any.hpp>
38 
39 // Define a synonym for hboost::any to customize a typemap for arguments that
40 // are to return drag-n-drop source data. SWIG allows typemaps to be defined
41 // for each typename independently.
43 
44 #include <UT/UT_Optional.h>
47 
48 // The following define should go in SYS_Math.h when we are ready to
49 // add equivalent defines for MAX_DOUBLE, MAX_INT, MIN_INT etc.
50 #define HOM_MIN_NEGATIVE_DOUBLE -1 * std::numeric_limits<double>::max()
51 
52 #ifdef SWIG
53 
54 //----------------------------------------------------------------------------
55 
56 // Since there's no way for a C++ function to have varying return types,
57 // we need to add special methods and functions that are only known
58 // to swig. For python, there's a typemap for PyObject* so that when
59 // swig encounters a function returning that type it won't try to wrap
60 // the return value, and will instead send it directly to the interpreter.
61 // We create a typemap for this type so our code can use it instead of
62 // PyObject* directly so it's easier to use more than just python in the
63 // future.
64 
65 // The swig code we output directly to the swig wrapper below (using %{%})
66 // uses InterpreterObject, so we need to say what it is.
67 %{
68 #ifdef SWIGPYTHON
69 typedef PyObject *InterpreterObject;
70 
71 PyObject *HOMincRef(PyObject *object)
72 {
73  if (!object)
74  object = Py_None;
75  Py_INCREF(object);
76  return object;
77 }
78 #endif
79 %}
80 
81 // We need to tell swig what InterpreterObject is so it applies the PyObject*
82 // typemap properly.
83 typedef PyObject *InterpreterObject;
84 
85 //----------------------------------------------------------------------------
86 
87 %{
88 
89 #include <UT/UT_StdUtil.h>
90 #include <HOM/HOM_ErrorUtil.h>
91 
92 // These helper functions convert from C++ objects to corresponding
93 // interpreter objects (PyObject*'s in python). They're roughly the same
94 // as swig::from(), but swig::from() does a slow lookup on the name of the
95 // type. These functions know the type at compile-time so they're faster.
96 // Unfortunately, we need to explicitly specialize all the types supported by
97 // the functions. Specifically, since HOM_IterableList calls these functions,
98 // objects that can be inside HOM_IterableList need to be specialized below.
99 
100 // The general case is left unimplemented so we get compiler errors if
101 // we call the function with an unspecialized type.
102 template <typename T> InterpreterObject
103 HOMconvertValueForInterpreter(const T &value, int own);
104 
105 // These functions specialize the native data types.
106 template <> InterpreterObject
107 HOMconvertValueForInterpreter<int>(const int& value, int /*own*/)
108 { return SWIG_From_int(value); }
109 
110 template <> InterpreterObject
111 HOMconvertValueForInterpreter<float>(const float& value, int /*own*/)
112 { return SWIG_From_float(value); }
113 
114 template <> InterpreterObject
115 HOMconvertValueForInterpreter<double>(const double& value, int /*own*/)
116 { return SWIG_From_double(value); }
117 
118 template <> InterpreterObject
119 HOMconvertValueForInterpreter<std::string>(
120  const std::string& value, int /*own*/)
121 { return SWIG_From_std_string(value); }
122 
123 // These functions specialize base classes to return interpreter instances
124 // of the proper subclass.
125 template <> InterpreterObject
126 HOMconvertValueForInterpreter<HOM_Node*>(HOM_Node *const &node, int own)
127 {
128  OP_OpTypeId optypeid;
129  HOM_NodeType *nodetype = nullptr;
130  HOM_OpNode *opnode = dynamic_cast<HOM_OpNode* const>(node);
131  HOM_ApexNode *apexnode = dynamic_cast<HOM_ApexNode* const>(node);
132  bool isnetwork = false;
133 
134  if (!node || (!opnode && !apexnode))
135  return SWIG_NewPointerObj(node, SWIGTYPE_p_HOM_Node, own);
136 
137  if (apexnode)
138  return SWIG_NewPointerObj(node, SWIGTYPE_p_HOM_ApexNode, own);
139 
140  optypeid = (OP_OpTypeId)opnode->opTypeIdAsInt();
141  switch (optypeid)
142  {
143  case OBJ_OPTYPE_ID:
144  // Because of multiple inheritance, it's extremely important that
145  // we explicitly cast the pointer to a HOM_ObjNode so we
146  // pass the right address to SWIG_NewPointerObject, since it takes
147  // a void*.
148  return SWIG_NewPointerObj(
149  (void*)dynamic_cast<HOM_ObjNode* const>(node),
150  SWIGTYPE_p_HOM_ObjNode, own);
151 
152  case SOP_OPTYPE_ID:
153  // Because of multiple inheritance, it's extremely important that
154  // we explicitly cast the pointer to a HOM_SopNode so we
155  // pass the right address to SWIG_NewPointerObject, since it takes
156  // a void*.
157  return SWIG_NewPointerObj(
158  (void*)dynamic_cast<HOM_SopNode* const>(node),
159  SWIGTYPE_p_HOM_SopNode, own);
160 
161  case CHOP_OPTYPE_ID:
162  // Because of multiple inheritance, it's extremely important that
163  // we explicitly cast the pointer to a HOM_ChopNode so we
164  // pass the right address to SWIG_NewPointerObject, since it takes
165  // a void*.
166  return SWIG_NewPointerObj(
167  (void*)dynamic_cast<HOM_ChopNode* const>(node),
168  SWIGTYPE_p_HOM_ChopNode, own);
169 
170  case COP2_OPTYPE_ID:
171  // Because of multiple inheritance, it's extremely important that
172  // we explicitly cast the pointer to a HOM_Cop2Node so we
173  // pass the right address to SWIG_NewPointerObject, since it takes
174  // a void*.
175  return SWIG_NewPointerObj(
176  (void*)dynamic_cast<HOM_Cop2Node* const>(node),
177  SWIGTYPE_p_HOM_Cop2Node, own);
178 
179  case COP_OPTYPE_ID:
180  // Because of multiple inheritance, it's extremely important that
181  // we explicitly cast the pointer to a HOM_CopNode so we
182  // pass the right address to SWIG_NewPointerObject, since it takes
183  // a void*.
184  return SWIG_NewPointerObj(
185  (void*)dynamic_cast<HOM_CopNode* const>(node),
186  SWIGTYPE_p_HOM_CopNode, own);
187 
188  case DOP_OPTYPE_ID:
189  // Because of multiple inheritance, it's extremely important that
190  // we explicitly cast the pointer to a HOM_DopNode so we
191  // pass the right address to SWIG_NewPointerObject, since it takes
192  // a void*.
193  return SWIG_NewPointerObj(
194  (void*)dynamic_cast<HOM_DopNode* const>(node),
195  SWIGTYPE_p_HOM_DopNode, own);
196 
197  case SHOP_OPTYPE_ID:
198  // Because of multiple inheritance, it's extremely important that
199  // we explicitly cast the pointer to a HOM_ShopNode so we
200  // pass the right address to SWIG_NewPointerObject, since it takes
201  // a void*.
202  return SWIG_NewPointerObj(
203  (void*)dynamic_cast<HOM_ShopNode* const>(node),
204  SWIGTYPE_p_HOM_ShopNode, own);
205 
206  case VOPNET_OPTYPE_ID:
207  // Because of multiple inheritance, it's extremely important that
208  // we explicitly cast the pointer to a HOM_VopNetNode so we
209  // pass the right address to SWIG_NewPointerObject, since it takes
210  // a void*.
211  return SWIG_NewPointerObj(
212  (void*)dynamic_cast<HOM_VopNetNode* const>(node),
213  SWIGTYPE_p_HOM_VopNetNode, own);
214 
215  case ROP_OPTYPE_ID:
216  // Because of multiple inheritance, it's extremely important that
217  // we explicitly cast the pointer to a HOM_RopNode so we
218  // pass the right address to SWIG_NewPointerObject, since it takes
219  // a void*.
220  return SWIG_NewPointerObj(
221  (void*)dynamic_cast<HOM_RopNode* const>(node),
222  SWIGTYPE_p_HOM_RopNode, own);
223 
224  case VOP_OPTYPE_ID:
225  // Because of multiple inheritance, it's extremely important that
226  // we explicitly cast the pointer to a HOM_VopNode so we
227  // pass the right address to SWIG_NewPointerObject, since it takes
228  // a void*.
229  return SWIG_NewPointerObj(
230  (void*)dynamic_cast<HOM_VopNode* const>(node),
231  SWIGTYPE_p_HOM_VopNode, own);
232 
233  case TOP_OPTYPE_ID:
234  // Because of multiple inheritance, it's extremely important that
235  // we explicitly cast the pointer to a HOM_TopNode so we
236  // pass the right address to SWIG_NewPointerObject, since it takes
237  // a void*.
238  return SWIG_NewPointerObj(
239  (void*)dynamic_cast<HOM_TopNode* const>(node),
240  SWIGTYPE_p_HOM_TopNode, own);
241 
242  case LOP_OPTYPE_ID:
243  // Because of multiple inheritance, it's extremely important that
244  // we explicitly cast the pointer to a HOM_LopNode so we
245  // pass the right address to SWIG_NewPointerObject, since it takes
246  // a void*.
247  //
248  // Special test for LOP Network management nodes, since LOP_Networks
249  // have their own HOM data type.
250  nodetype = node->type();
251  isnetwork = (nodetype && nodetype->isManager(true));
252  delete nodetype;
253  if (isnetwork)
254  return SWIG_NewPointerObj(
255  (void*)dynamic_cast<HOM_LopNetwork* const>(node),
256  SWIGTYPE_p_HOM_LopNetwork, own);
257  else
258  return SWIG_NewPointerObj(
259  (void*)dynamic_cast<HOM_LopNode* const>(node),
260  SWIGTYPE_p_HOM_LopNode, own);
261 
262  case DATA_OPTYPE_ID:
263  // Data operator types have no subclass so fall through to the
264  // generic HOM_Node.
265  break;
266 
267  case MGR_OPTYPE_ID:
268  // Special case for the /stage manager node, which is actually a
269  // LOP_Network, and therefore a LOP_Node.
270  if (HOM().lopNodeTypeCategory() == node->childTypeCategory())
271  return SWIG_NewPointerObj(
272  (void*)dynamic_cast<HOM_LopNetwork* const>(node),
273  SWIGTYPE_p_HOM_LopNetwork, own);
274 
275  default:
276  break;
277  };
278 
279  return SWIG_NewPointerObj(opnode, SWIGTYPE_p_HOM_OpNode, own);
280 }
281 
282 template <> InterpreterObject
283 HOMconvertValueForInterpreter<HOM_NodeType*>(
284  HOM_NodeType *const &nodetype, int own)
285 {
286  OP_OpTypeId optypeid;
287  HOM_OpNodeType *opnodetype = dynamic_cast<HOM_OpNodeType* const>(nodetype);
288  HOM_ApexNodeType*apexnodetype = dynamic_cast<HOM_ApexNodeType* const>(nodetype);
289 
290  if (!nodetype || (!opnodetype && !apexnodetype))
291  return SWIG_NewPointerObj(nodetype, SWIGTYPE_p_HOM_NodeType, own);
292 
293  if (apexnodetype)
294  return SWIG_NewPointerObj(nodetype, SWIGTYPE_p_HOM_ApexNodeType, own);
295 
296  if( !nodetype->isManager() )
297  {
298  optypeid = (OP_OpTypeId)opnodetype->opTypeIdAsInt();
299  switch (optypeid)
300  {
301  case SOP_OPTYPE_ID:
302  // Because of multiple inheritance, it's extremely important that
303  // we explicitly cast the pointer to a HOM_SopNodeType so we
304  // pass the right address to SWIG_NewPointerObject, since it takes
305  // a void*.
306  return SWIG_NewPointerObj(
307  (void*)dynamic_cast<const HOM_SopNodeType* const>(nodetype),
308  SWIGTYPE_p_HOM_SopNodeType, own);
309 
310  case SHOP_OPTYPE_ID:
311  // Because of multiple inheritance, it's extremely important that
312  // we explicitly cast the pointer to a HOM_ShopNodeType so we
313  // pass the right address to SWIG_NewPointerObject, since it takes
314  // a void*.
315  return SWIG_NewPointerObj(
316  (void*)dynamic_cast<const HOM_ShopNodeType* const>(nodetype),
317  SWIGTYPE_p_HOM_ShopNodeType, own);
318 
319  case VOP_OPTYPE_ID:
320  // Because of multiple inheritance, it's extremely important that
321  // we explicitly cast the pointer to a HOM_VopNodeType so we
322  // pass the right address to SWIG_NewPointerObject, since it takes
323  // a void*.
324  return SWIG_NewPointerObj(
325  (void*)dynamic_cast<const HOM_VopNodeType* const>(nodetype),
326  SWIGTYPE_p_HOM_VopNodeType, own);
327  default:
328  break;
329  }
330  }
331 
332  return SWIG_NewPointerObj(nodetype, SWIGTYPE_p_HOM_OpNodeType, own);
333 }
334 
335 template <> InterpreterObject
336 HOMconvertValueForInterpreter<HOM_NodeTypeCategory*>(
337  HOM_NodeTypeCategory *const &nodetypecategory, int own)
338 {
339  HOM_OpNodeTypeCategory *opnodetypecategory =
340  dynamic_cast<HOM_OpNodeTypeCategory* const>(nodetypecategory);
341  HOM_ApexNodeTypeCategory *apexnodetypecategory =
342  dynamic_cast<HOM_ApexNodeTypeCategory* const>(nodetypecategory);
343 
344  if (!nodetypecategory || (!opnodetypecategory && !apexnodetypecategory))
345  return SWIG_NewPointerObj(nodetypecategory,
346  SWIGTYPE_p_HOM_NodeTypeCategory, own);
347 
348  if (apexnodetypecategory)
349  return SWIG_NewPointerObj(nodetypecategory,
350  SWIGTYPE_p_HOM_ApexNodeTypeCategory, own);
351 
352  return SWIG_NewPointerObj(nodetypecategory,
353  SWIGTYPE_p_HOM_OpNodeTypeCategory, own);
354 }
355 
356 template <> InterpreterObject
357 HOMconvertValueForInterpreter<HOM_NodeTypeCategory&>(
358  HOM_NodeTypeCategory &nodetypecategory, int own)
359 {
360  HOM_OpNodeTypeCategory *opnodetypecategory =
361  dynamic_cast<HOM_OpNodeTypeCategory* const>(&nodetypecategory);
362  HOM_ApexNodeTypeCategory *apexnodetypecategory =
363  dynamic_cast<HOM_ApexNodeTypeCategory* const>(&nodetypecategory);
364 
365  if (!opnodetypecategory && !apexnodetypecategory)
366  return SWIG_NewPointerObj(&nodetypecategory,
367  SWIGTYPE_p_HOM_NodeTypeCategory, own);
368 
369  if (apexnodetypecategory)
370  return SWIG_NewPointerObj(&nodetypecategory,
371  SWIGTYPE_p_HOM_ApexNodeTypeCategory, own);
372 
373  return SWIG_NewPointerObj(&nodetypecategory,
374  SWIGTYPE_p_HOM_OpNodeTypeCategory, own);
375 }
376 
377 namespace swig {
378  template <>
379  struct traits_from<HOM_NodeTypeCategory *>
380  {
381  static PyObject *from(HOM_NodeTypeCategory * const &val)
382  {
383  // Guard exceptions here that are normally for python. This is
384  // similar to what we do with HOM_CONVERT_AND_CATCH code below
385  PyObject *result;
386  try
387  {
388  // HOM_NodeTypeCategory objects are always singletons, not
389  // owned by python/SWIG.
390  result = HOMconvertValueForInterpreter(val, 0);
391  }
392  catch (...)
393  {
394  // Unlike HOM_CONVERT_AND_CATCH, we can't raise a SWIG exception
395  // here because it will be ignored anyways in the list
396  // conversion code. Plus, we'll also run into an assertion
397  // failure inside the Python interpreter if we do this:
398  // (void)hom::raise_swig_exception();
399  result = Py_None;
400  }
401  return result;
402  }
403  };
404 }
405 
406 template <> InterpreterObject
407 HOMconvertValueForInterpreter<HOM_NetworkBox*>(
408  HOM_NetworkBox *const &obj, int own)
409 {
410  HOM_OpNetworkBox *opobj = dynamic_cast<HOM_OpNetworkBox* const>(obj);
411 
412  if (!obj || !opobj)
413  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_NetworkBox, own);
414 
415  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_OpNetworkBox, own);
416 }
417 
418 template <> InterpreterObject
419 HOMconvertValueForInterpreter<HOM_NetworkDot*>(
420  HOM_NetworkDot *const &obj, int own)
421 {
422  HOM_OpNetworkDot *opobj = dynamic_cast<HOM_OpNetworkDot* const>(obj);
423 
424  if (!obj || !opobj)
425  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_NetworkDot, own);
426 
427  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_OpNetworkDot, own);
428 }
429 
430 template <> InterpreterObject
431 HOMconvertValueForInterpreter<HOM_NodeConnection*>(
432  HOM_NodeConnection *const &obj, int own)
433 {
434  HOM_OpNodeConnection *opobj = dynamic_cast<HOM_OpNodeConnection* const>(obj);
435  HOM_ApexNodeConnection *apexobj = dynamic_cast<HOM_ApexNodeConnection* const>(obj);
436 
437  if (!obj || (!opobj && !apexobj))
438  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_NodeConnection, own);
439 
440  if (apexobj)
441  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_ApexNodeConnection, own);
442 
443  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_OpNodeConnection, own);
444 }
445 
446 template <> InterpreterObject
447 HOMconvertValueForInterpreter<HOM_StickyNote*>(
448  HOM_StickyNote *const &obj, int own)
449 {
450  HOM_OpStickyNote *opobj = dynamic_cast<HOM_OpStickyNote* const>(obj);
451  HOM_ApexStickyNote *apexobj = dynamic_cast<HOM_ApexStickyNote* const>(obj);
452 
453  if (!obj || (!opobj && !apexobj))
454  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_StickyNote, own);
455 
456  if (apexobj)
457  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_ApexStickyNote, own);
458 
459  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_OpStickyNote, own);
460 }
461 
462 template <> InterpreterObject
463 HOMconvertValueForInterpreter<HOM_SubnetIndirectInput*>(
464  HOM_SubnetIndirectInput *const &obj, int own)
465 {
466  HOM_OpSubnetIndirectInput *opobj = dynamic_cast<HOM_OpSubnetIndirectInput* const>(obj);
467 
468  if (!obj || !opobj)
469  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_SubnetIndirectInput, own);
470 
471  return SWIG_NewPointerObj(obj, SWIGTYPE_p_HOM_OpSubnetIndirectInput, own);
472 }
473 
474 template <> InterpreterObject
475 HOMconvertValueForInterpreter<HOM_BaseKeyframe*>(
476  HOM_BaseKeyframe *const &keyframe, int own)
477 {
478  if (!keyframe)
479  return SWIG_NewPointerObj(keyframe, SWIGTYPE_p_HOM_BaseKeyframe, own);
480 
481  if (keyframe->evaluatedType() == HOM_parmData::Float)
482  {
483  // Because of multiple inheritance, it's extremely important that
484  // we explicitly cast the pointer to a HOM_Keyframe so we
485  // pass the right address to SWIG_NewPointerObject, since it takes
486  // a void*.
487  return SWIG_NewPointerObj(
488  (void*)dynamic_cast<const HOM_Keyframe* const>(keyframe),
489  SWIGTYPE_p_HOM_Keyframe, own);
490  }
491  else if (keyframe->evaluatedType() == HOM_parmData::String)
492  {
493  // Because of multiple inheritance, it's extremely important that
494  // we explicitly cast the pointer to a HOM_Keyframe so we
495  // pass the right address to SWIG_NewPointerObject, since it takes
496  // a void*.
497  return SWIG_NewPointerObj(
498  (void*)dynamic_cast<const HOM_StringKeyframe* const>(keyframe),
499  SWIGTYPE_p_HOM_StringKeyframe, own);
500  }
501 
502  return SWIG_NewPointerObj(keyframe, SWIGTYPE_p_HOM_BaseKeyframe, own);
503 }
504 
505 template <> InterpreterObject
506 HOMconvertValueForInterpreter<HOM_PackedPrim*>(HOM_PackedPrim *const &prim, int own)
507 {
508  if (!prim)
509  return SWIG_NewPointerObj(prim, SWIGTYPE_p_HOM_PackedPrim, own);
510 
511  // Because of multiple inheritance, it's extremely important that
512  // we explicitly cast the pointer to the right HOM type so we
513  // pass the right address to SWIG_NewPointerObject, since it takes
514  // a void*.
515 
516  switch (prim->type().id())
517  {
518  case HOM_primType::Agent_Id:
519  return SWIG_NewPointerObj(
520  (void *)dynamic_cast<HOM_Agent *const>(prim),
521  SWIGTYPE_p_HOM_Agent, own);
522 
523  case HOM_primType::PackedFragment_Id:
524  return SWIG_NewPointerObj(
525  (void *)dynamic_cast<HOM_PackedFragment *const>(prim),
526  SWIGTYPE_p_HOM_PackedFragment, own);
527 
528  case HOM_primType::PackedGeometry_Id:
529  return SWIG_NewPointerObj(
530  (void *)dynamic_cast<HOM_PackedGeometry *const>(prim),
531  SWIGTYPE_p_HOM_PackedGeometry, own);
532  }
533 
534  // NOTE: No dynamic_cast needed here
535  return SWIG_NewPointerObj((void *)prim, SWIGTYPE_p_HOM_PackedPrim, own);
536 }
537 
538 template <> InterpreterObject
539 HOMconvertValueForInterpreter<HOM_Prim*>(HOM_Prim *const &prim, int own)
540 {
541  if (!prim)
542  return SWIG_NewPointerObj(prim, SWIGTYPE_p_HOM_Prim, own);
543 
544  // Because of multiple inheritance, it's extremely important that
545  // we explicitly cast the pointer to the right HOM type so we
546  // pass the right address to SWIG_NewPointerObject, since it takes
547  // a void*.
548  HOM_PackedPrim * packed = dynamic_cast<HOM_PackedPrim *>(prim);
549  if(packed)
550  return HOMconvertValueForInterpreter(packed, own);
551 
552  switch (prim->type().id())
553  {
554  case HOM_primType::Polygon_Id:
555  return SWIG_NewPointerObj(
556  (void*)dynamic_cast<const HOM_Polygon* const>(prim),
557  SWIGTYPE_p_HOM_Polygon, own);
558 
559  case HOM_primType::NURBSCurve_Id:
560  case HOM_primType::BezierCurve_Id:
561  return SWIG_NewPointerObj(
562  (void*)dynamic_cast<const HOM_Face* const>(prim),
563  SWIGTYPE_p_HOM_Face, own);
564 
565  case HOM_primType::Mesh_Id:
566  case HOM_primType::NURBSSurface_Id:
567  case HOM_primType::BezierSurface_Id:
568  return SWIG_NewPointerObj(
569  (void*)dynamic_cast<const HOM_Surface* const>(prim),
570  SWIGTYPE_p_HOM_Surface, own);
571 
572  case HOM_primType::Circle_Id:
573  case HOM_primType::Sphere_Id:
574  case HOM_primType::Tube_Id:
575  return SWIG_NewPointerObj(
576  (void*)dynamic_cast<const HOM_Quadric* const>(prim),
577  SWIGTYPE_p_HOM_Quadric, own);
578 
579  case HOM_primType::Volume_Id:
580  return SWIG_NewPointerObj(
581  (void*)dynamic_cast<const HOM_Volume* const>(prim),
582  SWIGTYPE_p_HOM_Volume, own);
583 
584  case HOM_primType::VDB_Id:
585  return SWIG_NewPointerObj(
586  (void*)dynamic_cast<const HOM_VDB* const>(prim),
587  SWIGTYPE_p_HOM_VDB, own);
588 
589  case HOM_primType::ChannelPrim_Id:
590  return SWIG_NewPointerObj(
591  (void*)dynamic_cast<const HOM_ChannelPrim* const>(prim),
592  SWIGTYPE_p_HOM_ChannelPrim, own);
593 
594  // TODO: Support more primitive types.
595  }
596 
597  return SWIG_NewPointerObj(prim, SWIGTYPE_p_HOM_Prim, own);
598 }
599 
600 template <> InterpreterObject
601 HOMconvertValueForInterpreter<HOM_ParmTemplate*>(
602  HOM_ParmTemplate *const &parm_template, int own)
603 {
604  if (!parm_template)
605  return SWIG_NewPointerObj(
606  parm_template, SWIGTYPE_p_HOM_ParmTemplate, own);
607 
608  // Because of multiple inheritance, it's extremely important that we
609  // explicitly cast to a pointer to the subclass so we pass the right
610  // address to SWIG_NewPointerObject, since it takes a void*.
611  switch (parm_template->type().id())
612  {
613  case HOM_parmTemplateType::Int_Id:
614  return SWIG_NewPointerObj(
615  (void*)dynamic_cast<const HOM_IntParmTemplate* const>(
616  parm_template),
617  SWIGTYPE_p_HOM_IntParmTemplate, own);
618 
619  case HOM_parmTemplateType::Float_Id:
620  return SWIG_NewPointerObj(
621  (void*)dynamic_cast<const HOM_FloatParmTemplate* const>(
622  parm_template),
623  SWIGTYPE_p_HOM_FloatParmTemplate, own);
624 
625  case HOM_parmTemplateType::String_Id:
626  return SWIG_NewPointerObj(
627  (void*)dynamic_cast<const HOM_StringParmTemplate* const>(
628  parm_template),
629  SWIGTYPE_p_HOM_StringParmTemplate, own);
630 
631  case HOM_parmTemplateType::Data_Id:
632  return SWIG_NewPointerObj(
633  (void*)dynamic_cast<const HOM_DataParmTemplate* const>(
634  parm_template),
635  SWIGTYPE_p_HOM_DataParmTemplate, own);
636 
637  case HOM_parmTemplateType::Toggle_Id:
638  return SWIG_NewPointerObj(
639  (void*)dynamic_cast<const HOM_ToggleParmTemplate* const>(
640  parm_template),
641  SWIGTYPE_p_HOM_ToggleParmTemplate, own);
642 
643  case HOM_parmTemplateType::Menu_Id:
644  return SWIG_NewPointerObj(
645  (void*)dynamic_cast<const HOM_MenuParmTemplate* const>(
646  parm_template),
647  SWIGTYPE_p_HOM_MenuParmTemplate, own);
648 
649  case HOM_parmTemplateType::Button_Id:
650  return SWIG_NewPointerObj(
651  (void*)dynamic_cast<const HOM_ButtonParmTemplate* const>(
652  parm_template),
653  SWIGTYPE_p_HOM_ButtonParmTemplate, own);
654 
655  case HOM_parmTemplateType::Label_Id:
656  return SWIG_NewPointerObj(
657  (void*)dynamic_cast<const HOM_LabelParmTemplate* const>(
658  parm_template),
659  SWIGTYPE_p_HOM_LabelParmTemplate, own);
660 
661  case HOM_parmTemplateType::Separator_Id:
662  return SWIG_NewPointerObj(
663  (void*)dynamic_cast<const HOM_SeparatorParmTemplate* const>(
664  parm_template),
665  SWIGTYPE_p_HOM_SeparatorParmTemplate, own);
666 
667  case HOM_parmTemplateType::FolderSet_Id:
668  return SWIG_NewPointerObj(
669  (void*)dynamic_cast<const HOM_FolderSetParmTemplate* const>(
670  parm_template),
671  SWIGTYPE_p_HOM_FolderSetParmTemplate, own);
672 
673  case HOM_parmTemplateType::Folder_Id:
674  return SWIG_NewPointerObj(
675  (void*)dynamic_cast<const HOM_FolderParmTemplate* const>(
676  parm_template),
677  SWIGTYPE_p_HOM_FolderParmTemplate, own);
678 
679  case HOM_parmTemplateType::Ramp_Id:
680  return SWIG_NewPointerObj(
681  (void*)dynamic_cast<const HOM_RampParmTemplate* const>(
682  parm_template),
683  SWIGTYPE_p_HOM_RampParmTemplate, own);
684  };
685 
686  UT_ASSERT(!"Unknown parm template type");
687  return SWIG_NewPointerObj(parm_template, SWIGTYPE_p_HOM_ParmTemplate, own);
688 }
689 
690 template <> InterpreterObject
691 HOMconvertValueForInterpreter<HOM_PaneTab*>(
692  HOM_PaneTab *const &pane_tab, int own)
693 {
694  if (!pane_tab)
695  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
696 
697  // Because of multiple inheritance, it's extremely important that
698  // we explicitly cast the pointer to the HOM type so we pass the right
699  // address to SWIG_NewPointerObject, since it takes a void*.
700 
701  switch (pane_tab->type().id())
702  {
703  case HOM_paneTabType::ContextViewer_Id:
704  return SWIG_NewPointerObj(
705  (void*)dynamic_cast<const HOM_ContextViewer* const>(pane_tab),
706  SWIGTYPE_p_HOM_ContextViewer, own);
707 
708  case HOM_paneTabType::SceneViewer_Id:
709  return SWIG_NewPointerObj(
710  (void*)dynamic_cast<const HOM_SceneViewer* const>(pane_tab),
711  SWIGTYPE_p_HOM_SceneViewer, own);
712 
713  case HOM_paneTabType::CompositorViewer_Id:
714  return SWIG_NewPointerObj(
715  (void*)dynamic_cast<const HOM_CompositorViewer* const>(pane_tab),
716  SWIGTYPE_p_HOM_CompositorViewer, own);
717 
718  case HOM_paneTabType::NetworkEditor_Id:
719  case HOM_paneTabType::ApexEditor_Id:
720  return SWIG_NewPointerObj(
721  (void*)dynamic_cast<const HOM_NetworkEditor* const>(pane_tab),
722  SWIGTYPE_p_HOM_NetworkEditor, own);
723 
724  case HOM_paneTabType::HelpBrowser_Id:
725  return SWIG_NewPointerObj(
726  (void*)dynamic_cast<const HOM_HelpBrowser* const>(pane_tab),
727  SWIGTYPE_p_HOM_HelpBrowser, own);
728 
729  case HOM_paneTabType::PythonPanel_Id:
730  return SWIG_NewPointerObj(
731  (void*)dynamic_cast<const HOM_PythonPanel* const>(pane_tab),
732  SWIGTYPE_p_HOM_PythonPanel, own);
733 
734  case HOM_paneTabType::IPRViewer_Id:
735  return SWIG_NewPointerObj(
736  (void*)dynamic_cast<const HOM_IPRViewer* const>(pane_tab),
737  SWIGTYPE_p_HOM_IPRViewer, own);
738 
739  case HOM_paneTabType::AssetBrowser_Id:
740  return SWIG_NewPointerObj(
741  (void*)dynamic_cast<const HOM_AssetBrowser* const>(pane_tab),
742  SWIGTYPE_p_HOM_AssetBrowser, own);
743 
744  case HOM_paneTabType::PerformanceMonitor_Id:
745  return SWIG_NewPointerObj(
746  (void*)dynamic_cast<const HOM_PerformanceMonitor* const>(pane_tab),
747  SWIGTYPE_p_HOM_PerformanceMonitor, own);
748 
749  case HOM_paneTabType::ChannelEditor_Id:
750  return SWIG_NewPointerObj(
751  (void*)dynamic_cast<const HOM_ChannelEditorPane* const>(pane_tab),
752  SWIGTYPE_p_HOM_ChannelEditorPane, own);
753 
754  case HOM_paneTabType::DataTree_Id:
755  return SWIG_NewPointerObj(
756  (void*)dynamic_cast<const HOM_DataTree* const>(pane_tab),
757  SWIGTYPE_p_HOM_DataTree, own);
758 
759  case HOM_paneTabType::SceneGraphTree_Id:
760  return SWIG_NewPointerObj(
761  (void*)dynamic_cast<const HOM_SceneGraphTree* const>(pane_tab),
762  SWIGTYPE_p_HOM_SceneGraphTree, own);
763 
764  case HOM_paneTabType::Parm_Id:
765  return SWIG_NewPointerObj(
766  (void*)dynamic_cast<const HOM_ParameterEditor* const>(pane_tab),
767  SWIGTYPE_p_HOM_ParameterEditor, own);
768 
769  case HOM_paneTabType::DetailsView_Id:
770  return SWIG_NewPointerObj(
771  (void*)dynamic_cast<const HOM_GeometrySpreadsheet * const>(pane_tab),
772  SWIGTYPE_p_HOM_GeometrySpreadsheet, own);
773 
774  case HOM_paneTabType::RenderGallery_Id:
775  return SWIG_NewPointerObj(
776  (void*)dynamic_cast<const HOM_RenderGallery* const>(pane_tab),
777  SWIGTYPE_p_HOM_RenderGallery, own);
778 
779  case HOM_paneTabType::ChannelViewer_Id:
780  case HOM_paneTabType::OutputViewer_Id:
781  case HOM_paneTabType::ShaderViewer_Id:
782  case HOM_paneTabType::TreeView_Id:
783  return SWIG_NewPointerObj(
784  (void*)dynamic_cast<const HOM_PathBasedPaneTab* const>(pane_tab),
785  SWIGTYPE_p_HOM_PathBasedPaneTab, own);
786 
787  case HOM_paneTabType::ChannelList_Id:
788  case HOM_paneTabType::Textport_Id:
789  case HOM_paneTabType::PythonShell_Id:
790  case HOM_paneTabType::HandleList_Id:
791  case HOM_paneTabType::BundleList_Id:
792  case HOM_paneTabType::TakeList_Id:
793  case HOM_paneTabType::ParmSpreadsheet_Id:
794  case HOM_paneTabType::LightLinker_Id:
795  case HOM_paneTabType::MaterialPalette_Id:
796  case HOM_paneTabType::EngineSessionSync_Id:
797  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
798  };
799 
800  UT_ASSERT(!"Unknown pane tab type");
801  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
802 }
803 
804 template <> InterpreterObject
805 HOMconvertValueForInterpreter<HOM_OpVerb*>(
806  HOM_OpVerb *const &opverb, int own)
807 {
808  if (!opverb)
809  return SWIG_NewPointerObj(opverb, SWIGTYPE_p_HOM_OpVerb, own);
810  OP_OpTypeId optypeid = (OP_OpTypeId)opverb->opTypeIdAsInt();
811  switch (optypeid)
812  {
813  case COP_OPTYPE_ID:
814  // Because of multiple inheritance, it's extremely important that
815  // we explicitly cast the pointer to a HOM_CopVerb so we
816  // pass the right address to SWIG_NewPointerObject, since it takes
817  // a void*.
818  return SWIG_NewPointerObj(
819  (void*)dynamic_cast<HOM_CopVerb* const>(opverb),
820  SWIGTYPE_p_HOM_CopVerb, own);
821  case SOP_OPTYPE_ID:
822  // Because of multiple inheritance, it's extremely important that
823  // we explicitly cast the pointer to a HOM_CopVerb so we
824  // pass the right address to SWIG_NewPointerObject, since it takes
825  // a void*.
826  return SWIG_NewPointerObj(
827  (void*)dynamic_cast<HOM_SopVerb* const>(opverb),
828  SWIGTYPE_p_HOM_SopVerb, own);
829  default:
830  break;
831  }
832  UT_ASSERT(!"Unknown opverb type");
833 
834  return SWIG_NewPointerObj(opverb,
835  SWIGTYPE_p_HOM_OpVerb, own);
836 
837 }
838 
839 template <> InterpreterObject
840 HOMconvertValueForInterpreter<HOM_CopVerb*>(
841  HOM_CopVerb *const &verb, int own)
842 {
843  return SWIG_NewPointerObj(verb, SWIGTYPE_p_HOM_CopVerb, own);
844 }
845 
846 template <> InterpreterObject
847 HOMconvertValueForInterpreter<HOM_SopVerb*>(
848  HOM_SopVerb *const &verb, int own)
849 {
850  return SWIG_NewPointerObj(verb, SWIGTYPE_p_HOM_SopVerb, own);
851 }
852 
853 template <> InterpreterObject
854 HOMconvertValueForInterpreter<HOM_Geometry*>(
855  HOM_Geometry *const &geo, int own)
856 {
857  return SWIG_NewPointerObj(geo, SWIGTYPE_p_HOM_Geometry, own);
858 }
859 
860 template <> InterpreterObject
861 HOMconvertValueForInterpreter<HOM_ImageLayer*>(
862  HOM_ImageLayer *const &layer, int own)
863 {
864  return SWIG_NewPointerObj(layer, SWIGTYPE_p_HOM_ImageLayer, own);
865 }
866 
867 template <> InterpreterObject
868 HOMconvertValueForInterpreter<HOM_NanoVDB*>(
869  HOM_NanoVDB *const &layer, int own)
870 {
871  return SWIG_NewPointerObj(layer, SWIGTYPE_p_HOM_NanoVDB, own);
872 }
873 
874 template <> InterpreterObject
875 HOMconvertValueForInterpreter<HOM_NetworkItem*>(
876  HOM_NetworkItem *const &item, int own)
877 {
878  if (item)
879  {
880  // Defer to the type-specific implementations of
881  // HOMconvertValueForInterpreter so we return the correct value
882  // based on which subclass of the object we have.
883  switch (item->networkItemType().id())
884  {
885  case HOM_networkItemType::Node_Id:
886  return HOMconvertValueForInterpreter(
887  dynamic_cast<HOM_Node* const>(item), own);
888 
889  case HOM_networkItemType::NetworkBox_Id:
890  return HOMconvertValueForInterpreter(
891  dynamic_cast<HOM_NetworkBox* const>(item), own);
892 
893  case HOM_networkItemType::StickyNote_Id:
894  return HOMconvertValueForInterpreter(
895  dynamic_cast<HOM_StickyNote* const>(item), own);
896 
897  case HOM_networkItemType::SubnetIndirectInput_Id:
898  return HOMconvertValueForInterpreter(
899  dynamic_cast<HOM_SubnetIndirectInput* const>(item), own);
900 
901  case HOM_networkItemType::Connection_Id:
902  return HOMconvertValueForInterpreter(
903  dynamic_cast<HOM_NodeConnection* const>(item), own);
904 
905  case HOM_networkItemType::NetworkDot_Id:
906  return HOMconvertValueForInterpreter(
907  dynamic_cast<HOM_NetworkDot* const>(item), own);
908 
909  default:
910  break;
911  };
912  }
913 
914  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_NetworkItem, own);
915 }
916 
917 template <> InterpreterObject
918 HOMconvertValueForInterpreter<HOM_NetworkMovableItem*>(
919  HOM_NetworkMovableItem *const &item, int own)
920 {
921  if (!item)
922  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_NetworkMovableItem, own);
923 
924  return HOMconvertValueForInterpreter<HOM_NetworkItem *>(item, own);
925 }
926 
927 template <> InterpreterObject
928 HOMconvertValueForInterpreter<
929  std::vector<HOM_ElemPtr<HOM_NodeConnection> >*>(
930  std::vector<HOM_ElemPtr<HOM_NodeConnection> > *const &list,
931  int own)
932 {
933  return swig::from(*list);
934 }
935 
936 template <> InterpreterObject
937 HOMconvertValueForInterpreter<HOM_DopData*>(HOM_DopData *const &data, int own)
938 {
939  const HOM_DopObject *const dop_object =
940  dynamic_cast<const HOM_DopObject *const>(data);
941  if (dop_object)
942  return SWIG_NewPointerObj(
943  (void *)dop_object, SWIGTYPE_p_HOM_DopObject, own);
944 
945  const HOM_DopRelationship *const dop_relationship =
946  dynamic_cast<const HOM_DopRelationship *const>(data);
947  if (dop_relationship)
948  return SWIG_NewPointerObj(
949  (void *)dop_relationship, SWIGTYPE_p_HOM_DopRelationship, own);
950 
951  return SWIG_NewPointerObj(data, SWIGTYPE_p_HOM_DopData, own);
952 }
953 
954 template <> InterpreterObject
955 HOMconvertValueForInterpreter<HOM_RadialItem*>(
956  HOM_RadialItem *const &item, int own)
957 {
958  if (item)
959  {
960  switch (item->type().id())
961  {
962  case HOM_radialItemType::Script_Id:
963  return SWIG_NewPointerObj(
964  (void*)dynamic_cast<const HOM_RadialScriptItem* const>(item),
965  SWIGTYPE_p_HOM_RadialScriptItem, own);
966 
967  case HOM_radialItemType::Submenu_Id:
968  return SWIG_NewPointerObj(
969  (void*)dynamic_cast<const HOM_RadialSubmenu* const>(item),
970  SWIGTYPE_p_HOM_RadialSubmenu, own);
971 
972  default:
973  break;
974  };
975  }
976 
977  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_RadialItem, own);
978 }
979 
980 template <> InterpreterObject
981 HOMconvertValueForInterpreter<HOM_EnumValue*>(
982  HOM_EnumValue *const &item, int own)
983 {
984  // We should NEVER heap allocate HOM_EnumValue because only return
985  // static instances of them to SWIG.
986  UT_ASSERT(!own);
987 
988  // NOTE: No dynamic_cast needed here
989  return SWIG_NewPointerObj((void*)item, SWIGTYPE_p_HOM_EnumValue, /*own*/0);
990 }
991 
992 // These functions specialize pointers to other classes. If a class is
993 // used inside HOM_IterableList or HOM_ElemPtr, it must be listed here.
994 #define HOM_PROVIDE_SWIG_LOOKUP(type) \
995  template <> InterpreterObject HOMconvertValueForInterpreter<type*>( \
996  type* const& value, int own) \
997  { \
998  return SWIG_NewPointerObj(SWIG_as_voidptr(value), \
999  SWIGTYPE_p_ ## type, own); \
1000  }
1001 
1002 HOM_PROVIDE_SWIG_LOOKUP(HOM_AdvancedDrawable)
1003 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentClip)
1004 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentDefinition)
1005 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentLayer)
1006 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShape)
1007 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShapeBinding)
1008 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShapeDeformer)
1009 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentTransformGroup)
1010 HOM_PROVIDE_SWIG_LOOKUP(HOM_AnimBar)
1011 HOM_PROVIDE_SWIG_LOOKUP(HOM_AssetGalleryDataSource)
1012 HOM_PROVIDE_SWIG_LOOKUP(HOM_Attrib)
1013 HOM_PROVIDE_SWIG_LOOKUP(HOM_AttribDataId)
1014 HOM_PROVIDE_SWIG_LOOKUP(HOM_Bookmark)
1015 HOM_PROVIDE_SWIG_LOOKUP(HOM_ChannelPrim)
1016 HOM_PROVIDE_SWIG_LOOKUP(HOM_ChannelGraphSelection)
1017 HOM_PROVIDE_SWIG_LOOKUP(HOM_clone_Connection)
1018 HOM_PROVIDE_SWIG_LOOKUP(HOM_Color)
1019 HOM_PROVIDE_SWIG_LOOKUP(HOM_Desktop)
1020 HOM_PROVIDE_SWIG_LOOKUP(HOM_Dialog)
1021 HOM_PROVIDE_SWIG_LOOKUP(HOM_DopRecord)
1022 HOM_PROVIDE_SWIG_LOOKUP(HOM_Drawable)
1023 HOM_PROVIDE_SWIG_LOOKUP(HOM_Drawable2D)
1024 HOM_PROVIDE_SWIG_LOOKUP(HOM_FloatingPanel)
1025 HOM_PROVIDE_SWIG_LOOKUP(HOM_GadgetContext)
1026 HOM_PROVIDE_SWIG_LOOKUP(HOM_GadgetDrawable)
1027 HOM_PROVIDE_SWIG_LOOKUP(HOM_Gallery)
1028 HOM_PROVIDE_SWIG_LOOKUP(HOM_GalleryEntry)
1029 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometrySelection)
1030 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryViewport)
1031 HOM_PROVIDE_SWIG_LOOKUP(HOM_Handle)
1032 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryDrawable)
1033 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryDrawableGroup)
1034 HOM_PROVIDE_SWIG_LOOKUP(HOM_HDADefinition)
1035 HOM_PROVIDE_SWIG_LOOKUP(HOM_HDASection)
1036 HOM_PROVIDE_SWIG_LOOKUP(HOM_ik_Joint)
1037 HOM_PROVIDE_SWIG_LOOKUP(HOM_IndexPairPropertyTable)
1038 HOM_PROVIDE_SWIG_LOOKUP(HOM_logging_LogEntry)
1039 HOM_PROVIDE_SWIG_LOOKUP(HOM_LopInstanceIdRule)
1040 HOM_PROVIDE_SWIG_LOOKUP(HOM_LopSelectionRule)
1041 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix2)
1042 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix3)
1043 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix4)
1044 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeBundle)
1045 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeGroup)
1046 HOM_PROVIDE_SWIG_LOOKUP(HOM_Pane)
1047 HOM_PROVIDE_SWIG_LOOKUP(HOM_Parm)
1048 HOM_PROVIDE_SWIG_LOOKUP(HOM_ParmTuple)
1049 HOM_PROVIDE_SWIG_LOOKUP(HOM_PluginHotkeyDefinitions)
1050 HOM_PROVIDE_SWIG_LOOKUP(HOM_Point)
1051 HOM_PROVIDE_SWIG_LOOKUP(HOM_Polygon)
1052 HOM_PROVIDE_SWIG_LOOKUP(HOM_PythonPanelInterface)
1053 HOM_PROVIDE_SWIG_LOOKUP(HOM_Edge)
1054 HOM_PROVIDE_SWIG_LOOKUP(HOM_PointGroup)
1055 HOM_PROVIDE_SWIG_LOOKUP(HOM_PrimGroup)
1056 HOM_PROVIDE_SWIG_LOOKUP(HOM_EdgeGroup)
1057 HOM_PROVIDE_SWIG_LOOKUP(HOM_VertexGroup)
1058 HOM_PROVIDE_SWIG_LOOKUP(HOM_Quaternion)
1059 HOM_PROVIDE_SWIG_LOOKUP(HOM_RadialMenu)
1060 HOM_PROVIDE_SWIG_LOOKUP(HOM_Ramp)
1061 HOM_PROVIDE_SWIG_LOOKUP(HOM_Selection)
1062 HOM_PROVIDE_SWIG_LOOKUP(HOM_Selector)
1063 HOM_PROVIDE_SWIG_LOOKUP(HOM_Shelf)
1064 HOM_PROVIDE_SWIG_LOOKUP(HOM_ShelfSet)
1065 HOM_PROVIDE_SWIG_LOOKUP(HOM_SimpleDrawable)
1066 HOM_PROVIDE_SWIG_LOOKUP(HOM_Take)
1067 HOM_PROVIDE_SWIG_LOOKUP(HOM_TextDrawable)
1068 HOM_PROVIDE_SWIG_LOOKUP(HOM_Tool)
1069 HOM_PROVIDE_SWIG_LOOKUP(HOM_Track)
1070 HOM_PROVIDE_SWIG_LOOKUP(HOM_UIEvent)
1071 HOM_PROVIDE_SWIG_LOOKUP(HOM_UIEventDevice)
1072 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector2)
1073 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector3)
1074 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector4)
1075 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vertex)
1076 HOM_PROVIDE_SWIG_LOOKUP(HOM_VexContext)
1077 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerHandleContext)
1078 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerHandleTemplate)
1079 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerState)
1080 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateContext)
1081 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateMenu)
1082 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateTemplate)
1083 HOM_PROVIDE_SWIG_LOOKUP(HOM_Viewport2D)
1084 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewportVisualizer)
1085 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewportVisualizerType)
1086 
1087 %}
1088 
1089 //----------------------------------------------------------------------------
1090 
1091 // We create typemaps for base classes that appear as return types to make
1092 // sure swig instances the proper subclasses in the interpreter.
1093 
1094 #define HOM_CONVERT_AND_CATCH \
1095  try \
1096  { \
1097  $result = HOMconvertValueForInterpreter($1, $owner); \
1098  } \
1099  catch (...) \
1100  { \
1101  (void)hom::raise_swig_exception(); \
1102  $result = nullptr; \
1103  } \
1104 /**/
1105 
1106 %typemap(out) HOM_Prim* {
1107  HOM_CONVERT_AND_CATCH
1108 }
1109 
1110 %typemap(out) HOM_PackedPrim* {
1111  HOM_CONVERT_AND_CATCH
1112 }
1113 
1114 %typemap(out) HOM_OpVerb* {
1115  HOM_CONVERT_AND_CATCH
1116 }
1117 
1118 %typemap(out) HOM_Node* {
1119  HOM_CONVERT_AND_CATCH
1120 }
1121 
1122 %typemap(out) HOM_NodeType* {
1123  HOM_CONVERT_AND_CATCH
1124 }
1125 
1126 %typemap(out) HOM_NodeTypeCategory* {
1127  HOM_CONVERT_AND_CATCH
1128 }
1129 
1130 %typemap(out) HOM_NodeTypeCategory& {
1131  HOM_CONVERT_AND_CATCH
1132 }
1133 
1134 %typemap(out) HOM_NetworkBox* {
1135  HOM_CONVERT_AND_CATCH
1136 }
1137 
1138 %typemap(out) HOM_NetworkDot* {
1139  HOM_CONVERT_AND_CATCH
1140 }
1141 
1142 %typemap(out) HOM_StickyNote* {
1143  HOM_CONVERT_AND_CATCH
1144 }
1145 
1146 %typemap(out) HOM_SubnetIndirectInput* {
1147  HOM_CONVERT_AND_CATCH
1148 }
1149 
1150 %typemap(out) HOM_NodeConnection* {
1151  HOM_CONVERT_AND_CATCH
1152 }
1153 
1154 %typemap(out) HOM_BaseKeyframe* {
1155  HOM_CONVERT_AND_CATCH
1156 }
1157 
1158 %typemap(out) HOM_ParmTemplate* {
1159  HOM_CONVERT_AND_CATCH
1160 }
1161 
1162 %typemap(out) HOM_Pane* {
1163  HOM_CONVERT_AND_CATCH
1164 }
1165 
1166 %typemap(out) HOM_PaneTab* {
1167  HOM_CONVERT_AND_CATCH
1168 }
1169 
1170 %typemap(out) HOM_DopData* {
1171  HOM_CONVERT_AND_CATCH
1172 }
1173 
1174 %typemap(out) HOM_RadialItem* {
1175  HOM_CONVERT_AND_CATCH
1176 }
1177 
1178 %typemap(out) HOM_NetworkMovableItem* {
1179  HOM_CONVERT_AND_CATCH
1180 }
1181 
1182 %typemap(out) HOM_NetworkItem* {
1183  HOM_CONVERT_AND_CATCH
1184 }
1185 
1186 %typemap(out) std::vector<HOM_ElemPtr<HOM_NodeConnection> > * {
1187  HOM_CONVERT_AND_CATCH
1188 }
1189 
1190 //----------------------------------------------------------------------------
1191 
1192 // These typemaps convert HOM exceptions into corresponding python standard
1193 // exceptions.
1194 %typemap(throws) HOM_TypeError %{
1195  SWIG_exception_fail(SWIG_TypeError, $1.instanceMessage().c_str());
1196 %}
1197 
1198 %typemap(throws) HOM_ValueError %{
1199  SWIG_exception_fail(SWIG_ValueError, $1.instanceMessage().c_str());
1200 %}
1201 
1202 #ifdef SWIGPYTHON
1203 %typemap(throws) HOM_SystemExit %{
1204  PyErr_SetObject(PyExc_SystemExit, SWIG_From_int($1.code()));
1205  SWIG_fail;
1206 %}
1207 #endif
1208 
1209 //----------------------------------------------------------------------------
1210 
1211 // This typemap lets you declare a hboost::any parameter and swig will convert
1212 // the interpreter (Python) object to a hboost::any that wraps the C++ data
1213 // type.
1214 %typemap(in) hboost::any {
1215  try
1216  {
1217  // Note that if we can't convert to a hboost::any, we leave the
1218  // hboost::any as empty (i.e. its empty() method returns true).
1219  HOMinterpreterObjectToBoostAny($input, $1);
1220  }
1221  catch (...)
1222  {
1223  (void)hom::raise_swig_exception();
1224  }
1225 }
1226 
1227 // This typemap lets you declare a HOM_UTOptionAny (hboost::any) parameter and
1228 // swig will convert the interpreter (Python) object into the C++ data type
1229 // for interpreter objects that correspond to a UT_OptionType.
1230 %typemap(in) HOM_UTOptionAny {
1231  try
1232  {
1233  // Note that if we can't convert to a hboost::any, we leave the
1234  // hboost::any as empty (i.e. its empty() method returns true).
1235  HOMinterpreterObjectToUTOptionAny($input, $1);
1236  }
1237  catch (...)
1238  {
1239  (void)hom::raise_swig_exception();
1240  }
1241 }
1242 
1243 // This typemap lets you return hboost::any objects.
1244 %typemap(out) hboost::any {
1245  try
1246  {
1247  $result = HOMboostAnyToInterpreterObject($1);
1248  }
1249  catch (...)
1250  {
1251  (void)hom::raise_swig_exception();
1252  }
1253 }
1254 
1255 %typemap(out) HOM_DDSourceAny {
1256  try
1257  {
1258  $result = HOMDDSourceAnyToInterpreterObject($1);
1259  }
1260  catch (...)
1261  {
1262  (void)hom::raise_swig_exception();
1263  }
1264 }
1265 
1266 //----------------------------------------------------------------------------
1267 
1268 %typemap(in) HOM_OptionalDouble {
1269  try
1270  {
1271 #ifdef SWIGPYTHON
1272  if ($input != Py_None)
1273  {
1274 #endif
1275  double res;
1276  if (SWIG_IsOK(SWIG_AsVal_double($input, &res)))
1277  $1 = res;
1278 #ifdef SWIGPYTHON
1279  }
1280 #endif
1281  }
1282  catch (...)
1283  {
1284  (void)hom::raise_swig_exception();
1285  }
1286 }
1287 
1288 %typemap(in) HOM_OptionalInt {
1289  try
1290  {
1291 #ifdef SWIGPYTHON
1292  if ($input != Py_None)
1293  {
1294 #endif
1295  int res;
1296  if (SWIG_IsOK(SWIG_AsVal_int($input, &res)))
1297  $1 = res;
1298 #ifdef SWIGPYTHON
1299  }
1300 #endif
1301  }
1302  catch (...)
1303  {
1304  (void)hom::raise_swig_exception();
1305  }
1306 }
1307 
1308 %typemap(out) HOM_OptionalInt {
1309  try
1310  {
1311  if ($1.has_value())
1312  $result = SWIG_From_int($1.value());
1313  else
1314  $result = SWIG_Py_Void();
1315  }
1316  catch (...)
1317  {
1318  (void)hom::raise_swig_exception();
1319  }
1320 }
1321 
1322 //----------------------------------------------------------------------------
1323 
1324 #ifdef SWIGPYTHON
1325 %typemap(out) PY_OpaqueObject {
1326  $result = HOMincRef((InterpreterObject)$1.opaqueObject());
1327 }
1328 #endif
1329 
1330 // For whatever reason, adding the typemap does not customize swig::from(),
1331 // so we do that manually.
1332 %{
1333 #ifdef SWIGPYTHON
1334 namespace swig {
1335  template <>
1336  struct traits_from<PY_OpaqueObject>
1337  {
1338  static PyObject *from(const PY_OpaqueObject &val)
1339  {
1340  return HOMincRef((InterpreterObject)val.opaqueObject());
1341  }
1342  };
1343 }
1344 #endif
1345 
1346 template <typename T>
1347 bool
1348 HOMinterpreterObjectConvertPtr(InterpreterObject input, hboost::any &result,
1349  swig_type_info *descriptor)
1350 {
1351  void *t_ptr = NULL;
1352  int res = SWIG_ConvertPtr(input, &t_ptr, descriptor, 0);;
1353  if (SWIG_IsOK(res) && t_ptr)
1354  {
1355  // Assign the pointer directly, taking ownership
1356  result = reinterpret_cast<T*>(t_ptr);
1357  return true;
1358  }
1359  else
1360  {
1361  return false;
1362  }
1363 }
1364 
1365 // Reworked traits_asptr_stdseq for std::vector
1366 // Avoid calling it.end() within the loop and pre-allocate the std::vector.
1367 template <typename Seq, typename T = typename Seq::value_type>
1368 bool
1369 HOMinterpreterObjectConvertSeq(InterpreterObject input, hboost::any &result)
1370 {
1371  swig::SwigPySequence_Cont<T> swigpyseq(input);
1372  if (!swigpyseq.check())
1373  return false;
1374 
1375  auto n = swigpyseq.size();
1376 
1377  Seq seq(n);
1378  for (auto i=0;i<n; ++i)
1379  seq[i] = swigpyseq[i];
1380 
1381  result = std::move(seq);
1382 
1383  return true;
1384 }
1385 
1386 template <typename T>
1387 bool
1388 HOMinterpreterObjectConvertVal(InterpreterObject input, hboost::any &result)
1389 {
1390 
1391  // This branch is using swig_input which was already filled by
1392  // SWIG_Python_GetSwigThis
1393  swig_type_info *descriptor = swig::type_info<T>();
1394  if (!descriptor)
1395  return false;
1396 
1397  T *t_ptr = NULL;
1398  int res = SWIG_ConvertPtr(input, (void**)&t_ptr, descriptor, 0);
1399 
1400  if (!SWIG_IsOK(res) || !t_ptr)
1401  return false;
1402 
1403  // This is a clever trick using std::move, since we can't take
1404  // ownership of the pointer
1405  // Deleting t_ptr will delete the cleared instance which is going to
1406  // be faster than deleting the real instance and the internal data
1407  // of std containers should be moved properly.
1408  result = std::move(*t_ptr);
1409  if (SWIG_IsNewObj(res))
1410  delete t_ptr;
1411 
1412  return true;
1413 }
1414 
1415 template <typename T>
1416 bool
1417 HOMinterpreterObjectConvertAsPtr(InterpreterObject input, hboost::any &result)
1418 {
1419  // First call is to check if the conversion is valid.
1420  // It doesn't perform allocations when failing
1421  int res = swig::asptr(input, (T**)NULL);
1422  if (!SWIG_IsOK(res))
1423  return false;
1424 
1425  // Second call does the conversion
1426  T *t_ptr = NULL;
1427  res = swig::asptr(input, &t_ptr);
1428  if (!SWIG_IsOK(res) || !t_ptr)
1429  return false;
1430 
1431  // This is a clever trick using std::move, since we can't take
1432  // ownership of the pointer
1433  // Deleting t_ptr will delete the cleared instance which is going to
1434  // be faster than deleting the real instance and the internal data
1435  // of std containers should be moved properly.
1436  result = std::move(*t_ptr);
1437  if (SWIG_IsNewObj(res))
1438  delete t_ptr;
1439 
1440  return true;
1441 }
1442 
1443 #define CONVERT_PTR(X) \
1444  if (HOMinterpreterObjectConvertPtr<X>(\
1445  swig_input,result,SWIGTYPE_p_##X))\
1446  return true;
1447 
1448 #define CONVERT_VAL(X) \
1449  if (HOMinterpreterObjectConvertVal<X>(swig_input,result))\
1450  return true;
1451 
1452 #define CONVERT_ASPTR(X) \
1453  if (HOMinterpreterObjectConvertAsPtr<X>(input,result))\
1454  return true;
1455 
1456 #define CONVERT_SEQ(X) \
1457  if (HOMinterpreterObjectConvertSeq<X>(input,result))\
1458  return true;
1459 
1460 // Need typedefs to pass as a macro argument
1461 typedef std::map<std::string,hboost::any> std__map_std__string_hboost__any_;
1462 typedef std::vector<std::map<std::string,hboost::any>> std__vector_std__map_std__string_hboost__any__;
1463 
1464 //----------------------------------------------------------------------------
1465 
1466 // This helper function takes an interpreter (Python) object and converts it
1467 // into a hboost::any object. It returns whether or not the conversion was
1468 // possible, and leaves the hboost::any unchanged if a conversion wasn't
1469 // possible.
1470 bool
1471 HOMinterpreterObjectToBoostAny(InterpreterObject input, hboost::any &result)
1472 {
1473 #ifdef SWIGPYTHON
1474  if (input == Py_None)
1475  {
1476  result = (void *)NULL;
1477  return true;
1478  }
1479 
1480  // SWIG_AsVal_bool is too permissive, and treats thinks that an integer
1481  // is a bool. So, we explicitly check against True and False.
1482  if (input == Py_True)
1483  {
1484  result = true;
1485  return true;
1486  }
1487 
1488  if (input == Py_False)
1489  {
1490  result = false;
1491  return true;
1492  }
1493 #endif
1494 
1495  int int_result;
1496  if (SWIG_IsOK(SWIG_AsVal_int(input, &int_result)))
1497  {
1498  result = int_result;
1499  return true;
1500  }
1501 
1502  double double_result;
1503  if (SWIG_IsOK(SWIG_AsVal_double(input, &double_result)))
1504  {
1505  result = double_result;
1506  return true;
1507  }
1508 
1509  {
1510  char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
1511  if (SWIG_IsOK((SWIG_AsCharPtrAndSize(input, &buf, &size, &alloc))))
1512  {
1513  if (buf)
1514  {
1515  result = std::string(buf, size - 1);
1516  if (alloc == SWIG_NEWOBJ)
1517  delete[] buf;
1518  }
1519  else
1520  {
1521  result = std::string();
1522  }
1523  return true;
1524 
1525  }
1526  }
1527 
1528  // Sequences and Dict must go through swig::asptr()
1529  // because of traits_asptr_stdseq and traits_asptr<std::map<K,T,Compare,Alloc > >
1530  // It is a faster code path that doesn't use SWIG_Python_GetSwigThis
1531  bool is_seq = PyList_Check(input) || PyTuple_Check(input);
1532  bool is_dict = PyDict_Check(input);
1533  if (is_seq)
1534  {
1535  CONVERT_SEQ(std::vector<int>);
1536  CONVERT_SEQ(std::vector<double>);
1537  CONVERT_SEQ(std::vector<std::string>);
1538  CONVERT_SEQ(std::vector<HOM_Quaternion>);
1539  CONVERT_SEQ(std::vector<HOM_Vector2>);
1540  CONVERT_SEQ(std::vector<HOM_Vector3>);
1541  CONVERT_SEQ(std::vector<HOM_Vector4>);
1542  CONVERT_SEQ(std::vector<HOM_Matrix2>);
1543  CONVERT_SEQ(std::vector<HOM_Matrix3>);
1544  CONVERT_SEQ(std::vector<HOM_Matrix4>);
1545  CONVERT_SEQ(std__vector_std__map_std__string_hboost__any__);
1546  }
1547  else if (is_dict)
1548  {
1549  CONVERT_ASPTR(std__map_std__string_hboost__any_);
1550  }
1551  else
1552  {
1553  // This greatly speeds up the casting for the remaining cases.
1554  // The int,float,string,seq,dict checks were simple and didn't rely
1555  // on calling SWIG_Python_GetSwigThis.
1556  InterpreterObject swig_input =
1557  (InterpreterObject)SWIG_Python_GetSwigThis(input);
1558 
1559  CONVERT_VAL(std::string);
1560 
1561  CONVERT_PTR(HOM_Geometry);
1562  CONVERT_PTR(HOM_ImageLayer);
1563  CONVERT_PTR(HOM_NanoVDB);
1564  CONVERT_PTR(HOM_Ramp);
1565  CONVERT_PTR(HOM_Color);
1566  CONVERT_PTR(HOM_Parm);
1567  CONVERT_PTR(HOM_EnumValue);
1568  CONVERT_PTR(HOM_Quaternion);
1569  CONVERT_PTR(HOM_Vector2);
1570  CONVERT_PTR(HOM_Vector3);
1571  CONVERT_PTR(HOM_Vector4);
1572  CONVERT_PTR(HOM_Matrix2);
1573  CONVERT_PTR(HOM_Matrix3);
1574  CONVERT_PTR(HOM_Matrix4);
1575 
1576  // Call the fallback version that uses SWIG_Python_GetSwigThis
1577  CONVERT_VAL(std::vector<int>);
1578  CONVERT_VAL(std::vector<double>);
1579  CONVERT_VAL(std::vector<std::string>);
1580  CONVERT_VAL(std::vector<HOM_Quaternion>);
1581  CONVERT_VAL(std::vector<HOM_Vector2>);
1582  CONVERT_VAL(std::vector<HOM_Vector3>);
1583  CONVERT_VAL(std::vector<HOM_Vector4>);
1584  CONVERT_VAL(std::vector<HOM_Matrix2>);
1585  CONVERT_VAL(std::vector<HOM_Matrix3>);
1586  CONVERT_VAL(std::vector<HOM_Matrix4>);
1587  CONVERT_VAL(std__map_std__string_hboost__any_);
1588  CONVERT_VAL(std__vector_std__map_std__string_hboost__any__);
1589  }
1590 
1591 
1592  UT_ASSERT(result.empty());
1593  return false;
1594 }
1595 
1596 // This helper function takes an interpreter (Python) object and converts it
1597 // into a HOM_UTOptionAny (hboost::any) object. It returns whether or not the
1598 // conversion was possible, and leaves the HOM_UTOptionAny unchanged if a
1599 // conversion wasn't possible.
1600 bool
1601 HOMinterpreterObjectToUTOptionAny(InterpreterObject input,
1602  HOM_UTOptionAny &result)
1603 {
1604  return HOMinterpreterObjectToBoostAny(input, result);
1605 }
1606 
1607 // Creating an input typemap isn't sufficient to handle input parameters with
1608 // std::vector's or std::map's of hboost::any's, so we need to specialize
1609 // swig::traits_asptr<hboost::any>.
1610 namespace swig {
1611  template <>
1612  struct traits_asptr<hboost::any>
1613  {
1614  static int asptr(InterpreterObject obj, hboost::any **val)
1615  {
1616  // TODO: Will the hboost::any be properly deleted?
1617  hboost::any *p = new hboost::any();
1618  HOMinterpreterObjectToBoostAny(obj, *p);
1619  if (val)
1620  *val = p;
1621  return SWIG_NEWOBJ;
1622  }
1623  };
1624 }
1625 
1626 // This function is not instantiated until the first use of HOM_BinaryString,
1627 // but we need to use it in HOMboostAnyToInterpreterObject. So just forward
1628 // declare it here.
1629 static PyObject * SWIG_From_HOM_BinaryString(const HOM_BinaryString& s);
1630 
1631 // This helper function takes a variable wrapped inside a hboost::any object
1632 // and creates a new instance of the corresponding InterpreterObject.
1633 static InterpreterObject
1634 HOMboostAnyToInterpreterObject(const hboost::any &result)
1635 {
1636  if (result.empty())
1637  return SWIG_Py_Void();
1638 
1639  namespace ti = hboost::typeindex;
1640 
1641  if (result.type() == ti::type_id<int>())
1642  return SWIG_From_int(hboost::any_cast<int>(result));
1643 
1644  if (result.type() == ti::type_id<long>())
1645  return SWIG_From_long(hboost::any_cast<long>(result));
1646 
1647  if (result.type() == ti::type_id<int64>())
1648  return swig::from(hboost::any_cast<int64>(result));
1649 
1650  if (result.type() == ti::type_id<float>())
1651  return SWIG_From_float(hboost::any_cast<float>(result));
1652 
1653  if (result.type() == ti::type_id<double>())
1654  return SWIG_From_double(hboost::any_cast<double>(result));
1655 
1656  if (result.type() == ti::type_id<bool>())
1657  return SWIG_From_bool(hboost::any_cast<bool>(result));
1658 
1659  if (result.type() == ti::type_id<std::string>())
1660  return SWIG_From_std_string(hboost::any_cast<std::string>(result));
1661 
1662  if (result.type() == ti::type_id<HOM_BinaryString>())
1663  return SWIG_From_HOM_BinaryString(hboost::any_cast<HOM_BinaryString>(result));
1664 
1665  if (result.type() == ti::type_id<std::map<std::string, hboost::any>>())
1666  return swig::from(
1667  hboost::any_cast<std::map<std::string, hboost::any> >(result));
1668 
1669  if (result.type() == ti::type_id<std::vector<int>>())
1670  return swig::from(hboost::any_cast<std::vector<int> >(result));
1671 
1672  if (result.type() == ti::type_id<std::vector<int64>>())
1673  return swig::from(hboost::any_cast<std::vector<int64> >(result));
1674 
1675  if (result.type() == ti::type_id<std::vector<float>>())
1676  return swig::from(hboost::any_cast<std::vector<float> >(result));
1677 
1678  if (result.type() == ti::type_id<std::vector<std::string>>())
1679  return swig::from(hboost::any_cast<std::vector<std::string> >(result));
1680 
1681  if (result.type() == ti::type_id<std::vector<double>>())
1682  return swig::from(hboost::any_cast<std::vector<double> >(result));
1683 
1684  if (result.type() == ti::type_id<std::vector<std::vector<float> >>())
1685  return swig::from(
1686  hboost::any_cast<std::vector<std::vector<float> > >(result));
1687 
1688  if (result.type() == ti::type_id<std::vector<std::vector<double> >>())
1689  return swig::from(
1690  hboost::any_cast<std::vector<std::vector<double> > >(result));
1691 
1692  if (result.type() == ti::type_id<std::vector<std::map<std::string, hboost::any> >>())
1693  return swig::from(
1694  hboost::any_cast<std::vector<std::map<std::string, hboost::any> > >(result));
1695 
1696  // If a HOM function returns a pointer to a HOM_Vector*/HOM_Matrix*, it
1697  // will transfer the ownership of that object to swig.
1698  if (result.type() == ti::type_id<HOM_Vector2 *>())
1699  return HOMconvertValueForInterpreter(
1700  hboost::any_cast<HOM_Vector2 *>(result), SWIG_POINTER_OWN);
1701 
1702  if (result.type() == ti::type_id<HOM_Vector3 *>())
1703  return HOMconvertValueForInterpreter(
1704  hboost::any_cast<HOM_Vector3 *>(result), SWIG_POINTER_OWN);
1705 
1706  if (result.type() == ti::type_id<HOM_Vector4 *>())
1707  return HOMconvertValueForInterpreter(
1708  hboost::any_cast<HOM_Vector4 *>(result), SWIG_POINTER_OWN);
1709 
1710  if (result.type() == ti::type_id<HOM_Matrix2 *>())
1711  return HOMconvertValueForInterpreter(
1712  hboost::any_cast<HOM_Matrix2 *>(result), SWIG_POINTER_OWN);
1713 
1714  if (result.type() == ti::type_id<HOM_Matrix3 *>())
1715  return HOMconvertValueForInterpreter(
1716  hboost::any_cast<HOM_Matrix3 *>(result), SWIG_POINTER_OWN);
1717 
1718  if (result.type() == ti::type_id<HOM_Matrix4 *>())
1719  return HOMconvertValueForInterpreter(
1720  hboost::any_cast<HOM_Matrix4 *>(result), SWIG_POINTER_OWN);
1721 
1722  if (result.type() == ti::type_id<HOM_Quaternion *>())
1723  return HOMconvertValueForInterpreter(
1724  hboost::any_cast<HOM_Quaternion *>(result), SWIG_POINTER_OWN);
1725 
1726  if (result.type() == ti::type_id<HOM_NodeType *>())
1727  return HOMconvertValueForInterpreter(
1728  hboost::any_cast<HOM_NodeType *>(result), SWIG_POINTER_OWN);
1729 
1730  if (result.type() == ti::type_id<HOM_Ramp *>())
1731  return HOMconvertValueForInterpreter(
1732  hboost::any_cast<HOM_Ramp *>(result), SWIG_POINTER_OWN);
1733 
1734  if (result.type() == ti::type_id<HOM_Color *>())
1735  return HOMconvertValueForInterpreter(
1736  hboost::any_cast<HOM_Color *>(result), SWIG_POINTER_OWN);
1737 
1738  if (result.type() == ti::type_id<HOM_Parm *>())
1739  return HOMconvertValueForInterpreter(
1740  hboost::any_cast<HOM_Parm *>(result), SWIG_POINTER_OWN);
1741 
1742  if (result.type() == ti::type_id<HOM_EnumValue *>())
1743  return HOMconvertValueForInterpreter(
1744  hboost::any_cast<HOM_EnumValue *>(result), /*own*/0);
1745 
1746  if (result.type() == ti::type_id<HOM_Geometry *>())
1747  return HOMconvertValueForInterpreter(
1748  hboost::any_cast<HOM_Geometry *>(result), SWIG_POINTER_OWN);
1749 
1750  if (result.type() == ti::type_id<HOM_ImageLayer *>())
1751  return HOMconvertValueForInterpreter(
1752  hboost::any_cast<HOM_ImageLayer *>(result), SWIG_POINTER_OWN);
1753 
1754  if (result.type() == ti::type_id<HOM_NanoVDB *>())
1755  return HOMconvertValueForInterpreter(
1756  hboost::any_cast<HOM_NanoVDB *>(result), SWIG_POINTER_OWN);
1757 
1758  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Vector2> >>())
1759  return swig::from(
1760  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector2> > >(result));
1761 
1762  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Vector3> >>())
1763  return swig::from(
1764  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector3> > >(result));
1765 
1766  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Vector4> >>())
1767  return swig::from(
1768  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector4> > >(result));
1769 
1770  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Matrix2> >>())
1771  return swig::from(
1772  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix2> > >(result));
1773 
1774  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Matrix3> >>())
1775  return swig::from(
1776  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix3> > >(result));
1777 
1778  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Matrix4> >>())
1779  return swig::from(
1780  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix4> > >(result));
1781 
1782  if (result.type() == ti::type_id<std::vector<HOM_ElemPtr<HOM_Quaternion> >>())
1783  return swig::from(
1784  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Quaternion> > >(result));
1785 
1786 #if UT_ASSERT_LEVEL > 0
1787  std::cout << "Unknown data type: "
1788  << UTunmangleClassNameFromTypeIdName(result.type().name()) << "\n";
1789 #endif
1790  UT_ASSERT(!"Unknown data type");
1791  return SWIG_Py_Void();
1792 }
1793 
1794 // This helper function takes a variable wrapped inside a hboost::any object
1795 // and creates a new instance of the corresponding InterpreterObject.
1796 static InterpreterObject
1797 HOMDDSourceAnyToInterpreterObject(const HOM_DDSourceAny &result)
1798 {
1799  namespace ti = hboost::typeindex;
1800 
1801  if (result.type() == ti::type_id<HOM_Node *>())
1802  {
1803  return HOMconvertValueForInterpreter(
1804  hboost::any_cast<HOM_Node *>(result), SWIG_POINTER_OWN);
1805  }
1806  if (result.type() == ti::type_id<HOM_Parm *>())
1807  {
1808  return HOMconvertValueForInterpreter(
1809  hboost::any_cast<HOM_Parm *>(result), SWIG_POINTER_OWN);
1810  }
1811  if (result.type() == ti::type_id<HOM_GalleryEntry *>())
1812  {
1813  return HOMconvertValueForInterpreter(
1814  hboost::any_cast<HOM_GalleryEntry *>(result), SWIG_POINTER_OWN);
1815  }
1816 
1817  return HOMboostAnyToInterpreterObject(result);
1818 }
1819 
1820 namespace swig {
1821  // Adding the typemap does not customize swig::from() so we do that
1822  // manually.
1823  template <>
1824  struct traits_from<hboost::any>
1825  {
1826  static PyObject *from(const hboost::any &val)
1827  { return HOMboostAnyToInterpreterObject(val); }
1828  };
1829 }
1830 
1831 static InterpreterObject
1832 HOMoptionsToInterpreterObject(const UT_Options &options);
1833 
1834 static InterpreterObject
1835 HOMoptionEntryToInterpreterObject(const UT_OptionEntry &option_entry)
1836 {
1837  // We're usually called from code that has the GIL released so make sure we
1838  // acquire it here.
1839  PY_InterpreterAutoLock py_lock;
1840 
1841  InterpreterObject result = NULL;
1842 
1843  switch (option_entry.getType())
1844  {
1845  case UT_OPTION_INT:
1846  return swig::from(
1847  ((const UT_OptionInt &)option_entry).getValue());
1848 
1849  case UT_OPTION_BOOL:
1850  return SWIG_From_bool(
1851  ((const UT_OptionBool &)option_entry).getValue());
1852 
1853  case UT_OPTION_FPREAL:
1854  return SWIG_From_double(
1855  ((const UT_OptionFpreal &)option_entry).getValue());
1856 
1857  case UT_OPTION_STRING:
1858  case UT_OPTION_STRINGRAW:
1859  {
1860  return SWIG_From_std_string(
1861  ((const UT_OptionString &)option_entry).getValue().toStdString());
1862  }
1863 
1864  case UT_OPTION_VECTOR2:
1865  return HOMconvertValueForInterpreter(
1866  new HOM_Vector2(
1867  ((const UT_OptionVector2 &)option_entry).getValue()),
1868  SWIG_POINTER_OWN);
1869 
1870  case UT_OPTION_VECTOR3:
1871  return HOMconvertValueForInterpreter(
1872  new HOM_Vector3(
1873  ((const UT_OptionVector3 &)option_entry).getValue()),
1874  SWIG_POINTER_OWN);
1875 
1876  case UT_OPTION_VECTOR4:
1877  return HOMconvertValueForInterpreter(
1878  new HOM_Vector4(
1879  ((const UT_OptionVector4 &)option_entry).getValue()),
1880  SWIG_POINTER_OWN);
1881 
1882  case UT_OPTION_QUATERNION:
1883  return HOMconvertValueForInterpreter(
1884  new HOM_Quaternion(
1885  ((const UT_OptionQuaternion &)option_entry).getValue()),
1886  SWIG_POINTER_OWN);
1887 
1888  case UT_OPTION_MATRIX2:
1889  return HOMconvertValueForInterpreter(
1891  ((const UT_OptionMatrix2 &)option_entry).getValue())),
1892  SWIG_POINTER_OWN);
1893 
1894  case UT_OPTION_MATRIX3:
1895  return HOMconvertValueForInterpreter(
1897  ((const UT_OptionMatrix3 &)option_entry).getValue())),
1898  SWIG_POINTER_OWN);
1899 
1900  case UT_OPTION_MATRIX4:
1901  return HOMconvertValueForInterpreter(
1903  ((const UT_OptionMatrix4 &)option_entry).getValue())),
1904  SWIG_POINTER_OWN);
1905 
1906  case UT_OPTION_UV:
1907  return HOMconvertValueForInterpreter(
1908  new HOM_Vector2(
1909  ((const UT_OptionUV &)option_entry).getValue()),
1910  SWIG_POINTER_OWN);
1911 
1912  case UT_OPTION_UVW:
1913  return HOMconvertValueForInterpreter(
1914  new HOM_Vector3(
1915  ((const UT_OptionUVW &)option_entry).getValue()),
1916  SWIG_POINTER_OWN);
1917 
1918  case UT_OPTION_INTARRAY:
1919  {
1920  std::vector<int64> int_vector;
1921  UTarrayToStdVector(
1922  static_cast<const UT_OptionInt64Array &>(option_entry)
1923  .getValue(), int_vector);
1924  return swig::from(int_vector);
1925  }
1926 
1927  case UT_OPTION_FPREALARRAY:
1928  {
1929  std::vector<double> double_vector;
1930  UTarrayToStdVector(
1931  static_cast<const UT_OptionFpreal64Array &>(option_entry)
1932  .getValue(), double_vector);
1933  return swig::from(double_vector);
1934  }
1935 
1936  case UT_OPTION_STRINGARRAY:
1937  {
1938  std::vector<std::string> str_vector;
1939  UTarrayToStdVectorOfStrings(
1940  static_cast<const UT_OptionStringArray &>(option_entry)
1941  .getValue(), str_vector);
1942  return swig::from(str_vector);
1943  }
1944 
1945  case UT_OPTION_DICT:
1946  {
1947  UT_OptionsHolder opt;
1948  opt = static_cast<const UT_OptionDict &>(option_entry).getValue();
1949  return HOMoptionsToInterpreterObject(*opt.options());
1950  }
1951  case UT_OPTION_DICTARRAY:
1952  {
1954  optlist = static_cast<const UT_OptionDictArray &>(option_entry).getValue();
1955  InterpreterObject result = PyList_New(0);
1956 
1957  for (auto && opt : optlist)
1958  {
1959  PyList_Append(result, HOMoptionsToInterpreterObject(*opt.options()));
1960  }
1961 
1962  return result;
1963  }
1964  case UT_OPTION_INVALID:
1965  case UT_OPTION_NUM_TYPES:
1966  // Just exit the switch with no result.
1967  break;
1968  }
1969 
1970  return result ? result : SWIG_Py_Void();
1971 }
1972 
1973 #ifdef SWIGPYTHON
1974 static InterpreterObject
1975 HOMoptionsToInterpreterObject(const UT_Options &options)
1976 {
1977  // We're usually called from code that has the GIL released so make sure we
1978  // acquire it here.
1979  PY_InterpreterAutoLock py_lock;
1980 
1981  InterpreterObject result = PyDict_New();
1982 
1983  for (UT_Options::iterator it = options.begin(); !it.atEnd(); ++it)
1984  {
1985  // The Python dictionary object will increment the reference count
1986  // on the value, so we decrement it since we just allocated it.
1987  InterpreterObject value=HOMoptionEntryToInterpreterObject(*it.entry());
1988  PyDict_SetItemString(result, it.name(), value);
1989  Py_DECREF(value);
1990  }
1991 
1992  return result;
1993 }
1994 
1995 static InterpreterObject
1996 HOMoptionsListToInterpreterObject(const std::vector<UT_Options>& options)
1997 {
1998  auto pysize = options.size();
1999 
2000  // We're usually called from code that has the GIL released so make sure we
2001  // acquire it here.
2002  PY_InterpreterAutoLock py_lock;
2003 
2004  InterpreterObject list = PyList_New(pysize);
2005  for (int i = 0; i < pysize; ++i)
2006  {
2007  auto value = HOMoptionsToInterpreterObject(options[i]);
2008  // PyList_SET_ITEM will steal the reference
2009  PyList_SET_ITEM(list, i, value);
2010  }
2011  return list;
2012 }
2013 
2014 #endif
2015 
2016 #ifdef SWIGPYTHON
2017 
2018 // Helper for accessing a HOM object python attributes.
2019 // Used by HDAModule, HDAViewerStateModule and HOMF_HDAViewerHandleModule.
2020 template<typename T>
2021 PyObject* HOMgetattr(T* hom_object, const char *name)
2022 {
2023  HOM_AutoLock hom_lock;
2024  PY_InterpreterAutoLock py_lock;
2025 
2026  // First check the context's locals dictionary. If the context
2027  // pointer is null we treat it as though the dictionary is empty.
2028  PY_EvaluationContext *context = hom_object->getEvaluationContext();
2029  PyObject *dict = context
2030  ? (PyObject *)context->getGlobalsDict() : NULL;
2031  PyObject *attribute = (dict && name)
2032  ? PyDict_GetItemString(dict, name) : NULL;
2033 
2034  // If the lookup failed, try the globals dictionary.
2035  if (!attribute && dict)
2036  {
2037  dict = (PyObject *)context->getGlobalsDict();
2038  attribute = name ? PyDict_GetItemString(dict, name) : NULL;
2039  }
2040 
2041  // If we found an object in the dictionary, return it, being careful
2042  // to increment the reference count on the object.
2043  if (attribute)
2044  return HOMincRef(attribute);
2045 
2046  // We didn't find the object, so raise an exception.
2047  if (!name)
2048  name = "";
2049  UT_WorkBuffer error_message;
2050  error_message.sprintf("'module' object has no attribute '%s'", name);
2051  PyErr_SetString(PyExc_AttributeError, error_message.buffer());
2052  return NULL;
2053 }
2054 #endif
2055 
2056 //----------------------------------------------------------------------------
2057 
2058 #ifdef SWIGPYTHON
2059 // This helper class takes a Python buffer object and provides access to
2060 // the underlying C buffer. Note that the class is only used inside the
2061 // swig file, so it doesn't need to be exported from the current library.
2062 class HOM_PyBuffer
2063 {
2064 public:
2065  HOM_PyBuffer(InterpreterObject py_object)
2066  {
2067 #if PY_VERSION_HEX >= 0x03000000
2068  myBytesObj = nullptr;
2069 #endif
2070  myData = NULL;
2071  myLength = 0;
2072 
2073  PyObject *obj = py_object;
2074 
2075 #if PY_VERSION_HEX >= 0x03000000
2076  // Automatically convert HOM binary strings to buffer-like objects.
2077  if (PyUnicode_Check(obj))
2078  {
2079  myBytesObj =
2080  PyUnicode_AsEncodedString(obj, "utf-8", "surrogateescape");
2081  obj = myBytesObj;
2082  }
2083 #endif
2084 
2085  // Python added a new buffer interface starting with Python 2.6.
2086 #if PY_VERSION_HEX >= 0x02060000
2087  myUseNewAPI = false;
2088  if (PyObject_CheckBuffer(obj))
2089  {
2090  if (PyObject_GetBuffer(obj, &myPyBuffer, PyBUF_SIMPLE) < 0)
2091  {
2092 #if PY_VERSION_HEX >= 0x03000000
2093  cleanBytesObject_();
2094 #endif
2095  throw HOM_TypeError("failed to get readable buffer");
2096  }
2097 
2098  myUseNewAPI = true;
2099  myData = myPyBuffer.buf;
2100  myLength = myPyBuffer.len;
2101  return;
2102  }
2103 #endif
2104 
2105 #if PY_VERSION_HEX >= 0x03000000
2106  cleanBytesObject_();
2107  throw HOM_TypeError("failed to get readable buffer");
2108 #else
2109  // Either the new API isn't supported in this Python version or the
2110  // Python object doesn't support it. Try the old API.
2111  if (!PyObject_CheckReadBuffer(obj))
2112  throw HOM_TypeError("expected a readable buffer");
2113 
2114  if (PyObject_AsReadBuffer(obj, &myData, &myLength) < 0)
2115  throw HOM_TypeError("failed to get readable buffer");
2116 #endif
2117  }
2118 
2119  ~HOM_PyBuffer()
2120  {
2121 #if PY_VERSION_HEX >= 0x03000000
2122  cleanBytesObject_();
2123 #endif
2124 
2125 #if PY_VERSION_HEX >= 0x02060000
2126  if (myUseNewAPI)
2127  PyBuffer_Release(&myPyBuffer);
2128 #endif
2129  }
2130 
2131 #if PY_VERSION_HEX >= 0x03000000
2132  void cleanBytesObject_()
2133  {
2134  if (!myBytesObj)
2135  return;
2136 
2137  Py_DECREF(myBytesObj);
2138  myBytesObj = nullptr;
2139  }
2140 #endif
2141 
2142 #if PY_VERSION_HEX >= 0x03000000
2143  PyObject *myBytesObj;
2144 #endif
2145 
2146 #if PY_VERSION_HEX >= 0x02060000
2147  bool myUseNewAPI;
2148  Py_buffer myPyBuffer;
2149 #endif
2150  const void *myData;
2151  Py_ssize_t myLength;
2152 };
2153 #endif
2154 
2155 //----------------------------------------------------------------------------
2156 
2157 // These helper functions are used to implement the attrib() methods of
2158 // Points, Prims, and Vertices. We need to do extra work for these methods
2159 // because the return type can vary.
2160 
2161 template <typename T, typename A>
2162 InterpreterObject
2163 HOMattribValue(T &geo_element, A &hom_attrib,
2164  int attr_size,
2165  bool is_array_type,
2166  int array_data_type
2167 )
2168 {
2169  InterpreterObject result = NULL;
2170  const bool scalar = (attr_size == 1 && !is_array_type);
2171  switch (array_data_type)
2172  {
2173  case HOM_attribData::Int_Id:
2174  if (scalar)
2175  result = swig::from(
2176  hboost::any_cast<int64>(geo_element.intAttribValue(hom_attrib)));
2177  else
2178  result = swig::from(
2179  hboost::any_cast<std::vector<int64> >(
2180  geo_element.intListAttribValue(hom_attrib)));
2181  break;
2182 
2183  case HOM_attribData::Float_Id:
2184  if (scalar)
2185  result = SWIG_From_double(geo_element.floatAttribValue(hom_attrib));
2186  else
2187  result = swig::from(geo_element.floatListAttribValue(hom_attrib));
2188  break;
2189 
2190  case HOM_attribData::String_Id:
2191  if (scalar)
2192  result = SWIG_From_std_string(
2193  geo_element.stringAttribValue(hom_attrib));
2194  else
2195  result = swig::from(geo_element.stringListAttribValue(hom_attrib));
2196  break;
2197 
2198  case HOM_attribData::Dict_Id:
2199  if (scalar)
2200  result = swig::from(geo_element.dictAttribValue(hom_attrib));
2201  else
2202  result = swig::from(geo_element.dictListAttribValue(hom_attrib));
2203  break;
2204  }
2205  UT_ASSERT(result);
2206  return result;
2207 }
2208 
2209 template <typename T>
2210 InterpreterObject
2211 HOMattribValue(T &geo_element, HOM_Attrib &hom_attrib)
2212 {
2213  return HOMattribValue(geo_element,
2214  hom_attrib,
2215  hom_attrib.size(),
2216  hom_attrib.isArrayType(),
2217  hom_attrib.dataType().id());
2218 }
2219 
2220 template <typename T>
2221 InterpreterObject
2222 HOMattribValue(T &geo_element, const char *name)
2223 {
2224  int attr_size = 1;
2225  bool is_array_type = false;
2226  int attr_data_type = 0;
2227  geo_element._attribInfo(name,attr_data_type,attr_size,is_array_type);
2228  return HOMattribValue(geo_element,name, attr_size, is_array_type,
2229  attr_data_type);
2230 }
2231 %}
2232 
2233 //----------------------------------------------------------------------------
2234 
2235 %{
2236 // These helper functions are used to implement parm evaluation.
2237 static InterpreterObject
2238 HOMevalParm(HOM_Parm &parm)
2239 {
2240  switch (parm.parmDataTypeEnumId())
2241  {
2242  case HOM_parmData::Int_Id:
2243  return swig::from(hboost::any_cast<int64>(parm.evalAsInt()));
2244  case HOM_parmData::Float_Id:
2245  return SWIG_From_double(parm.evalAsFloat());
2246  case HOM_parmData::String_Id:
2247  return SWIG_From_std_string(parm.evalAsString());
2248  case HOM_parmData::Ramp_Id:
2249  return SWIG_NewPointerObj(
2250  (void*)parm.evalAsRamp(), SWIGTYPE_p_HOM_Ramp, SWIG_POINTER_OWN);
2251  case HOM_parmData::Data_Id:
2252  if (parm.dataParmTypeEnumId() == HOM_dataParmType::KeyValueDictionary_Id)
2253  return swig::from(parm.evalAsJSONMap());
2254 
2255  return SWIG_NewPointerObj(
2256  (void*)parm.evalAsGeometry(), SWIGTYPE_p_HOM_Geometry, SWIG_POINTER_OWN);
2257  }
2258 
2259  UT_ASSERT(!"Unknown parm data type");
2260  return SWIG_Py_Void();
2261 }
2262 
2263 static InterpreterObject
2264 HOMevalParmAtFrame(HOM_Parm &parm, double frame)
2265 {
2266  switch (parm.parmDataTypeEnumId())
2267  {
2268  case HOM_parmData::Int_Id:
2269  return swig::from(hboost::any_cast<int64>(parm.evalAsIntAtFrame(frame)));
2270  case HOM_parmData::Float_Id:
2271  return SWIG_From_double(parm.evalAsFloatAtFrame(frame));
2272  case HOM_parmData::String_Id:
2273  return SWIG_From_std_string(parm.evalAsStringAtFrame(frame));
2274  case HOM_parmData::Ramp_Id:
2275  return SWIG_NewPointerObj(
2276  (void*)parm.evalAsRampAtFrame(frame),
2277  SWIGTYPE_p_HOM_Ramp, SWIG_POINTER_OWN);
2278  case HOM_parmData::Data_Id:
2279  if (parm.dataParmTypeEnumId() == HOM_dataParmType::KeyValueDictionary_Id)
2280  return swig::from(parm.evalAsJSONMapAtFrame(frame));
2281 
2282  return SWIG_NewPointerObj(
2283  (void*)parm.evalAsGeometryAtFrame(frame),
2284  SWIGTYPE_p_HOM_Geometry, SWIG_POINTER_OWN);
2285  }
2286 
2287  UT_ASSERT(!"Unknown parm data type");
2288  return SWIG_Py_Void();
2289 }
2290 
2291 static InterpreterObject
2292 HOMevalParmTuple(HOM_ParmTuple &parm_tuple)
2293 {
2294  switch (parm_tuple.parmDataTypeEnumId())
2295  {
2296  case HOM_parmData::Int_Id:
2297  return swig::from(parm_tuple.evalAsInts());
2298  case HOM_parmData::Float_Id:
2299  return swig::from(parm_tuple.evalAsFloats());
2300  case HOM_parmData::String_Id:
2301  return swig::from(parm_tuple.evalAsStrings());
2302  case HOM_parmData::Ramp_Id:
2303  return swig::from(parm_tuple.evalAsRamps());
2304  case HOM_parmData::Data_Id:
2305  if (parm_tuple.dataParmTypeEnumId()
2306  == HOM_dataParmType::KeyValueDictionary_Id)
2307  {
2308  return swig::from(parm_tuple.evalAsJSONMaps());
2309  }
2310 
2311  return swig::from(parm_tuple.evalAsGeometries());
2312  }
2313 
2314  UT_ASSERT(!"Unknown parm data type");
2315  return SWIG_Py_Void();
2316 }
2317 
2318 static InterpreterObject
2319 HOMevalParmTupleAtFrame(HOM_ParmTuple &parm_tuple, double frame)
2320 {
2321  switch (parm_tuple.parmDataTypeEnumId())
2322  {
2323  case HOM_parmData::Int_Id:
2324  return swig::from(parm_tuple.evalAsIntsAtFrame(frame));
2325  case HOM_parmData::Float_Id:
2326  return swig::from(parm_tuple.evalAsFloatsAtFrame(frame));
2327  case HOM_parmData::String_Id:
2328  return swig::from(parm_tuple.evalAsStringsAtFrame(frame));
2329  case HOM_parmData::Ramp_Id:
2330  return swig::from(parm_tuple.evalAsRampsAtFrame(frame));
2331  case HOM_parmData::Data_Id:
2332  if (parm_tuple.dataParmTypeEnumId()
2333  == HOM_dataParmType::KeyValueDictionary_Id)
2334  {
2335  return swig::from(parm_tuple.evalAsJSONMapsAtFrame(frame));
2336  }
2337 
2338  return swig::from(parm_tuple.evalAsGeometriesAtFrame(frame));
2339  }
2340 
2341  UT_ASSERT(!"Unknown parm data type");
2342  return SWIG_Py_Void();
2343 }
2344 
2345 static InterpreterObject
2346 HOMevalViewportVisualizerParm(HOM_ViewportVisualizer &visualizer, const char *parm_name)
2347 {
2348  switch (visualizer.parmDataTypeEnumId(parm_name))
2349  {
2350  case HOM_parmData::Int_Id:
2351  return swig::from(hboost::any_cast<int64>(visualizer.evalParmAsInt(parm_name)));
2352  case HOM_parmData::Float_Id:
2353  return SWIG_From_double(visualizer.evalParmAsFloat(parm_name));
2354  case HOM_parmData::String_Id:
2355  return SWIG_From_std_string(visualizer.evalParmAsString(parm_name));
2356  case HOM_parmData::Ramp_Id:
2357  return SWIG_NewPointerObj(
2358  (void*)visualizer.evalParmAsRamp(parm_name), SWIGTYPE_p_HOM_Ramp,
2359  SWIG_POINTER_OWN);
2360  }
2361 
2362  UT_ASSERT(!"Unknown parm data type");
2363  return SWIG_Py_Void();
2364 }
2365 
2366 
2367 //----------------------------------------------------------------------------
2368 
2369 %}
2370 #endif
2371 
2372 #endif
UT_Matrix4T< double > UT_DMatrix4
virtual std::vector< HOM_ElemPtr< HOM_Geometry > > evalAsGeometries()=0
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
UT_Matrix3T< double > UT_DMatrix3
virtual std::vector< int > evalAsIntsAtFrame(double frame)=0
virtual int size()=0
virtual std::string evalParmAsString(const char *parm_name)=0
virtual bool isArrayType()=0
void
Definition: png.h:1083
virtual std::vector< HOM_ElemPtr< HOM_Ramp > > evalAsRampsAtFrame(double frame)=0
GLboolean * data
Definition: glcorearb.h:131
hboost::any HOM_UTOptionAny
Definition: HOM_Defines.h:37
void * opaqueObject() const noexcept
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual int parmDataTypeEnumId()=0
virtual double evalAsFloat()=0
virtual int opTypeIdAsInt()=0
virtual std::vector< int > evalAsInts()=0
SYS_FORCE_INLINE const char * buffer() const
GLdouble s
Definition: glad.h:3009
**But if you need a result
Definition: thread.h:622
bool atEnd() const
Definition: UT_Options.h:316
constexpr auto in(type t, int set) -> bool
Definition: core.h:611
__hostdev__ float getValue(uint32_t i) const
Definition: NanoVDB.h:5578
std::optional< T > UT_Optional
Definition: UT_Optional.h:26
virtual HOM_Ramp * evalParmAsRamp(const char *parm_name)=0
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
virtual HOM_Ramp * evalAsRampAtFrame(double frame)=0
virtual std::vector< std::string > evalAsStrings()=0
UT_API std::string UTunmangleClassNameFromTypeIdName(const std::string &name)
GLdouble n
Definition: glcorearb.h:2008
virtual double evalAsFloatAtFrame(double frame)=0
virtual std::vector< std::map< std::string, std::string > > evalAsJSONMaps()=0
virtual int dataParmTypeEnumId()=0
bool any(const vbool4 &v)
Definition: simd.h:3600
virtual std::map< std::string, std::string > evalAsJSONMapAtFrame(double frame)=0
virtual HOM_Geometry * evalAsGeometryAtFrame(double frame)=0
virtual UT_OptionType getType() const
UT_Matrix2T< double > UT_DMatrix2
virtual std::vector< std::map< std::string, std::string > > evalAsJSONMapsAtFrame(double frame)=0
virtual std::map< std::string, std::string > evalAsJSONMap()=0
virtual int64 evalAsInt()=0
UT_Optional< int > HOM_OptionalInt
Definition: HOM_Defines.h:46
OP_OpTypeId
Definition: OP_OpTypeId.h:18
GLuint const GLchar * name
Definition: glcorearb.h:786
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t packed(VULKAN_HPP_NAMESPACE::Format format)
virtual int parmDataTypeEnumId()=0
virtual std::string evalAsStringAtFrame(double frame)=0
virtual std::vector< HOM_ElemPtr< HOM_Geometry > > evalAsGeometriesAtFrame(double frame)=0
virtual std::vector< double > evalAsFloatsAtFrame(double frame)=0
virtual HOM_Ramp * evalAsRamp()=0
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
virtual int dataParmTypeEnumId()=0
hboost::any HOM_DDSourceAny
Definition: HOM_Defines.h:42
iterator begin() const
Definition: UT_Options.h:428
virtual std::vector< double > evalAsFloats()=0
GLsizeiptr size
Definition: glcorearb.h:664
A map of string to various well defined value types.
Definition: UT_Options.h:84
virtual int opTypeIdAsInt()=0
virtual double evalParmAsFloat(const char *parm_name)=0
virtual int parmDataTypeEnumId(const char *parm_name)=0
SYS_FORCE_INLINE const UT_Options * options() const
Definition: UT_Options.h:888
virtual bool isManager(bool include_management_types=true)=0
GLuint GLfloat * val
Definition: glcorearb.h:1608
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
virtual HOM_EnumValue & dataType()=0
OIIO_UTIL_API const char * c_str(string_view str)
int id() const
Definition: HOM_EnumValue.h:82
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
UT_Optional< double > HOM_OptionalDouble
Definition: HOM_Defines.h:45
Adaptors between UT and std classes.
virtual std::vector< HOM_ElemPtr< HOM_Ramp > > evalAsRamps()=0
virtual int evalParmAsInt(const char *parm_name)=0
HOM_API HOM_Module & HOM()
virtual std::vector< std::string > evalAsStringsAtFrame(double frame)=0
virtual std::string evalAsString()=0
virtual int64 evalAsIntAtFrame(double frame)=0
virtual HOM_Geometry * evalAsGeometry()=0