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