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