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