1 # PyOpenSG is (C) Copyright 2005-2009 by Allen Bierbaum
3 # This file is part of PyOpenSG.
5 # PyOpenSG is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option)
10 # PyOpenSG is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This script is derived from gen_bindings.py, it contains all class specific
20 # tasks for the OSGBaseLib for the integration with the OpenSG CMake system
26 import pygccxml
.declarations
as pd
28 import pyplusplus
.function_transformers
as FT
34 def preScanSetup(gen_classes
, fc_infos
, core_mods
, free_funcs
, free_func_mods
, exc_types
):
36 # Add basic classes that can just be wrapped with no customization
37 #for c in ["Connection",
41 # gen_classes.append(osggen.ClassInfo(c))
43 # For OSG::ExceptionBinaryDataHandler::petValues(), we could set things up
44 # so that the input is a Python list. From there, however, it becomes tricky
45 # because we need to know the data type in the list in order to get the
46 # correct overload of OSG::ExceptionBinaryDataHandler::petValues().
49 osggen
.ClassInfo("ExceptionBinaryDataHandler",
50 excludeList
= ["put", "putAndFree", "putValues", "get",
51 "getAndAlloc", "getValues"]))
53 # Exclude begin, beginCreated, end, endCreated because they return
54 # non-portable iterators.
58 excludeList
= ['begin',
62 policyList
= [("create",
63 return_value_policy(reference_existing_object
))]))
66 def statCollectorCustomizations(klass
):
67 """ Remove all the operators. """
68 cmethods
= klass
.calldefs()
70 if isinstance(m
, operator_t
) and m
.symbol
in ["+", "+="]:
74 osggen
.ClassInfo("StatCollector",
75 excludeList
= ["StatCollector", "getElem", "reset", "getValue"],
76 policyList
= [("create", return_value_policy(reference_existing_object
))],
77 modCallable
= statCollectorCustomizations
)
80 # OSG::Thread is exposed so that we can get access to the change list for a given thread, not so
81 # that Python programmers can spawn OpenSG threads. If it is deemed necessary that Python
82 # programmers be able to do this, then some further special consideration will probably be needed
83 # for this class. In particular, OGS::Thread::runFunction() would need to handle accepting a
84 # Python callable. This may not be so easy, however, as OSG::Thread does not use an instance of
85 # boost::function<T> as the thread callback type.
89 excludeList
= ["runFunction"],
90 policyList
= [("find", return_value_policy(reference_existing_object
)),
91 ("getCurrentChangeList", return_value_policy(reference_existing_object
))]
98 policyList
= [("find", return_value_policy(reference_existing_object
))]
103 # fc's that are custom (not in fcd files)
104 fc_infos
["AttachmentContainer"] = osggen
.FCInfo("AttachmentContainer", "FieldContainer",
106 excludeList
= ["shallowCopy", "shallowCopyLocal",
109 # fc_infos["Attachment"] = osggen.FCInfo("Attachment", "AttachmentContainer", hasBase = True,
110 # excludeList = ["shallowCopy", "shallowCopyLocal",
111 # "createAspectCopy"])
113 # Base class for state chunks and other things
114 #fc_infos["FieldContainerAttachment"] = osggen.FCInfo("FieldContainerAttachment",
115 # "FieldContainer", hasBase = False)
117 fc_infos
["Node"] = osggen
.FCInfo("Node", "AttachmentContainer", hasBase
= False)
119 fc_infos
["NodeCore"] = osggen
.FCInfo("NodeCore", "AttachmentContainer")
121 # ---- Free functions ----- #
123 free_funcs
.extend(["setName",
129 def setUseOverloadMacro(m
):
130 m
.use_overload_macro
= True
132 # gccxml bug causes problems with default arguments on these methods.
133 for m
in ["cloneTree", "deepCloneTree"]:
134 free_func_mods
[m
] = [setUseOverloadMacro
]
136 exc_types
.extend([("SocketException", "IOError"),
137 ("ExceptionBinaryDataHandler::ReadError", "IOError"),
138 ("ExceptionBinaryDataHandler::WriteError", "IOError"),
139 ("Exception", "Exception")])
142 def excludeFCDSetup(opensg_src_dir
, fc_ignore_list
, skip_fcds
):
148 cmh_hcdsd_temp
= None
149 dsm_cmh_hcdsd_temp
= None
158 stat_templates
= None
160 def genTemplatesSetup(template_builder
, tbuilder
, non_fc_template_instances
):
163 global cmh_hcdsd_temp
164 global dsm_cmh_hcdsd_temp
172 global stat_templates
174 # Add the math templates
175 for vst
in settings
.vec_storage_typeinfo
:
176 template_builder
.Template(vst
.type, vst
.alias
)
178 # for svst in settings.select_vec_storage_typeinfo:
179 # template_builder.Template(svst.type, svst.alias)
181 for vt
in settings
.vec_typeinfo
:
182 template_builder
.Template(vt
.type, vt
.alias
)
184 for pt
in settings
.pnt_typeinfo
:
185 template_builder
.Template(pt
.type, pt
.alias
)
188 #for size in settings.pnt_sizes:
189 # for type_str in settings.pnt_types.iteritems():
190 # pnt_temp = tb.Template("OSG::Pnt%s%s"%(size, type_str),
191 # "Pnt%s%s"%(size,type_str))
193 for ct
in settings
.color_typeinfo
:
194 template_builder
.Template(ct
.type, ct
.alias
)
196 mat_temp
= tbuilder
.Template("OSG::Matrix", "Matrix")
197 matd_temp
= tbuilder
.Template("OSG::Matrix4d", "Matrix4d")
198 quat_temp
= tbuilder
.Template("OSG::Quaternion","Quaternion")
199 quatd_temp
= tbuilder
.Template("OSG::Quaterniond","Quaterniond")
201 fcf_temp
= tbuilder
.Template("OSG::FieldContainerFactory","FieldContainerFactory")
204 cmh_hcdsd_temp
= tbuilder
.Template("OSG::ContainerMixinHead<OSG::HardwareContextDataSlotDesc>",
205 "ContainerMixinHardwareContextDataSlotDesc")
206 dsm_cmh_hcdsd_temp
= tbuilder
.Template("OSG::DataSlotMixin<OSG::ContainerMixinHead<OSG::HardwareContextDataSlotDesc> >",
207 "DataSlotMixinContainerMixinHardwareContextDataSlotDesc")
208 hcp_temp
= tbuilder
.Template("OSG::HardwareContextParent", "HardwareContextParent")
210 cf_temp
= tbuilder
.Template("OSG::ConnectionFactory", "ConnectionFactory")
212 pm_temp
= tbuilder
.Template("OSG::PerfMonitor","PerfMonitor")
216 for x
in ["StatIntElem", "StatTimeElem", "StatRealElem", "StatIntOnceElem"]:
217 temp
= tbuilder
.Template("OSG::StatElemDesc<OSG::%s>" % x
,
218 "StatElemDesc_%s" % x
)
219 stat_templates
.append(temp
)
225 def postScanSetup(osg
, template_alias_db
):
227 print "# --------------- Base Memory and Field Types ----------------- #"
230 # - Memory/Type classes
233 tb
["GlobalNamespace"].exclude()
234 osggen
.handleClassDefaults(tb
, True)
235 tb
["getParent"].call_policies
= return_internal_reference()
238 mo
= osg
["MemoryObject"]
241 # Do not let Py++ think that it needs to generate a wrapper for
242 # OSG::MemoryObject to expose the constructor and copy constructor for the
244 for c
in mo
.constructors():
247 # Be sure that OSG::MemoryObject instances cannot be copied. The copy
248 # constructor is protected in the declaration, and this is here just to be
249 # sure that Py++ gets it right.
250 for d
in mo
.declarations
:
255 osggen
.handleClassDefaults(dt
, True)
259 ft
= osg
["FieldType"]
263 #ff = decl_from_typedef( osg["FieldFactory"] )
265 #ff["createField"].call_policies = return_value_policy(manage_new_object)
266 #ff["getFieldType"].call_policies = return_internal_reference()
267 #ff["the"].call_policies = return_value_policy(reference_existing_object)
268 #ff["_fieldTypeM"].exclude()
271 fd
= osg
["FieldDescriptionBase"]
273 for x
in ["_fEditMethod", "_fGetMethod", "_fIndexedGetMethod", "_fIndexedEditMethod"]:
276 for n
in ["getFieldType"]:
277 fd
[n
].call_policies
= return_internal_reference()
279 for n
in ["createConnector", "createField", "clone"]:
280 fd
[n
].call_policies
= return_value_policy(manage_new_object
)
282 rct
= osg
.class_("ReflexiveContainerType") #.finalize()
284 osggen
.handleClassDefaults(rct
, False)
286 fct
= osg
.class_("FieldContainerType") #.finalize()
288 osggen
.handleClassDefaults(fct
, True)
291 ##fct["getParent"].exclude()
292 #fct["addDescription"].exclude()
293 #fct["subDescription"].exclude()
294 #fct["getFieldDesc"].call_policies = return_internal_reference()
295 ##fct["findFieldDescription"].call_policies = return_internal_reference()
297 # FieldContainerFactory and FieldContainerFactoryBase.
299 osggen
.exposeSingleton(fcf
,"FieldContainerFactory")
300 fcf_base
= osg
["FieldContainerFactoryBase"]
302 osggen
.handleClassDefaults(fcf_base
, True)
303 fcf_base
["beginStore"].exclude()
304 fcf_base
["endStore"].exclude()
305 fcf_base
["getFieldContainerStore"].exclude();
308 #for c in [c.related_class for c in fcf_base[0].recursive_bases]:
310 # osggen.handleClassDefaults(c, False)
313 splitGenHelper
.exposeTemplateType(cmh_hcdsd_temp
)
314 splitGenHelper
.exposeTemplateType(dsm_cmh_hcdsd_temp
)
316 splitGenHelper
.exposeTemplateType(hcp_temp
)
317 hcp_temp
.decl
["addDestroyedFunctorFor"].exclude()
320 # OSG::ConnectionFactory
323 osggen
.exposeSingleton(c
, "ConnectionFactory")
324 cf_base
= osg
["ConnectionFactoryBase"]
326 # OSG::ConnectionFactoryBase::dump() is declared but not defined.
327 cf_base
["dump"].exclude()
328 osggen
.handleClassDefaults(cf_base
, True)
331 # Performance monitor
334 # Expose the singleton.
335 osggen
.exposeSingleton(pm
, "PerfMonitor")
336 pm_base
= osg
["PerfMonitorBase"]
338 pm_base
["updateFrame"].add_transformation(osggen
.unlocked_native(), alias
= "updateFrame")
339 pm_base
["mOutFile"].exclude()
342 #osggen.handleClassDefaults(bl_base, False)
343 nsi
= osg
["NestedSampleInfo"]
345 nsi
['string_hash'].exclude()
348 # ----------------- Base Math types --------------- #
349 print "---------------------------------------------------"
350 print "Base Math Type"
353 line
= osg
.class_("Line") #.finalize()
355 line
.noncopyable
= False
359 # Expose the VecStorage classes
360 for vst
in settings
.vec_storage_typeinfo
:
362 type_alias
= vst
.type_str
363 cname
= template_alias_db
[vst
.alias
].declaration
.name
# Look up true class name by alias
364 c
= osg
.class_(cname
)
365 #c.noncopyable = False
367 c
.rename(vst
.exposed_name
)
368 c
["_uiSize"].exclude()
369 wrap_method(c
, "getSeparateValues",
370 "&osgwrap::VecStorage%s_getSeparateValues_tuple<%s>" % (size
, type_alias
))
371 #osggen.addStrOperator(c)
374 # Expose the SelectVecStorage classes. These are included to get the Python class hierarchy to
375 # match the C++ class hierarchy.
376 # for svst in settings.select_vec_storage_typeinfo:
378 # type_alias = svst.type_str
379 # cname = template_alias_db[svst.alias].declaration.name # Look up true class name by alias
380 # c = osg.class_(cname)
382 # c.rename(svst.exposed_name)
383 # exclude_protected(c)
386 for vt
in settings
.vec_typeinfo
:
387 c
= template_alias_db
[vt
.alias
].declaration
.type.declaration
388 c
.noncopyable
= False
390 c
.rename(vt
.exposed_name
)
392 c
["subZero"].call_policies
= return_internal_reference()
393 c
["addToZero"].call_policies
= return_internal_reference()
394 add_member_function(c
,"__setitem__","osgwrap::setArrayElement<%s,%s::ValueType>"%(vt
.type,vt
.type))
395 osggen
.addStrOperator(c
)
399 for pt
in settings
.pnt_typeinfo
:
400 #type_name = template_alias_db[pt.alias].declaration.name
401 c
= template_alias_db
[pt
.alias
].declaration
.type.declaration
403 c
.noncopyable
= False
404 #c = osg.class_(cname)
405 c
.rename(pt
.exposed_name
)
407 c
["subZero"][0].call_policies
= return_internal_reference()
408 #c["addToZero"][0].call_policies = return_internal_reference()
409 wrap_method(c
,"getValues", "osgwrap::getValues%d<%s>"%(pt
.size
,pt
.type))
410 add_member_function(c
,"__setitem__","osgwrap::setArrayElement<%s,%s::ValueType>"%(pt
.type,pt
.type))
411 osggen
.addStrOperator(c
)
415 for ct
in settings
.color_typeinfo
:
416 (size
,type_abrv
) = (ct
.size
,ct
.type_str
)
417 c
= template_alias_db
[ct
.alias
].declaration
.type.declaration
419 c
.rename(ct
.exposed_name
)
421 wrap_method(c
,"getValuesRGB", "Color3_getValuesRGB_tuple<%s>"%type_abrv
)
423 wrap_method(c
,"getValuesRGBA", "Color4_getValuesRGBA_tuple<%s>"%type_abrv
)
424 wrap_method(c
,"getValuesHSV", "Color_getValuesHSV< %s >"%ct
.type)
425 c
.decls("convertToHSV",allow_empty
=True).exclude()
426 add_member_function(c
,"__setitem__","osgwrap::setArrayElement<%s,%s::ValueType>"%(ct
.type,ct
.type))
427 osggen
.addStrOperator(c
)
429 c
.noncopyable
= False
432 #c = template_alias_db["alias_Matrix"].declaration.type.declaration
434 c
.noncopyable
= False
438 # Remove the operator that returns a vector by const reference because it
439 # results in returning a copy.
440 for array_op
in c
['operator[]']:
441 if is_const_ref(array_op
.return_type
):
444 # Does not work for some reason. So we do it manually.
445 #c.member_function(name = 'setValue',
446 # arg_types = [pd.pointer_t(pd.const_t(pd.float_t())), pd.bool_t()]).exclude()
448 for svm
in c
['setValue']:
449 if 2 == len(svm
.arguments
):
450 arg0
= svm
.arguments
[0]
451 if pd
.is_pointer(arg0
._type
) and pd
.is_floating_point(pd
.remove_pointer(arg0
._type
)):
453 c
.add_registration_code('def("setValue", &osgwrap::setValueMatrix<float>, ( bp::arg("pMat"), bp::arg("bTransposed")=(bool)(true) ) )')
455 wrap_method(c
,"getValues", 'osgwrap::getValuesMatrix<float>')
456 wrap_method(c
,"getTransform", 'osgwrap::getTransform_Matrix<float>')
458 # Expose all mult and multLeft variations.
459 matrix_value_types
= ['OSG::Real32', 'OSG::Real64']
460 for right_type
in matrix_value_types
:
461 add_member_function(c
, "mult", "osgwrap::wrapMatrixMult<OSG::Real32, %s>" % right_type
)
462 add_member_function(c
, "multLeft", "osgwrap::wrapMatrixMultLeft<OSG::Real32, %s>" % right_type
)
464 c
["jacobi"].exclude()
465 osggen
.addStrOperator(c
)
470 c
.noncopyable
= False
474 # Remove the operator that returns a vector by const reference because it
475 # results in returning a copy.
476 for array_op
in c
['operator[]']:
477 if is_const_ref(array_op
.return_type
):
480 # Does not work for some reason. So we do it manually.
481 #c.member_function(name='setValue', arg_types = [pd.pointer_t(pd.const_t(pd.float_t())), pd.bool_t()]).exclude()
483 for svm
in c
['setValue']:
484 if 2 == len(svm
.arguments
):
485 arg0
= svm
.arguments
[0]
486 if pd
.is_pointer(arg0
._type
) and pd
.is_floating_point(pd
.remove_pointer(arg0
._type
)):
488 c
.add_registration_code('def("setValue", &osgwrap::setValueMatrix<double>, ( bp::arg("pMat"), bp::arg("bTransposed")=(bool)(true) ) )')
490 wrap_method(c
,"getValues", 'osgwrap::getValuesMatrix<double>')
491 wrap_method(c
,"getTransform", 'osgwrap::getTransform_Matrix<double>')
493 # Expose all mult and multLeft variations.
494 matrix_value_types
= ['OSG::Real32', 'OSG::Real64']
495 for right_type
in matrix_value_types
:
496 add_member_function(c
, "mult", "osgwrap::wrapMatrixMult<OSG::Real64, %s>" % right_type
)
497 add_member_function(c
, "multLeft", "osgwrap::wrapMatrixMultLeft<OSG::Real64, %s>" % right_type
)
499 c
["jacobi"].exclude()
500 osggen
.addStrOperator(c
)
505 c
.noncopyable
= False
508 c
["_uiSize"].exclude()
509 wrap_method(c
,"getValues", 'osgwrap::getValues4<OSG::QuaternionBase<OSG::Real32> >')
510 wrap_method(c
,"getValueAsQuat", 'osgwrap::getValues4<OSG::QuaternionBase<OSG::Real32> >')
511 wrap_method(c
,"getValueAsAxisDeg", 'osgwrap::getValueAsAxisDeg<OSG::Real32>')
512 wrap_method(c
,"getValueAsAxisRad", 'osgwrap::getValueAsAxisRad<OSG::Real32>')
513 add_member_function(c
,"__setitem__","osgwrap::setArrayElement<OSG::Quaternion, OSG::Quaternion::ValueType>")
514 osggen
.addStrOperator(c
)
518 c
.noncopyable
= False
521 c
["_uiSize"].exclude()
522 wrap_method(c
,"getValues", 'osgwrap::getValues4<OSG::QuaternionBase<OSG::Real64> >')
523 wrap_method(c
,"getValueAsQuat", 'osgwrap::getValues4<OSG::QuaternionBase<OSG::Real64> >')
524 wrap_method(c
,"getValueAsAxisDeg", 'osgwrap::getValueAsAxisDeg<OSG::Real64>')
525 wrap_method(c
,"getValueAsAxisRad", 'osgwrap::getValueAsAxisRad<OSG::Real64>')
526 add_member_function(c
,"__setitem__","osgwrap::setArrayElement<OSG::Quaterniond, OSG::Quaterniond::ValueType>")
527 osggen
.addStrOperator(c
)
531 c
= osg
.class_("Plane")
533 c
.noncopyable
= False
534 c
["getNormal"].call_policies
= return_internal_reference(1)
535 # These transformations have to have the alias set explicitly or else Py++
536 # will generate the "ugly" alias form as the name of the Python method.
537 c
["intersect"].add_transformation(FT
.output(1), alias
= "intersect")
538 c
["intersectInfinite"].add_transformation(FT
.output(1),
539 alias
= "intersectInfinite")
543 for vol_name
in ["Volume", "BoxVolume", "CylinderVolume", "FrustumVolume", "PolytopeVolume",
547 osggen
.handleClassDefaults(c
, True)
548 if "Volume" != vol_name
:
550 c
.decls("getPlanes",allow_empty
=True).exclude()
556 def tempLookatPostScanSetup(osg
):
558 # splitGenHelper.exposeTemplateType(cmh_hcdsd_temp)
559 # splitGenHelper.exposeTemplateType(dsm_cmh_hcdsd_temp)
561 # splitGenHelper.exposeTemplateType(hcp_temp)
562 # hcp_temp.decl["addDestroyedFunctorFor"].exclude()
567 def postGenClassesSetup(osg
, mb
):
569 for class_name
in ["Thread", "ExternalThread"]:
570 c
= osg
.class_(class_name
)
571 # NOTE: These non-FC types declare ObjRefPtr instead of ObjRecPtr as their recorded pointer
573 rec_ptr
= "OSG::%s::ObjRefPtr" % class_name
574 c
.held_type
= rec_ptr
575 c
.add_registration_code(
576 "pyopensg::register_transit<OSG::%s, %s>::execute();" % (class_name
, rec_ptr
),
577 works_on_instance
= False
579 c
.add_registration_code(
580 "bp::implicitly_convertible<%s, OSG::%s*>();" % (rec_ptr
, class_name
),
581 works_on_instance
= False
584 c
= osg
.class_("StatCollector")
587 # Expose stat classes
588 sedb
= osg
["StatElemDescBase"]
590 osggen
.handleClassDefaults(sedb
, False)
591 sedb
["findDescByName"].exclude()
594 for t
in stat_templates
:
599 ebdh
= osg
.class_("ExceptionBinaryDataHandler")
601 for f
in ebdh
.member_functions("getValue"):
602 arg_type
= remove_cv(remove_reference(f
.argument_types
[0]))
603 if type(arg_type
) == pd
.cpptypes
.bool_t
:
604 f
.add_transformation(FT
.output(0), alias
= "getBool")
605 elif type(arg_type
) == pd
.cpptypes
.signed_char_t
:
606 f
.add_transformation(FT
.output(0), alias
= "getInt8")
607 elif type(arg_type
) == pd
.cpptypes
.short_int_t
:
608 f
.add_transformation(FT
.output(0), alias
= "getInt16")
609 elif type(arg_type
) == pd
.cpptypes
.int_t
:
610 f
.add_transformation(FT
.output(0), alias
= "getInt32")
611 elif arg_type
.decl_string
== 'OSG::Int64':
612 f
.add_transformation(FT
.output(0), alias
= "getInt64")
613 elif type(arg_type
) == pd
.cpptypes
.float_t
:
614 f
.add_transformation(FT
.output(0), alias
= "getReal32")
615 elif type(arg_type
) == pd
.cpptypes
.double_t
:
616 f
.add_transformation(FT
.output(0), alias
= "getReal64")
617 elif type(arg_type
) == pd
.cpptypes
.long_double_t
:
618 f
.add_transformation(FT
.output(0), alias
= "getReal128")
619 elif (arg_type
.decl_string
== 'std::string' or
620 arg_type
.decl_string
== '::std::string'):
621 f
.add_transformation(FT
.output(0), alias
= "getString")
623 #print "Excluding return type", arg_type.decl_string
626 for f
in ebdh
.member_functions("putValue"):
627 arg_type
= remove_cv(remove_reference(f
.argument_types
[0]))
628 if type(arg_type
) == pd
.cpptypes
.bool_t
:
630 elif type(arg_type
) == pd
.cpptypes
.signed_char_t
:
632 elif type(arg_type
) == pd
.cpptypes
.short_int_t
:
634 elif type(arg_type
) == pd
.cpptypes
.int_t
:
636 elif arg_type
.decl_string
== 'OSG::Int64':
638 elif type(arg_type
) == pd
.cpptypes
.float_t
:
639 f
.alias
= "putReal32"
640 elif type(arg_type
) == pd
.cpptypes
.double_t
:
641 f
.alias
= "putReal64"
642 elif type(arg_type
) == pd
.cpptypes
.long_double_t
:
643 f
.alias
= "putReal128"
644 elif (arg_type
.decl_string
== 'std::string' or
645 arg_type
.decl_string
== '::std::string'):
646 f
.alias
= "putString"
648 #print "Excluding data type", arg_type.decl_string
652 osg
["osgInit"].exclude() # Add wrapper below to code creator
653 osg_exit
= osg
["osgExit"]
656 #add_method(mb,"getRefCount","&osgwrap::ptrGetRefCount")
657 #add_method(mb,"getContainerId","&osgwrap::ptrGetContainerId")
658 add_method(mb
, "osgInit", "&osgwrap::osgInitWrapper")
661 mat_util
= ["MatrixOrthogonal", "MatrixFrustum", "MatrixPerspective",
662 "MatrixStereoPerspective", "MatrixLookAt", "MatrixProjection"]
668 rc
= osg
.class_("ReflexiveContainer")
670 rc
["getClassType"].call_policies
= return_value_policy(reference_existing_object
)
671 for decl
in rc
["getFieldDescription"]:
672 decl
.call_policies
= return_internal_reference()
673 for name
in ["getContainerSize", "changed"]:
675 for decl
in rc
["getType"]:
676 # Having both a const and a non-const version of this method is pointless in Python.
677 if is_const_ref(decl
.return_type
):
680 decl
.call_policies
= return_internal_reference()
682 rc
.variables(allow_empty
= True).exclude()
685 fc
= osg
.class_("FieldContainer")
687 dont_expose
= ["onCreate", "onCreateAspect", "onDestroy", "NextFieldMask", 'isNodeCore',
688 "editSField", "editMField", "getFieldFlags", "deregister", "shallowCopy",
689 "shallowCopyLocal", "createAspectCopy", "getContainerSize"]
690 osggen
.excludeMembers(fc
, dont_expose
)
692 for decl
in fc
["getType"]:
693 # Having both a const and a non-const version of this method is pointless in Python.
694 if is_const_ref(decl
.return_type
):
696 # OSG::ReflexiveContainer::getType() returns OSG::ReflexiveContainerType& while
697 # OSG::FieldContainer::getType() returns OSG::FieldContainerType&. The covariant return type
698 # does not seem to be handled correctly by Py++ (we want the most derived version), so we do
700 elif decl
.return_type
.decl_string
.find("ReflexiveContainerType") != -1:
703 decl
.call_policies
= return_internal_reference()
705 # getClassType() is a static method that returns a reference to an existing
706 # object. Because it is a static method, it cannot use
707 # return_internal_refernce because there is no custodian object.
708 fc
["getClassType"].call_policies
= return_value_policy(reference_existing_object
)
710 fc
.variables(allow_empty
=True).exclude()
712 osggen
.addFCPtrCode(fc
, mb
, "FieldContainer", None)
715 def postFCDInfoSetup(osg
, mb
, adddition_exp
):
717 splitGenHelper
.handleFindNamedComponent(osg
, "FieldContainer")
718 # splitGenHelper.handleFindNamedComponent(osg, "AttachmentContainer")
720 c
= osg
.class_("Node")
721 c
.add_declaration_code("""
725 bp::list getChildren(OSG::Node* node)
729 OSG::UInt32 num_children(node->getNChildren());
730 for ( OSG::UInt32 i = 0; i < num_children; ++i )
732 children.append(OSG::Node::ObjTransitPtr(node->getChild(i)));
740 c
.add_registration_code('add_property("children", getChildren)')
742 c
= osg
.class_("AttachmentContainer")
743 c
["findAttachment"].call_policies
= return_internal_reference()
745 adddition_exp
.extend(["vector<unsigned short>", "vector<float>",
746 "vector<std::string>"])
752 def localUnused(osg
):
753 c
= osg
["Connection"]
755 # c["bind"].exclude()
756 # c["bind"].set_virtuality(pd.VIRTUALITY_TYPES.NOT_VIRTUAL)
758 osggen
.excludeMembers(c
, ["bind"]);
760 c
.add_wrapper_code("""
761 virtual ::std::string bind( ::std::string const & address="" ){
762 bp::override func_bind = this->get_override( "bind" );
763 return func_bind( address ).as<std::string>();
767 c
.add_registration_code("""
768 { //::OSG::Connection::bind
770 typedef ::std::string ( ::OSG::Connection::*bind_function_type )( ::std::string const & ) ;
772 Connection_exposer.def(
774 , bp::pure_virtual( bind_function_type(&::OSG::Connection::bind) )
775 , ( bp::arg("address")="" ) );
781 c
= osg
["GroupConnection"]
783 osggen
.excludeMembers(c
, ["bind"]);
785 # c["bind"].exclude()
787 c
.add_wrapper_code("""
788 virtual ::std::string bind( ::std::string const & address="" ){
789 bp::override func_bind = this->get_override( "bind" );
790 return func_bind( address ).as<std::string>();
794 # c.add_registration_code("""
795 # { //::OSG::Connection::bind
797 # typedef ::std::string ( ::OSG::Connection::*bind_function_type )( ::std::string const & ) ;
799 # GroupConnection_exposer.def(
801 # , bp::pure_virtual( bind_function_type(&::OSG::Connection::bind) )
802 # , ( bp::arg("address")="" ) );
809 c
= osg
["PointConnection"]
811 osggen
.excludeMembers(c
, ["bind"]);
813 # c["bind"].exclude()
815 c
.add_wrapper_code("""
816 virtual ::std::string bind( ::std::string const & address="" ){
817 bp::override func_bind = this->get_override( "bind" );
818 return func_bind( address ).as<std::string>();
822 # c.add_registration_code("""
823 # { //::OSG::Connection::bind
825 # typedef ::std::string ( ::OSG::Connection::*bind_function_type )( ::std::string const & ) ;
827 # PointConnection_exposer.def(
829 # , bp::pure_virtual( bind_function_type(&::OSG::Connection::bind) )
830 # , ( bp::arg("address")="" ) );