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