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  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
635  };
636 
637  UT_ASSERT(!"Unknown pane tab type");
638  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
639 }
640 
641 template <> InterpreterObject
642 HOMconvertValueForInterpreter<HOM_SopVerb*>(
643  HOM_SopVerb *const &verb, int own)
644 {
645  return SWIG_NewPointerObj(verb, SWIGTYPE_p_HOM_SopVerb, own);
646 }
647 
648 template <> InterpreterObject
649 HOMconvertValueForInterpreter<HOM_Geometry*>(
650  HOM_Geometry *const &geo, int own)
651 {
652  return SWIG_NewPointerObj(geo, SWIGTYPE_p_HOM_Geometry, own);
653 }
654 
655 template <> InterpreterObject
656 HOMconvertValueForInterpreter<HOM_NetworkItem*>(
657  HOM_NetworkItem *const &item, int own)
658 {
659  if (item)
660  {
661  switch (item->networkItemType().id())
662  {
663  case HOM_networkItemType::Node_Id:
664  // We know its a node, but we need to convert to the specific
665  // node type referred to by this item.
666  return HOMconvertValueForInterpreter(
667  dynamic_cast<HOM_Node* const>(item), own);
668 
669  case HOM_networkItemType::NetworkBox_Id:
670  return SWIG_NewPointerObj(
671  (void*)dynamic_cast<const HOM_NetworkBox* const>(item),
672  SWIGTYPE_p_HOM_NetworkBox, own);
673 
674  case HOM_networkItemType::StickyNote_Id:
675  return SWIG_NewPointerObj(
676  (void*)dynamic_cast<const HOM_StickyNote* const>(item),
677  SWIGTYPE_p_HOM_StickyNote, own);
678 
679  case HOM_networkItemType::SubnetIndirectInput_Id:
680  return SWIG_NewPointerObj(
681  (void*)dynamic_cast<const HOM_SubnetIndirectInput* const>(item),
682  SWIGTYPE_p_HOM_SubnetIndirectInput, own);
683 
684  case HOM_networkItemType::Connection_Id:
685  return SWIG_NewPointerObj(
686  (void*)dynamic_cast<const HOM_NodeConnection* const>(item),
687  SWIGTYPE_p_HOM_NodeConnection, own);
688 
689  case HOM_networkItemType::NetworkDot_Id:
690  return SWIG_NewPointerObj(
691  (void*)dynamic_cast<const HOM_NetworkDot* const>(item),
692  SWIGTYPE_p_HOM_NetworkDot, own);
693 
694  default:
695  break;
696  };
697  }
698 
699  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_NetworkItem, own);
700 }
701 
702 template <> InterpreterObject
703 HOMconvertValueForInterpreter<HOM_NetworkMovableItem*>(
704  HOM_NetworkMovableItem *const &item, int own)
705 {
706  if (!item)
707  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_NetworkMovableItem, own);
708 
709  return HOMconvertValueForInterpreter<HOM_NetworkItem *>(item, own);
710 }
711 
712 template <> InterpreterObject
713 HOMconvertValueForInterpreter<
714  std::vector<HOM_ElemPtr<HOM_NodeConnection> >*>(
715  std::vector<HOM_ElemPtr<HOM_NodeConnection> > *const &list,
716  int own)
717 {
718  return swig::from(*list);
719 }
720 
721 template <> InterpreterObject
722 HOMconvertValueForInterpreter<HOM_DopData*>(HOM_DopData *const &data, int own)
723 {
724  const HOM_DopObject *const dop_object =
725  dynamic_cast<const HOM_DopObject *const>(data);
726  if (dop_object)
727  return SWIG_NewPointerObj(
728  (void *)dop_object, SWIGTYPE_p_HOM_DopObject, own);
729 
730  const HOM_DopRelationship *const dop_relationship =
731  dynamic_cast<const HOM_DopRelationship *const>(data);
732  if (dop_relationship)
733  return SWIG_NewPointerObj(
734  (void *)dop_relationship, SWIGTYPE_p_HOM_DopRelationship, own);
735 
736  return SWIG_NewPointerObj(data, SWIGTYPE_p_HOM_DopData, own);
737 }
738 
739 template <> InterpreterObject
740 HOMconvertValueForInterpreter<HOM_RadialItem*>(
741  HOM_RadialItem *const &item, int own)
742 {
743  if (item)
744  {
745  switch (item->type().id())
746  {
747  case HOM_radialItemType::Script_Id:
748  return SWIG_NewPointerObj(
749  (void*)dynamic_cast<const HOM_RadialScriptItem* const>(item),
750  SWIGTYPE_p_HOM_RadialScriptItem, own);
751 
752  case HOM_radialItemType::Submenu_Id:
753  return SWIG_NewPointerObj(
754  (void*)dynamic_cast<const HOM_RadialSubmenu* const>(item),
755  SWIGTYPE_p_HOM_RadialSubmenu, own);
756 
757  case HOM_radialItemType::Menu_Id:
758  return SWIG_NewPointerObj(
759  (void*)dynamic_cast<const HOM_RadialMenu* const>(item),
760  SWIGTYPE_p_HOM_RadialMenu, own);
761 
762  default:
763  break;
764  };
765  }
766 
767  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_RadialItem, own);
768 }
769 
770 // These functions specialize pointers to other classes. If a class is
771 // used inside HOM_IterableList or HOM_ElemPtr, it must be listed here.
772 #define HOM_PROVIDE_SWIG_LOOKUP(type) \
773  template <> InterpreterObject HOMconvertValueForInterpreter<type*>( \
774  type* const& value, int own) \
775  { \
776  return SWIG_NewPointerObj(SWIG_as_voidptr(value), \
777  SWIGTYPE_p_ ## type, own); \
778  }
779 
780 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentClip)
781 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentDefinition)
782 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentLayer)
783 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShape)
784 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShapeBinding)
785 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShapeDeformer)
786 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentTransformGroup)
787 HOM_PROVIDE_SWIG_LOOKUP(HOM_Attrib)
788 HOM_PROVIDE_SWIG_LOOKUP(HOM_AttribDataId)
789 HOM_PROVIDE_SWIG_LOOKUP(HOM_ChannelGraphSelection)
790 HOM_PROVIDE_SWIG_LOOKUP(HOM_Color)
791 HOM_PROVIDE_SWIG_LOOKUP(HOM_Desktop)
792 HOM_PROVIDE_SWIG_LOOKUP(HOM_Dialog)
793 HOM_PROVIDE_SWIG_LOOKUP(HOM_DopRecord)
794 HOM_PROVIDE_SWIG_LOOKUP(HOM_Drawable)
795 HOM_PROVIDE_SWIG_LOOKUP(HOM_EnumValue)
796 HOM_PROVIDE_SWIG_LOOKUP(HOM_FloatingPanel)
797 HOM_PROVIDE_SWIG_LOOKUP(HOM_Gallery)
798 HOM_PROVIDE_SWIG_LOOKUP(HOM_GalleryEntry)
799 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometrySelection)
800 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryViewport)
801 HOM_PROVIDE_SWIG_LOOKUP(HOM_Handle)
802 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryDrawable)
803 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryDrawableGroup)
804 HOM_PROVIDE_SWIG_LOOKUP(HOM_HDADefinition)
805 HOM_PROVIDE_SWIG_LOOKUP(HOM_HDASection)
806 HOM_PROVIDE_SWIG_LOOKUP(HOM_IndexPairPropertyTable)
807 HOM_PROVIDE_SWIG_LOOKUP(HOM_LopInstanceIdRule)
808 HOM_PROVIDE_SWIG_LOOKUP(HOM_LopSelectionRule)
809 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix2)
810 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix3)
811 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix4)
812 HOM_PROVIDE_SWIG_LOOKUP(HOM_NetworkBox)
813 HOM_PROVIDE_SWIG_LOOKUP(HOM_NetworkDot)
814 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeBundle)
815 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeConnection)
816 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeGroup)
817 HOM_PROVIDE_SWIG_LOOKUP(HOM_Pane)
818 HOM_PROVIDE_SWIG_LOOKUP(HOM_Parm)
819 HOM_PROVIDE_SWIG_LOOKUP(HOM_ParmTuple)
820 HOM_PROVIDE_SWIG_LOOKUP(HOM_Point)
821 HOM_PROVIDE_SWIG_LOOKUP(HOM_Polygon)
822 HOM_PROVIDE_SWIG_LOOKUP(HOM_PythonPanelInterface)
823 HOM_PROVIDE_SWIG_LOOKUP(HOM_Edge)
824 HOM_PROVIDE_SWIG_LOOKUP(HOM_PointGroup)
825 HOM_PROVIDE_SWIG_LOOKUP(HOM_PrimGroup)
826 HOM_PROVIDE_SWIG_LOOKUP(HOM_EdgeGroup)
827 HOM_PROVIDE_SWIG_LOOKUP(HOM_VertexGroup)
828 HOM_PROVIDE_SWIG_LOOKUP(HOM_Quaternion)
829 HOM_PROVIDE_SWIG_LOOKUP(HOM_RadialMenu)
830 HOM_PROVIDE_SWIG_LOOKUP(HOM_Ramp)
831 HOM_PROVIDE_SWIG_LOOKUP(HOM_Selection)
832 HOM_PROVIDE_SWIG_LOOKUP(HOM_Selector)
833 HOM_PROVIDE_SWIG_LOOKUP(HOM_Shelf)
834 HOM_PROVIDE_SWIG_LOOKUP(HOM_ShelfSet)
835 HOM_PROVIDE_SWIG_LOOKUP(HOM_SimpleDrawable)
836 HOM_PROVIDE_SWIG_LOOKUP(HOM_StickyNote)
837 HOM_PROVIDE_SWIG_LOOKUP(HOM_SubnetIndirectInput)
838 HOM_PROVIDE_SWIG_LOOKUP(HOM_Take)
839 HOM_PROVIDE_SWIG_LOOKUP(HOM_TextDrawable)
840 HOM_PROVIDE_SWIG_LOOKUP(HOM_Tool)
841 HOM_PROVIDE_SWIG_LOOKUP(HOM_Track)
842 HOM_PROVIDE_SWIG_LOOKUP(HOM_UIEvent)
843 HOM_PROVIDE_SWIG_LOOKUP(HOM_UIEventDevice)
844 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector2)
845 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector3)
846 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector4)
847 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vertex)
848 HOM_PROVIDE_SWIG_LOOKUP(HOM_VexContext)
849 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerState)
850 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateMenu)
851 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateTemplate)
852 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewportVisualizer)
853 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewportVisualizerType)
854 HOM_PROVIDE_SWIG_LOOKUP(HOM_AdvancedDrawable)
855 
856 %}
857 
858 //----------------------------------------------------------------------------
859 
860 // We create typemaps for base classes that appear as return types to make
861 // sure swig instances the proper subclasses in the interpreter.
862 %typemap(out) HOM_Prim* {
863  $result = HOMconvertValueForInterpreter($1, $owner);
864 }
865 
866 %typemap(out) HOM_PackedPrim* {
867  $result = HOMconvertValueForInterpreter($1, $owner);
868 }
869 
870 %typemap(out) HOM_Node* {
871  $result = HOMconvertValueForInterpreter($1, $owner);
872 }
873 
874 %typemap(out) HOM_NodeType* {
875  $result = HOMconvertValueForInterpreter($1, $owner);
876 }
877 
878 %typemap(out) HOM_BaseKeyframe* {
879  $result = HOMconvertValueForInterpreter($1, $owner);
880 }
881 
882 %typemap(out) HOM_ParmTemplate* {
883  $result = HOMconvertValueForInterpreter($1, $owner);
884 }
885 
886 %typemap(out) HOM_Pane* {
887  $result = HOMconvertValueForInterpreter($1, $owner);
888 }
889 
890 %typemap(out) HOM_PaneTab* {
891  $result = HOMconvertValueForInterpreter($1, $owner);
892 }
893 
894 %typemap(out) HOM_DopData* {
895  $result = HOMconvertValueForInterpreter($1, $owner);
896 }
897 
898 %typemap(out) HOM_NetworkMovableItem* {
899  $result = HOMconvertValueForInterpreter($1, $owner);
900 }
901 
902 %typemap(out) HOM_NetworkItem* {
903  $result = HOMconvertValueForInterpreter($1, $owner);
904 }
905 
906 %typemap(out) std::vector<HOM_ElemPtr<HOM_NodeConnection> > * {
907  $result = HOMconvertValueForInterpreter($1, $owner);
908 }
909 
910 //----------------------------------------------------------------------------
911 
912 // These typemaps convert HOM exceptions into corresponding python standard
913 // exceptions.
914 %typemap(throws) HOM_TypeError %{
915  SWIG_exception_fail(SWIG_TypeError, $1.instanceMessage().c_str());
916 %}
917 
918 %typemap(throws) HOM_ValueError %{
919  SWIG_exception_fail(SWIG_ValueError, $1.instanceMessage().c_str());
920 %}
921 
922 #ifdef SWIGPYTHON
923 %typemap(throws) HOM_SystemExit %{
924  PyErr_SetObject(PyExc_SystemExit, SWIG_From_int($1.code()));
925  SWIG_fail;
926 %}
927 #endif
928 
929 //----------------------------------------------------------------------------
930 
931 // This typemap lets you declare a hboost::any parameter and swig will convert
932 // the interpreter (Python) object to a hboost::any that wraps the C++ data
933 // type.
934 %typemap(in) hboost::any {
935  // Note that if we can't convert to a hboost::any, we leave the hboost::any
936  // as empty (i.e. its empty() method returns true).
937  HOMinterpreterObjectToBoostAny($input, $1);
938 }
939 
940 // This typemap lets you declare a HOM_UTOptionAny (hboost::any) parameter and
941 // swig will convert the interpreter (Python) object into the C++ data type
942 // for interpreter objects that correspond to a UT_OptionType.
943 %typemap(in) HOM_UTOptionAny {
944  // Note that if we can't convert to a hboost::any, we leave the hboost::any
945  // as empty (i.e. its empty() method returns true).
946  HOMinterpreterObjectToUTOptionAny($input, $1);
947 }
948 
949 // This typemap lets you return hboost::any objects.
950 %typemap(out) hboost::any {
951  $result = HOMboostAnyToInterpreterObject($1);
952 }
953 
954 %typemap(out) HOM_DDSourceAny {
955  $result = HOMDDSourceAnyToInterpreterObject($1);
956 }
957 
958 //----------------------------------------------------------------------------
959 
960 #ifdef SWIGPYTHON
961 %typemap(out) PY_OpaqueObject {
962  $result = HOMincRef((InterpreterObject)$1.opaqueObject());
963 }
964 #endif
965 
966 // For whatever reason, adding the typemap does not customize swig::from(),
967 // so we do that manually.
968 %{
969 #ifdef SWIGPYTHON
970 namespace swig {
971  template <>
972  struct traits_from<PY_OpaqueObject>
973  {
974  static PyObject *from(const PY_OpaqueObject &val)
975  {
976  return HOMincRef((InterpreterObject)val.opaqueObject());
977  }
978  };
979 }
980 #endif
981 
982 //----------------------------------------------------------------------------
983 
984 // This helper function takes an interpreter (Python) object and converts it
985 // into a hboost::any object. It returns whether or not the conversion was
986 // possible, and leaves the hboost::any unchanged if a conversion wasn't
987 // possible.
988 bool
989 HOMinterpreterObjectToBoostAny(InterpreterObject input, hboost::any &result)
990 {
991 #ifdef SWIGPYTHON
992  if (input == Py_None)
993  {
994  result = (void *)NULL;
995  return true;
996  }
997 
998  // SWIG_AsVal_bool is too permissive, and treats thinks that an integer
999  // is a bool. So, we explicitly check against True and False.
1000  if (input == Py_True)
1001  {
1002  result = true;
1003  return true;
1004  }
1005 
1006  if (input == Py_False)
1007  {
1008  result = false;
1009  return true;
1010  }
1011 #endif
1012 
1013  int int_result;
1014  if (SWIG_IsOK(SWIG_AsVal_int(input, &int_result)))
1015  {
1016  result = int_result;
1017  return true;
1018  }
1019 
1020  double double_result;
1021  if (SWIG_IsOK(SWIG_AsVal_double(input, &double_result)))
1022  {
1023  result = double_result;
1024  return true;
1025  }
1026 
1027  std::string string_result;
1028  if (SWIG_IsOK(SWIG_AsVal_std_string(input, &string_result)))
1029  {
1030  result = string_result;
1031  return true;
1032  }
1033 
1034  void *geometry_result = NULL;
1035  if (SWIG_IsOK(SWIG_ConvertPtr(input, &geometry_result,
1036  SWIGTYPE_p_HOM_Geometry, 0)) && geometry_result)
1037  {
1038  result = reinterpret_cast<HOM_Geometry *>(geometry_result);
1039  return true;
1040  }
1041 
1042  void *ramp_result = NULL;
1043  if (SWIG_IsOK(SWIG_ConvertPtr(input, &ramp_result,
1044  SWIGTYPE_p_HOM_Ramp, 0)) && ramp_result)
1045  {
1046  result = reinterpret_cast<HOM_Ramp *>(ramp_result);
1047  return true;
1048  }
1049 
1050  void *color_result = NULL;
1051  if (SWIG_IsOK(SWIG_ConvertPtr(input, &color_result,
1052  SWIGTYPE_p_HOM_Color, 0)) && color_result)
1053  {
1054  result = reinterpret_cast<HOM_Color *>(color_result);
1055  return true;
1056  }
1057 
1058  void *parm_result = NULL;
1059  if (SWIG_IsOK(SWIG_ConvertPtr(input, &parm_result,
1060  SWIGTYPE_p_HOM_Parm, 0)) && parm_result)
1061  {
1062  result = reinterpret_cast<HOM_Parm *>(parm_result);
1063  return true;
1064  }
1065 
1066  void *enum_result = NULL;
1067  if (SWIG_IsOK(SWIG_ConvertPtr(input, &enum_result,
1068  SWIGTYPE_p_HOM_EnumValue, 0)) && enum_result)
1069  {
1070  result = reinterpret_cast<HOM_EnumValue *>(enum_result);
1071  return true;
1072  }
1073 
1074  void *vec2_result = NULL;
1075  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vec2_result,
1076  SWIGTYPE_p_HOM_Vector2, 0)) && vec2_result)
1077  {
1078  result = reinterpret_cast<HOM_Vector2 *>(vec2_result);
1079  return true;
1080  }
1081 
1082  void *vec3_result = NULL;
1083  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vec3_result,
1084  SWIGTYPE_p_HOM_Vector3, 0)) && vec3_result)
1085  {
1086  result = reinterpret_cast<HOM_Vector3 *>(vec3_result);
1087  return true;
1088  }
1089 
1090  void *vec4_result = NULL;
1091  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vec4_result,
1092  SWIGTYPE_p_HOM_Vector4, 0)) && vec4_result)
1093  {
1094  result = reinterpret_cast<HOM_Vector4 *>(vec4_result);
1095  return true;
1096  }
1097 
1098  std::vector<int> *int_vector_ptr = NULL;
1099  if (SWIG_IsOK(swig::asptr(input, (std::vector<int> **)NULL)) &&
1100  SWIG_IsOK(swig::asptr(input, &int_vector_ptr)))
1101  {
1102  result = *int_vector_ptr;
1103  delete int_vector_ptr;
1104  return true;
1105  }
1106 
1107  std::vector<double> *double_vector_ptr = NULL;
1108  if (SWIG_IsOK(swig::asptr(input, (std::vector<double> **)NULL)) &&
1109  SWIG_IsOK(swig::asptr(input, &double_vector_ptr)))
1110  {
1111  result = *double_vector_ptr;
1112  delete double_vector_ptr;
1113  return true;
1114  }
1115 
1116  std::vector<std::string> *string_vector_ptr = NULL;
1117  if (SWIG_IsOK(swig::asptr(input, (std::vector<std::string> **)NULL)) &&
1118  SWIG_IsOK(swig::asptr(input, &string_vector_ptr)))
1119  {
1120  result = *string_vector_ptr;
1121  delete string_vector_ptr;
1122  return true;
1123  }
1124 
1125  std::vector<HOM_Vector2> *vector2_vector_ptr = NULL;
1126  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector2> **)NULL)) &&
1127  SWIG_IsOK(swig::asptr(input, &vector2_vector_ptr)))
1128  {
1129  result = *vector2_vector_ptr;
1130  delete vector2_vector_ptr;
1131  return true;
1132  }
1133 
1134  std::vector<HOM_Vector3> *vector3_vector_ptr = NULL;
1135  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector3> **)NULL)) &&
1136  SWIG_IsOK(swig::asptr(input, &vector3_vector_ptr)))
1137  {
1138  result = *vector3_vector_ptr;
1139  delete vector3_vector_ptr;
1140  return true;
1141  }
1142 
1143  std::vector<HOM_Vector4> *vector4_vector_ptr = NULL;
1144  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector4> **)NULL)) &&
1145  SWIG_IsOK(swig::asptr(input, &vector4_vector_ptr)))
1146  {
1147  result = *vector4_vector_ptr;
1148  delete vector4_vector_ptr;
1149  return true;
1150  }
1151 
1152  std::vector<HOM_Matrix2> *matrix2_vector_ptr = NULL;
1153  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix2> **)NULL)) &&
1154  SWIG_IsOK(swig::asptr(input, &matrix2_vector_ptr)))
1155  {
1156  result = *matrix2_vector_ptr;
1157  delete matrix2_vector_ptr;
1158  return true;
1159  }
1160 
1161  std::vector<HOM_Matrix3> *matrix3_vector_ptr = NULL;
1162  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix3> **)NULL)) &&
1163  SWIG_IsOK(swig::asptr(input, &matrix3_vector_ptr)))
1164  {
1165  result = *matrix3_vector_ptr;
1166  delete matrix3_vector_ptr;
1167  return true;
1168  }
1169 
1170  std::vector<HOM_Matrix4> *matrix4_vector_ptr = NULL;
1171  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix4> **)NULL)) &&
1172  SWIG_IsOK(swig::asptr(input, &matrix4_vector_ptr)))
1173  {
1174  result = *matrix4_vector_ptr;
1175  delete matrix4_vector_ptr;
1176  return true;
1177  }
1178 
1179  std::vector<std::map<std::string, hboost::any> > *map_vector_ptr = NULL;
1180  if (SWIG_IsOK(swig::asptr(input, (std::vector<std::map<std::string, hboost::any> > **)NULL)) &&
1181  SWIG_IsOK(swig::asptr(input, &map_vector_ptr)))
1182  {
1183  result = *map_vector_ptr;
1184  delete map_vector_ptr;
1185  return true;
1186  }
1187 
1188  UT_ASSERT(result.empty());
1189  return false;
1190 }
1191 
1192 // This helper function takes an interpreter (Python) object and converts it
1193 // into a HOM_UTOptionAny (hboost::any) object. It returns whether or not the
1194 // conversion was possible, and leaves the HOM_UTOptionAny unchanged if a
1195 // conversion wasn't possible.
1196 bool
1197 HOMinterpreterObjectToUTOptionAny(InterpreterObject input,
1198  HOM_UTOptionAny &result)
1199 {
1200 #ifdef SWIGPYTHON
1201  if (input == Py_None)
1202  {
1203  result = (void *)NULL;
1204  return true;
1205  }
1206 
1207  // SWIG_AsVal_bool is too permissive, and treats thinks that an integer
1208  // is a bool. So, we explicitly check against True and False.
1209  if (input == Py_True)
1210  {
1211  result = true;
1212  return true;
1213  }
1214 
1215  if (input == Py_False)
1216  {
1217  result = false;
1218  return true;
1219  }
1220 #endif
1221 
1222  int int_result;
1223  if (SWIG_IsOK(SWIG_AsVal_int(input, &int_result)))
1224  {
1225  result = int_result;
1226  return true;
1227  }
1228 
1229  double double_result;
1230  if (SWIG_IsOK(SWIG_AsVal_double(input, &double_result)))
1231  {
1232  result = double_result;
1233  return true;
1234  }
1235 
1236  std::string string_result;
1237  if (SWIG_IsOK(SWIG_AsVal_std_string(input, &string_result)))
1238  {
1239  result = string_result;
1240  return true;
1241  }
1242 
1243  void *vector2_result = NULL;
1244  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vector2_result,
1245  SWIGTYPE_p_HOM_Vector2, 0)) && vector2_result)
1246  {
1247  result = reinterpret_cast<HOM_Vector2 *>(vector2_result);
1248  return true;
1249  }
1250 
1251  void *vector3_result = NULL;
1252  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vector3_result,
1253  SWIGTYPE_p_HOM_Vector3, 0)) && vector3_result)
1254  {
1255  result = reinterpret_cast<HOM_Vector3 *>(vector3_result);
1256  return true;
1257  }
1258 
1259  void *vector4_result = NULL;
1260  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vector4_result,
1261  SWIGTYPE_p_HOM_Vector4, 0)) && vector4_result)
1262  {
1263  result = reinterpret_cast<HOM_Vector4 *>(vector4_result);
1264  return true;
1265  }
1266 
1267  void *quat_result = NULL;
1268  if (SWIG_IsOK(SWIG_ConvertPtr(input, &quat_result,
1269  SWIGTYPE_p_HOM_Quaternion, 0)) && quat_result)
1270  {
1271  result = reinterpret_cast<HOM_Quaternion *>(quat_result);
1272  return true;
1273  }
1274 
1275  void *matrix2_result = NULL;
1276  if (SWIG_IsOK(SWIG_ConvertPtr(input, &matrix2_result,
1277  SWIGTYPE_p_HOM_Matrix2, 0)) && matrix2_result)
1278  {
1279  result = reinterpret_cast<HOM_Matrix2 *>(matrix2_result);
1280  return true;
1281  }
1282 
1283  void *matrix3_result = NULL;
1284  if (SWIG_IsOK(SWIG_ConvertPtr(input, &matrix3_result,
1285  SWIGTYPE_p_HOM_Matrix3, 0)) && matrix3_result)
1286  {
1287  result = reinterpret_cast<HOM_Matrix3 *>(matrix3_result);
1288  return true;
1289  }
1290 
1291  void *matrix4_result = NULL;
1292  if (SWIG_IsOK(SWIG_ConvertPtr(input, &matrix4_result,
1293  SWIGTYPE_p_HOM_Matrix4, 0)) && matrix4_result)
1294  {
1295  result = reinterpret_cast<HOM_Matrix4 *>(matrix4_result);
1296  return true;
1297  }
1298 
1299  void *geometry_result = NULL;
1300  if (SWIG_IsOK(SWIG_ConvertPtr(input, &geometry_result,
1301  SWIGTYPE_p_HOM_Geometry, 0)) && geometry_result)
1302  {
1303  result = reinterpret_cast<HOM_Geometry *>(geometry_result);
1304  return true;
1305  }
1306 
1307  void *ramp_result = NULL;
1308  if (SWIG_IsOK(SWIG_ConvertPtr(input, &ramp_result,
1309  SWIGTYPE_p_HOM_Ramp, 0)) && ramp_result)
1310  {
1311  result = reinterpret_cast<HOM_Ramp *>(ramp_result);
1312  return true;
1313  }
1314 
1315  std::vector<int> *int_vector_ptr = NULL;
1316  if (SWIG_IsOK(swig::asptr(input, (std::vector<int> **)NULL)) &&
1317  SWIG_IsOK(swig::asptr(input, &int_vector_ptr)))
1318  {
1319  result = *int_vector_ptr;
1320  delete int_vector_ptr;
1321  return true;
1322  }
1323 
1324  std::vector<double> *double_vector_ptr = NULL;
1325  if (SWIG_IsOK(swig::asptr(input, (std::vector<double> **)NULL)) &&
1326  SWIG_IsOK(swig::asptr(input, &double_vector_ptr)))
1327  {
1328  result = *double_vector_ptr;
1329  delete double_vector_ptr;
1330  return true;
1331  }
1332 
1333  std::vector<std::string> *string_vector_ptr = NULL;
1334  if (SWIG_IsOK(swig::asptr(input, (std::vector<std::string> **)NULL)) &&
1335  SWIG_IsOK(swig::asptr(input, &string_vector_ptr)))
1336  {
1337  result = *string_vector_ptr;
1338  delete string_vector_ptr;
1339  return true;
1340  }
1341 
1342  std::vector<HOM_Vector2> *vector2_vector_ptr = NULL;
1343  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector2> **)NULL)) &&
1344  SWIG_IsOK(swig::asptr(input, &vector2_vector_ptr)))
1345  {
1346  result = *vector2_vector_ptr;
1347  delete vector2_vector_ptr;
1348  return true;
1349  }
1350 
1351  std::vector<HOM_Vector3> *vector3_vector_ptr = NULL;
1352  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector3> **)NULL)) &&
1353  SWIG_IsOK(swig::asptr(input, &vector3_vector_ptr)))
1354  {
1355  result = *vector3_vector_ptr;
1356  delete vector3_vector_ptr;
1357  return true;
1358  }
1359 
1360  std::vector<HOM_Vector4> *vector4_vector_ptr = NULL;
1361  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector4> **)NULL)) &&
1362  SWIG_IsOK(swig::asptr(input, &vector4_vector_ptr)))
1363  {
1364  result = *vector4_vector_ptr;
1365  delete vector4_vector_ptr;
1366  return true;
1367  }
1368 
1369  std::vector<HOM_Matrix2> *matrix2_vector_ptr = NULL;
1370  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix2> **)NULL)) &&
1371  SWIG_IsOK(swig::asptr(input, &matrix2_vector_ptr)))
1372  {
1373  result = *matrix2_vector_ptr;
1374  delete matrix2_vector_ptr;
1375  return true;
1376  }
1377 
1378  std::vector<HOM_Matrix3> *matrix3_vector_ptr = NULL;
1379  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix3> **)NULL)) &&
1380  SWIG_IsOK(swig::asptr(input, &matrix3_vector_ptr)))
1381  {
1382  result = *matrix3_vector_ptr;
1383  delete matrix3_vector_ptr;
1384  return true;
1385  }
1386 
1387  std::vector<HOM_Matrix4> *matrix4_vector_ptr = NULL;
1388  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix4> **)NULL)) &&
1389  SWIG_IsOK(swig::asptr(input, &matrix4_vector_ptr)))
1390  {
1391  result = *matrix4_vector_ptr;
1392  delete matrix4_vector_ptr;
1393  return true;
1394  }
1395 
1396  UT_ASSERT(result.empty());
1397  return false;
1398 }
1399 
1400 // Creating an input typemap isn't sufficient to handle input parameters with
1401 // std::vector's or std::map's of hboost::any's, so we need to specialize
1402 // swig::traits_asptr<hboost::any>.
1403 namespace swig {
1404  template <>
1405  struct traits_asptr<hboost::any>
1406  {
1407  static int asptr(InterpreterObject obj, hboost::any **val)
1408  {
1409  // TODO: Will the hboost::any be properly deleted?
1410  hboost::any *p = new hboost::any();
1411  HOMinterpreterObjectToBoostAny(obj, *p);
1412  if (val)
1413  *val = p;
1414  return SWIG_NEWOBJ;
1415  }
1416  };
1417 
1418  template <>
1419  struct traits<std::vector<std::map<std::string, hboost::any> > >
1420  {
1421  typedef pointer_category cateogry;
1422  static const char *type_name() { return "std::vector<std::map<std::string, hboost::any> >"; }
1423  };
1424 }
1425 
1426 // This function is not instantiated until the first use of HOM_BinaryString,
1427 // but we need to use it in HOMboostAnyToInterpreterObject. So just forward
1428 // declare it here.
1429 static PyObject * SWIG_From_HOM_BinaryString(const HOM_BinaryString& s);
1430 
1431 // This helper function takes a variable wrapped inside a hboost::any object
1432 // and creates a new instance of the corresponding InterpreterObject.
1433 static InterpreterObject
1434 HOMboostAnyToInterpreterObject(const hboost::any &result)
1435 {
1436  if (result.empty())
1437  return SWIG_Py_Void();
1438 
1439  if (result.type() == typeid(int))
1440  return SWIG_From_int(hboost::any_cast<int>(result));
1441 
1442  if (result.type() == typeid(long))
1443  return SWIG_From_long(hboost::any_cast<long>(result));
1444 
1445  if (result.type() == typeid(int64))
1446  return swig::from(hboost::any_cast<int64>(result));
1447 
1448  if (result.type() == typeid(float))
1449  return SWIG_From_float(hboost::any_cast<float>(result));
1450 
1451  if (result.type() == typeid(double))
1452  return SWIG_From_double(hboost::any_cast<double>(result));
1453 
1454  if (result.type() == typeid(bool))
1455  return SWIG_From_bool(hboost::any_cast<bool>(result));
1456 
1457  if (result.type() == typeid(std::string))
1458  return SWIG_From_std_string(hboost::any_cast<std::string>(result));
1459 
1460  if (result.type() == typeid(HOM_BinaryString))
1461  return SWIG_From_HOM_BinaryString(hboost::any_cast<HOM_BinaryString>(result));
1462 
1463  if (result.type() == typeid(std::vector<int>))
1464  return swig::from(hboost::any_cast<std::vector<int> >(result));
1465 
1466  if (result.type() == typeid(std::vector<int64>))
1467  return swig::from(hboost::any_cast<std::vector<int64> >(result));
1468 
1469  if (result.type() == typeid(std::vector<float>))
1470  return swig::from(hboost::any_cast<std::vector<float> >(result));
1471 
1472  if (result.type() == typeid(std::vector<std::string>))
1473  return swig::from(hboost::any_cast<std::vector<std::string> >(result));
1474 
1475  if (result.type() == typeid(std::vector<double>))
1476  return swig::from(hboost::any_cast<std::vector<double> >(result));
1477 
1478  if (result.type() == typeid(std::vector<std::vector<float> >))
1479  return swig::from(
1480  hboost::any_cast<std::vector<std::vector<float> > >(result));
1481 
1482  if (result.type() == typeid(std::vector<std::vector<double> >))
1483  return swig::from(
1484  hboost::any_cast<std::vector<std::vector<double> > >(result));
1485 
1486  if (result.type() == typeid(std::vector<std::map<std::string, hboost::any> >))
1487  return swig::from(
1488  hboost::any_cast<std::vector<std::map<std::string, hboost::any> > >(result));
1489 
1490  // If a HOM function returns a pointer to a HOM_Vector*/HOM_Matrix*, it
1491  // will transfer the ownership of that object to swig.
1492  if (result.type() == typeid(HOM_Vector2 *))
1493  return HOMconvertValueForInterpreter(
1494  hboost::any_cast<HOM_Vector2 *>(result), SWIG_POINTER_OWN);
1495 
1496  if (result.type() == typeid(HOM_Vector3 *))
1497  return HOMconvertValueForInterpreter(
1498  hboost::any_cast<HOM_Vector3 *>(result), SWIG_POINTER_OWN);
1499 
1500  if (result.type() == typeid(HOM_Vector4 *))
1501  return HOMconvertValueForInterpreter(
1502  hboost::any_cast<HOM_Vector4 *>(result), SWIG_POINTER_OWN);
1503 
1504  if (result.type() == typeid(HOM_Matrix2 *))
1505  return HOMconvertValueForInterpreter(
1506  hboost::any_cast<HOM_Matrix2 *>(result), SWIG_POINTER_OWN);
1507 
1508  if (result.type() == typeid(HOM_Matrix3 *))
1509  return HOMconvertValueForInterpreter(
1510  hboost::any_cast<HOM_Matrix3 *>(result), SWIG_POINTER_OWN);
1511 
1512  if (result.type() == typeid(HOM_Matrix4 *))
1513  return HOMconvertValueForInterpreter(
1514  hboost::any_cast<HOM_Matrix4 *>(result), SWIG_POINTER_OWN);
1515 
1516  if (result.type() == typeid(HOM_NodeType *))
1517  return HOMconvertValueForInterpreter(
1518  hboost::any_cast<HOM_NodeType *>(result), SWIG_POINTER_OWN);
1519 
1520  if (result.type() == typeid(HOM_Ramp *))
1521  return HOMconvertValueForInterpreter(
1522  hboost::any_cast<HOM_Ramp *>(result), SWIG_POINTER_OWN);
1523 
1524  if (result.type() == typeid(HOM_Color *))
1525  return HOMconvertValueForInterpreter(
1526  hboost::any_cast<HOM_Color *>(result), SWIG_POINTER_OWN);
1527 
1528  if (result.type() == typeid(HOM_Parm *))
1529  return HOMconvertValueForInterpreter(
1530  hboost::any_cast<HOM_Parm *>(result), SWIG_POINTER_OWN);
1531 
1532  if (result.type() == typeid(HOM_EnumValue *))
1533  return HOMconvertValueForInterpreter(
1534  hboost::any_cast<HOM_EnumValue *>(result), SWIG_POINTER_OWN);
1535 
1536  if (result.type() == typeid(HOM_Geometry *))
1537  return HOMconvertValueForInterpreter(
1538  hboost::any_cast<HOM_Geometry *>(result), SWIG_POINTER_OWN);
1539 
1540  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Vector2> >))
1541  return swig::from(
1542  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector2> > >(result));
1543 
1544  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Vector3> >))
1545  return swig::from(
1546  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector3> > >(result));
1547 
1548  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Vector4> >))
1549  return swig::from(
1550  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector4> > >(result));
1551 
1552  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Matrix2> >))
1553  return swig::from(
1554  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix2> > >(result));
1555 
1556  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Matrix3> >))
1557  return swig::from(
1558  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix3> > >(result));
1559 
1560  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Matrix4> >))
1561  return swig::from(
1562  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix4> > >(result));
1563 
1564 #if UT_ASSERT_LEVEL > 0
1565  std::cout << "Unknown data type: "
1566  << UTunmangleClassNameFromTypeIdName(result.type().name()) << "\n";
1567 #endif
1568  UT_ASSERT(!"Unknown data type");
1569  return SWIG_Py_Void();
1570 }
1571 
1572 // This helper function takes a variable wrapped inside a hboost::any object
1573 // and creates a new instance of the corresponding InterpreterObject.
1574 static InterpreterObject
1575 HOMDDSourceAnyToInterpreterObject(const HOM_DDSourceAny &result)
1576 {
1577  if (result.type() == typeid(HOM_Node *))
1578  {
1579  return HOMconvertValueForInterpreter(
1580  hboost::any_cast<HOM_Node *>(result), SWIG_POINTER_OWN);
1581  }
1582  if (result.type() == typeid(HOM_Parm *))
1583  {
1584  return HOMconvertValueForInterpreter(
1585  hboost::any_cast<HOM_Parm *>(result), SWIG_POINTER_OWN);
1586  }
1587  if (result.type() == typeid(HOM_GalleryEntry *))
1588  {
1589  return HOMconvertValueForInterpreter(
1590  hboost::any_cast<HOM_GalleryEntry *>(result), SWIG_POINTER_OWN);
1591  }
1592 
1593  return HOMboostAnyToInterpreterObject(result);
1594 }
1595 
1596 namespace swig {
1597  // Adding the typemap does not customize swig::from() so we do that
1598  // manually.
1599  template <>
1600  struct traits_from<hboost::any>
1601  {
1602  static PyObject *from(const hboost::any &val)
1603  { return HOMboostAnyToInterpreterObject(val); }
1604  };
1605 }
1606 
1607 static InterpreterObject
1608 HOMoptionEntryToInterpreterObject(const UT_OptionEntry &option_entry)
1609 {
1610  // We're usually called from code that has the GIL released so make sure we
1611  // acquire it here.
1612  PY_InterpreterAutoLock py_lock;
1613 
1614  InterpreterObject result = NULL;
1615 
1616  switch (option_entry.getType())
1617  {
1618  case UT_OPTION_INT:
1619  return SWIG_From_int(
1620  ((const UT_OptionInt &)option_entry).getValue());
1621 
1622  case UT_OPTION_BOOL:
1623  return SWIG_From_bool(
1624  ((const UT_OptionBool &)option_entry).getValue());
1625 
1626  case UT_OPTION_FPREAL:
1627  return SWIG_From_double(
1628  ((const UT_OptionFpreal &)option_entry).getValue());
1629 
1630  case UT_OPTION_STRING:
1631  case UT_OPTION_STRINGRAW:
1632  {
1633  return SWIG_From_std_string(
1634  ((const UT_OptionString &)option_entry).getValue().toStdString());
1635  }
1636 
1637  case UT_OPTION_VECTOR2:
1638  return HOMconvertValueForInterpreter(
1639  new HOM_Vector2(
1640  ((const UT_OptionVector2 &)option_entry).getValue()),
1641  SWIG_POINTER_OWN);
1642 
1643  case UT_OPTION_VECTOR3:
1644  return HOMconvertValueForInterpreter(
1645  new HOM_Vector3(
1646  ((const UT_OptionVector3 &)option_entry).getValue()),
1647  SWIG_POINTER_OWN);
1648 
1649  case UT_OPTION_VECTOR4:
1650  return HOMconvertValueForInterpreter(
1651  new HOM_Vector4(
1652  ((const UT_OptionVector4 &)option_entry).getValue()),
1653  SWIG_POINTER_OWN);
1654 
1655  case UT_OPTION_QUATERNION:
1656  return HOMconvertValueForInterpreter(
1657  new HOM_Quaternion(
1658  ((const UT_OptionQuaternion &)option_entry).getValue()),
1659  SWIG_POINTER_OWN);
1660 
1661  case UT_OPTION_MATRIX2:
1662  return HOMconvertValueForInterpreter(
1664  ((const UT_OptionMatrix2 &)option_entry).getValue())),
1665  SWIG_POINTER_OWN);
1666 
1667  case UT_OPTION_MATRIX3:
1668  return HOMconvertValueForInterpreter(
1670  ((const UT_OptionMatrix3 &)option_entry).getValue())),
1671  SWIG_POINTER_OWN);
1672 
1673  case UT_OPTION_MATRIX4:
1674  return HOMconvertValueForInterpreter(
1676  ((const UT_OptionMatrix4 &)option_entry).getValue())),
1677  SWIG_POINTER_OWN);
1678 
1679  case UT_OPTION_UV:
1680  return HOMconvertValueForInterpreter(
1681  new HOM_Vector2(
1682  ((const UT_OptionUV &)option_entry).getValue()),
1683  SWIG_POINTER_OWN);
1684 
1685  case UT_OPTION_UVW:
1686  return HOMconvertValueForInterpreter(
1687  new HOM_Vector3(
1688  ((const UT_OptionUVW &)option_entry).getValue()),
1689  SWIG_POINTER_OWN);
1690 
1691  case UT_OPTION_INTARRAY:
1692  {
1693  std::vector<int64> int_vector;
1694  UTarrayToStdVector(
1695  static_cast<const UT_OptionInt64Array &>(option_entry)
1696  .getValue(), int_vector);
1697  return swig::from(int_vector);
1698  }
1699 
1700  case UT_OPTION_FPREALARRAY:
1701  {
1702  std::vector<double> double_vector;
1703  UTarrayToStdVector(
1704  static_cast<const UT_OptionFpreal64Array &>(option_entry)
1705  .getValue(), double_vector);
1706  return swig::from(double_vector);
1707  }
1708 
1709  case UT_OPTION_STRINGARRAY:
1710  {
1711  std::vector<std::string> str_vector;
1712  UTarrayToStdVectorOfStrings(
1713  static_cast<const UT_OptionStringArray &>(option_entry)
1714  .getValue(), str_vector);
1715  return swig::from(str_vector);
1716  }
1717 
1718  case UT_OPTION_INVALID:
1719  case UT_OPTION_NUM_TYPES:
1720  // Just exit the switch with no result.
1721  break;
1722  }
1723 
1724  return result ? result : SWIG_Py_Void();
1725 }
1726 
1727 #ifdef SWIGPYTHON
1728 static InterpreterObject
1729 HOMoptionsToInterpreterObject(const UT_Options &options)
1730 {
1731  // We're usually called from code that has the GIL released so make sure we
1732  // acquire it here.
1733  PY_InterpreterAutoLock py_lock;
1734 
1735  InterpreterObject result = PyDict_New();
1736 
1737  for (UT_Options::iterator it = options.begin(); !it.atEnd(); ++it)
1738  {
1739  // The Python dictionary object will increment the reference count
1740  // on the value, so we decrement it since we just allocated it.
1741  InterpreterObject value=HOMoptionEntryToInterpreterObject(*it.entry());
1742  PyDict_SetItemString(result, it.name(), value);
1743  Py_DECREF(value);
1744  }
1745 
1746  return result;
1747 }
1748 
1749 static InterpreterObject
1750 HOMoptionsListToInterpreterObject(const std::vector<UT_Options>& options)
1751 {
1752  auto pysize = options.size();
1753 
1754  // We're usually called from code that has the GIL released so make sure we
1755  // acquire it here.
1756  PY_InterpreterAutoLock py_lock;
1757 
1758  InterpreterObject list = PyList_New(pysize);
1759  for (int i = 0; i < pysize; ++i)
1760  {
1761  auto value = HOMoptionsToInterpreterObject(options[i]);
1762  // PyList_SET_ITEM will steal the reference
1763  PyList_SET_ITEM(list, i, value);
1764  }
1765  return list;
1766 }
1767 
1768 #endif
1769 
1770 #ifdef SWIGPYTHON
1771 
1772 // Helper for accessing a HOM object python attributes.
1773 // Used by HDAModule and HDAViewerStateModule.
1774 template<typename T>
1775 PyObject* HOMgetattr(T* hom_object, const char *name)
1776 {
1777  HOM_AutoLock hom_lock;
1778  PY_InterpreterAutoLock py_lock;
1779 
1780  // First check the context's locals dictionary. If the context
1781  // pointer is null we treat it as though the dictionary is empty.
1782  PY_EvaluationContext *context = hom_object->getEvaluationContext();
1783  PyObject *dict = context
1784  ? (PyObject *)context->getGlobalsDict() : NULL;
1785  PyObject *attribute = (dict && name)
1786  ? PyDict_GetItemString(dict, name) : NULL;
1787 
1788  // If the lookup failed, try the globals dictionary.
1789  if (!attribute && dict)
1790  {
1791  dict = (PyObject *)context->getGlobalsDict();
1792  attribute = name ? PyDict_GetItemString(dict, name) : NULL;
1793  }
1794 
1795  // If we found an object in the dictionary, return it, being careful
1796  // to increment the reference count on the object.
1797  if (attribute)
1798  return HOMincRef(attribute);
1799 
1800  // We didn't find the object, so raise an exception.
1801  if (!name)
1802  name = "";
1803  UT_WorkBuffer error_message;
1804  error_message.sprintf("'module' object has no attribute '%s'", name);
1805  PyErr_SetString(PyExc_AttributeError, error_message.buffer());
1806  return NULL;
1807 }
1808 #endif
1809 
1810 //----------------------------------------------------------------------------
1811 
1812 #ifdef SWIGPYTHON
1813 // This helper class takes a Python buffer object and provides access to
1814 // the underlying C buffer. Note that the class is only used inside the
1815 // swig file, so it doesn't need to be exported from the current library.
1816 class HOM_PyBuffer
1817 {
1818 public:
1819  HOM_PyBuffer(InterpreterObject py_object)
1820  {
1821  myData = NULL;
1822  myLength = 0;
1823 
1824  // Python added a new buffer interface starting with Python 2.6.
1825 #if PY_VERSION_HEX >= 0x02060000
1826  myUseNewAPI = false;
1827  if (PyObject_CheckBuffer(py_object))
1828  {
1829  if (PyObject_GetBuffer(py_object, &myPyBuffer, PyBUF_SIMPLE) < 0)
1830  throw HOM_TypeError("failed to get readable buffer");
1831 
1832  myUseNewAPI = true;
1833  myData = myPyBuffer.buf;
1834  myLength = myPyBuffer.len;
1835  return;
1836  }
1837 #endif
1838 
1839 #if PY_VERSION_HEX >= 0x03000000
1840  throw HOM_TypeError("failed to get readable buffer");
1841 #else
1842  // Either the new API isn't supported in this Python version or the
1843  // Python object doesn't support it. Try the old API.
1844  if (!PyObject_CheckReadBuffer(py_object))
1845  throw HOM_TypeError("expected a readable buffer");
1846 
1847  if (PyObject_AsReadBuffer(py_object, &myData, &myLength) < 0)
1848  throw HOM_TypeError("failed to get readable buffer");
1849 #endif
1850  }
1851 
1852  ~HOM_PyBuffer()
1853  {
1854 #if PY_VERSION_HEX >= 0x02060000
1855  if (myUseNewAPI)
1856  PyBuffer_Release(&myPyBuffer);
1857 #endif
1858  }
1859 
1860 #if PY_VERSION_HEX >= 0x02060000
1861  bool myUseNewAPI;
1862  Py_buffer myPyBuffer;
1863 #endif
1864  const void *myData;
1865  Py_ssize_t myLength;
1866 };
1867 #endif
1868 
1869 //----------------------------------------------------------------------------
1870 
1871 // These helper functions are used to implement the attrib() methods of
1872 // Points, Prims, and Vertices. We need to do extra work for these methods
1873 // because the return type can vary.
1874 template <typename T>
1875 InterpreterObject
1876 HOMattribValue(T &geo_element, HOM_Attrib &hom_attrib)
1877 {
1878  InterpreterObject result = NULL;
1879  switch (hom_attrib.dataType().id())
1880  {
1881  case HOM_attribData::Int_Id:
1882  if (hom_attrib.size() == 1)
1883  result = swig::from(
1884  hboost::any_cast<int64>(geo_element.intAttribValue(hom_attrib)));
1885  else
1886  result = swig::from(
1887  hboost::any_cast<std::vector<int64> >(
1888  geo_element.intListAttribValue(hom_attrib)));
1889  break;
1890 
1891  case HOM_attribData::Float_Id:
1892  if (hom_attrib.size() == 1)
1893  result = SWIG_From_double(geo_element.floatAttribValue(hom_attrib));
1894  else
1895  result = swig::from(geo_element.floatListAttribValue(hom_attrib));
1896  break;
1897 
1898  case HOM_attribData::String_Id:
1899  if (hom_attrib.size() == 1)
1900  result = SWIG_From_std_string(
1901  geo_element.stringAttribValue(hom_attrib));
1902  else
1903  result = swig::from(geo_element.stringListAttribValue(hom_attrib));
1904  break;
1905  }
1906  UT_ASSERT(result);
1907  return result;
1908 }
1909 
1910 
1911 // Note that the caller is responsible for deleting the HOM_Attrib object
1912 // that's returned.
1913 template <typename T> HOM_Attrib*
1914 HOMlookUpAttrib(T &geo_element, const char *name);
1915 
1916 template <> HOM_Attrib*
1917 HOMlookUpAttrib(HOM_Point &point, const char *name)
1918 { return HOMdel(point.geometry())->findPointAttrib(name); }
1919 
1920 template <> HOM_Attrib*
1921 HOMlookUpAttrib(HOM_Prim &prim, const char *name)
1922 { return HOMdel(prim.geometry())->findPrimAttrib(name); }
1923 
1924 template <> HOM_Attrib*
1925 HOMlookUpAttrib(HOM_Vertex &vertex, const char *name)
1926 { return HOMdel(vertex.geometry())->findVertexAttrib(name); }
1927 
1928 template <> HOM_Attrib*
1929 HOMlookUpAttrib(HOM_Geometry &geometry, const char *name)
1930 { return geometry.findGlobalAttrib(name); }
1931 
1932 template <typename T>
1933 InterpreterObject
1934 HOMattribValue(T &geo_element, const char *name)
1935 {
1936  HOM_Attrib *hom_attrib = HOMlookUpAttrib(geo_element, name);
1937  if (!hom_attrib)
1938  throw HOM_OperationFailed();
1939 
1940  InterpreterObject result = HOMattribValue(geo_element, *hom_attrib);
1941  delete hom_attrib;
1942  return result;
1943 }
1944 %}
1945 
1946 //----------------------------------------------------------------------------
1947 
1948 %{
1949 // These helper functions are used to implement parm evaluation.
1950 static InterpreterObject
1951 HOMevalParm(HOM_Parm &parm)
1952 {
1953  switch (parm.parmDataTypeEnumId())
1954  {
1955  case HOM_parmData::Int_Id:
1956  return SWIG_From_int(parm.evalAsInt());
1957  case HOM_parmData::Float_Id:
1958  return SWIG_From_double(parm.evalAsFloat());
1959  case HOM_parmData::String_Id:
1960  return SWIG_From_std_string(parm.evalAsString());
1961  case HOM_parmData::Ramp_Id:
1962  return SWIG_NewPointerObj(
1963  (void*)parm.evalAsRamp(), SWIGTYPE_p_HOM_Ramp, SWIG_POINTER_OWN);
1964  case HOM_parmData::Data_Id:
1965  if (parm.dataParmTypeEnumId() == HOM_dataParmType::KeyValueDictionary_Id)
1966  return swig::from(parm.evalAsJSONMap());
1967 
1968  return SWIG_NewPointerObj(
1969  (void*)parm.evalAsGeometry(), SWIGTYPE_p_HOM_Geometry, SWIG_POINTER_OWN);
1970  }
1971 
1972  UT_ASSERT(!"Unknown parm data type");
1973  return SWIG_Py_Void();
1974 }
1975 
1976 static InterpreterObject
1977 HOMevalParmAtFrame(HOM_Parm &parm, double frame)
1978 {
1979  switch (parm.parmDataTypeEnumId())
1980  {
1981  case HOM_parmData::Int_Id:
1982  return SWIG_From_int(parm.evalAsIntAtFrame(frame));
1983  case HOM_parmData::Float_Id:
1984  return SWIG_From_double(parm.evalAsFloatAtFrame(frame));
1985  case HOM_parmData::String_Id:
1986  return SWIG_From_std_string(parm.evalAsStringAtFrame(frame));
1987  case HOM_parmData::Ramp_Id:
1988  return SWIG_NewPointerObj(
1989  (void*)parm.evalAsRampAtFrame(frame),
1990  SWIGTYPE_p_HOM_Ramp, SWIG_POINTER_OWN);
1991  case HOM_parmData::Data_Id:
1992  if (parm.dataParmTypeEnumId() == HOM_dataParmType::KeyValueDictionary_Id)
1993  return swig::from(parm.evalAsJSONMapAtFrame(frame));
1994 
1995  return SWIG_NewPointerObj(
1996  (void*)parm.evalAsGeometryAtFrame(frame),
1997  SWIGTYPE_p_HOM_Geometry, SWIG_POINTER_OWN);
1998  }
1999 
2000  UT_ASSERT(!"Unknown parm data type");
2001  return SWIG_Py_Void();
2002 }
2003 
2004 static InterpreterObject
2005 HOMevalParmTuple(HOM_ParmTuple &parm_tuple)
2006 {
2007  switch (parm_tuple.parmDataTypeEnumId())
2008  {
2009  case HOM_parmData::Int_Id:
2010  return swig::from(parm_tuple.evalAsInts());
2011  case HOM_parmData::Float_Id:
2012  return swig::from(parm_tuple.evalAsFloats());
2013  case HOM_parmData::String_Id:
2014  return swig::from(parm_tuple.evalAsStrings());
2015  case HOM_parmData::Ramp_Id:
2016  return swig::from(parm_tuple.evalAsRamps());
2017  case HOM_parmData::Data_Id:
2018  return swig::from(parm_tuple.evalAsGeometries());
2019  }
2020 
2021  UT_ASSERT(!"Unknown parm data type");
2022  return SWIG_Py_Void();
2023 }
2024 
2025 static InterpreterObject
2026 HOMevalParmTupleAtFrame(HOM_ParmTuple &parm_tuple, double frame)
2027 {
2028  switch (parm_tuple.parmDataTypeEnumId())
2029  {
2030  case HOM_parmData::Int_Id:
2031  return swig::from(parm_tuple.evalAsIntsAtFrame(frame));
2032  case HOM_parmData::Float_Id:
2033  return swig::from(parm_tuple.evalAsFloatsAtFrame(frame));
2034  case HOM_parmData::String_Id:
2035  return swig::from(parm_tuple.evalAsStringsAtFrame(frame));
2036  case HOM_parmData::Ramp_Id:
2037  return swig::from(parm_tuple.evalAsRampsAtFrame(frame));
2038  case HOM_parmData::Data_Id:
2039  return swig::from(parm_tuple.evalAsGeometriesAtFrame(frame));
2040  }
2041 
2042  UT_ASSERT(!"Unknown parm data type");
2043  return SWIG_Py_Void();
2044 }
2045 
2046 static InterpreterObject
2047 HOMevalViewportVisualizerParm(HOM_ViewportVisualizer &visualizer, const char *parm_name)
2048 {
2049  switch (visualizer.parmDataTypeEnumId(parm_name))
2050  {
2051  case HOM_parmData::Int_Id:
2052  return SWIG_From_int(visualizer.evalParmAsInt(parm_name));
2053  case HOM_parmData::Float_Id:
2054  return SWIG_From_double(visualizer.evalParmAsFloat(parm_name));
2055  case HOM_parmData::String_Id:
2056  return SWIG_From_std_string(visualizer.evalParmAsString(parm_name));
2057  case HOM_parmData::Ramp_Id:
2058  return SWIG_NewPointerObj(
2059  (void*)visualizer.evalParmAsRamp(parm_name), SWIGTYPE_p_HOM_Ramp,
2060  SWIG_POINTER_OWN);
2061  }
2062 
2063  UT_ASSERT(!"Unknown parm data type");
2064  return SWIG_Py_Void();
2065 }
2066 
2067 
2068 //----------------------------------------------------------------------------
2069 
2070 %}
2071 #endif
2072 
2073 #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:1020
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