added: travMask to csm viewport
[opensg.git] / Source / Base / Bindings / Python / osgSetupBindings_OSGBase.py.in
blobbc98006b03534c73e238bd2ce5b02f357ede5daa
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)
8 # any later version.
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
13 # more details.
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
21 # (GV)
24 from goodies import *
26 import pygccxml.declarations as pd
28 import pyplusplus.function_transformers as FT
30 import osggen
31 import settings
32 import splitGenHelper
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",
38 # "PointConnection",
39 # "GroupConnection",
40 # "ConnectionType"]:
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().
48 gen_classes.append(
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.
55 gen_classes.append(
56 osggen.ClassInfo(
57 "ChangeList",
58 excludeList = ['begin',
59 'beginCreated',
60 'end',
61 'endCreated'],
62 policyList = [("create",
63 return_value_policy(reference_existing_object))]))
66 def statCollectorCustomizations(klass):
67 """ Remove all the operators. """
68 cmethods = klass.calldefs()
69 for m in cmethods:
70 if isinstance(m, operator_t) and m.symbol in ["+", "+="]:
71 m.exclude()
73 gen_classes.append(
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.
86 gen_classes.append(
87 osggen.ClassInfo(
88 "Thread",
89 excludeList = ["runFunction"],
90 policyList = [("find", return_value_policy(reference_existing_object)),
91 ("getCurrentChangeList", return_value_policy(reference_existing_object))]
95 gen_classes.append(
96 osggen.ClassInfo(
97 "ExternalThread",
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",
105 hasBase = False,
106 excludeList = ["shallowCopy", "shallowCopyLocal",
107 "createAspectCopy"])
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",
124 "getName",
125 "cloneTree",
126 "deepCloneTree",
127 "commitChanges"])
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):
144 return
147 fcf_temp = None
148 cmh_hcdsd_temp = None
149 dsm_cmh_hcdsd_temp = None
150 hcp_temp = None
151 cf_temp = None
152 pm_temp = None
154 mat_temp = None
155 matd_temp = None
156 quat_temp = None
157 quatd_temp = None
158 stat_templates = None
160 def genTemplatesSetup(template_builder, tbuilder, non_fc_template_instances):
162 global fcf_temp
163 global cmh_hcdsd_temp
164 global dsm_cmh_hcdsd_temp
165 global hcp_temp
166 global cf_temp
167 global pm_temp
168 global mat_temp
169 global matd_temp
170 global quat_temp
171 global quatd_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)
187 #pnt_templates = []
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")
215 stat_templates = []
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)
221 return
225 def postScanSetup(osg, template_alias_db):
227 print "# --------------- Base Memory and Field Types ----------------- #"
229 # Expose classes
230 # - Memory/Type classes
231 tb = osg["TypeBase"]
232 tb.include()
233 tb["GlobalNamespace"].exclude()
234 osggen.handleClassDefaults(tb, True)
235 tb["getParent"].call_policies = return_internal_reference()
236 finalize(tb)
238 mo = osg["MemoryObject"]
239 mo.include()
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
243 # class.
244 for c in mo.constructors():
245 c.exclude()
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:
251 d.noncopyable = True
253 dt = osg["DataType"]
254 dt.include()
255 osggen.handleClassDefaults(dt, True)
256 finalize(dt)
258 # - Field classes
259 ft = osg["FieldType"]
260 ft.include()
261 finalize(ft)
263 #ff = decl_from_typedef( osg["FieldFactory"] )
264 #ff.include()
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()
269 #finalize(ff)
271 fd = osg["FieldDescriptionBase"]
272 fd.include()
273 for x in ["_fEditMethod", "_fGetMethod", "_fIndexedGetMethod", "_fIndexedEditMethod"]:
274 fd[x].exclude()
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()
283 rct.include()
284 osggen.handleClassDefaults(rct, False)
286 fct = osg.class_("FieldContainerType") #.finalize()
287 fct.include()
288 osggen.handleClassDefaults(fct, True)
289 finalize(fct)
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.
298 fcf = fcf_temp.decl
299 osggen.exposeSingleton(fcf,"FieldContainerFactory")
300 fcf_base = osg["FieldContainerFactoryBase"]
301 fcf_base.include()
302 osggen.handleClassDefaults(fcf_base, True)
303 fcf_base["beginStore"].exclude()
304 fcf_base["endStore"].exclude()
305 fcf_base["getFieldContainerStore"].exclude();
306 finalize(fcf_base)
308 #for c in [c.related_class for c in fcf_base[0].recursive_bases]:
309 # c.include()
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
321 c = cf_temp.decl
322 c.include()
323 osggen.exposeSingleton(c, "ConnectionFactory")
324 cf_base = osg["ConnectionFactoryBase"]
325 cf_base.include()
326 # OSG::ConnectionFactoryBase::dump() is declared but not defined.
327 cf_base["dump"].exclude()
328 osggen.handleClassDefaults(cf_base, True)
329 finalize(cf_base)
331 # Performance monitor
332 pm = pm_temp.decl
333 pm.include()
334 # Expose the singleton.
335 osggen.exposeSingleton(pm, "PerfMonitor")
336 pm_base = osg["PerfMonitorBase"]
337 pm_base.include()
338 pm_base["updateFrame"].add_transformation(osggen.unlocked_native(), alias = "updateFrame")
339 pm_base["mOutFile"].exclude()
340 finalize(pm_base)
342 #osggen.handleClassDefaults(bl_base, False)
343 nsi = osg["NestedSampleInfo"]
344 nsi.include()
345 nsi['string_hash'].exclude()
346 finalize(nsi)
348 # ----------------- Base Math types --------------- #
349 print "---------------------------------------------------"
350 print "Base Math Type"
352 # Expose classes
353 line = osg.class_("Line") #.finalize()
354 line.include()
355 line.noncopyable = False
356 finalize(line)
359 # Expose the VecStorage classes
360 for vst in settings.vec_storage_typeinfo:
361 size = vst.size
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
366 c.include()
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)
372 exclude_protected(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:
377 # size = svst.size
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)
381 # c.include()
382 # c.rename(svst.exposed_name)
383 # exclude_protected(c)
385 # VecXX classes
386 for vt in settings.vec_typeinfo:
387 c = template_alias_db[vt.alias].declaration.type.declaration
388 c.noncopyable = False
389 c.include()
390 c.rename(vt.exposed_name)
391 c["Null"].exclude()
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)
396 exclude_protected(c)
398 # PntXX classes
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
402 c.include()
403 c.noncopyable = False
404 #c = osg.class_(cname)
405 c.rename(pt.exposed_name)
406 c["Null"].exclude()
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)
412 exclude_protected(c)
414 # ColorXX classes
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
418 c.include()
419 c.rename(ct.exposed_name)
420 if 3 == size:
421 wrap_method(c,"getValuesRGB", "Color3_getValuesRGB_tuple<%s>"%type_abrv)
422 else:
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)
428 exclude_protected(c)
429 c.noncopyable = False
431 # Matrix
432 #c = template_alias_db["alias_Matrix"].declaration.type.declaration
433 c = mat_temp.decl
434 c.noncopyable = False
435 c.include()
436 finalize(c)
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):
442 array_op.exclude()
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)):
452 svm.exclude()
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)
466 exclude_protected(c)
468 # Expose Matrix4d
469 c = matd_temp.decl
470 c.noncopyable = False
471 c.include()
472 finalize(c)
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):
478 array_op.exclude()
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)):
487 svm.exclude()
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)
501 exclude_protected(c)
503 # Quaternion
504 c = quat_temp.decl
505 c.noncopyable = False
506 c.include()
507 finalize(c)
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)
515 exclude_protected(c)
517 c = quatd_temp.decl
518 c.noncopyable = False
519 c.include()
520 finalize(c)
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)
528 exclude_protected(c)
530 # Plane
531 c = osg.class_("Plane")
532 c.include()
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")
540 exclude_protected(c)
543 for vol_name in ["Volume", "BoxVolume", "CylinderVolume", "FrustumVolume", "PolytopeVolume",
544 "SphereVolume"]:
545 c = osg[vol_name][0]
546 c.include()
547 osggen.handleClassDefaults(c, True)
548 if "Volume" != vol_name:
549 finalize(c)
550 c.decls("getPlanes",allow_empty=True).exclude()
551 exclude_protected(c)
553 return
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()
564 return
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
572 # type. Argh.
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")
585 c.noncopyable = True
587 # Expose stat classes
588 sedb = osg["StatElemDescBase"]
589 sedb.include()
590 osggen.handleClassDefaults(sedb, False)
591 sedb["findDescByName"].exclude()
592 #finalize(sedb)
594 for t in stat_templates:
595 c = t.decl
596 c.include()
597 finalize(c)
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")
622 else:
623 #print "Excluding return type", arg_type.decl_string
624 f.exclude()
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:
629 f.alias = "putBool"
630 elif type(arg_type) == pd.cpptypes.signed_char_t:
631 f.alias = "putInt8"
632 elif type(arg_type) == pd.cpptypes.short_int_t:
633 f.alias = "putInt16"
634 elif type(arg_type) == pd.cpptypes.int_t:
635 f.alias = "putInt32"
636 elif arg_type.decl_string == 'OSG::Int64':
637 f.alias = "putInt64"
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"
647 else:
648 #print "Excluding data type", arg_type.decl_string
649 f.exclude()
651 # Base methods
652 osg["osgInit"].exclude() # Add wrapper below to code creator
653 osg_exit = osg["osgExit"]
654 osg_exit.include()
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"]
663 for f in mat_util:
664 decl = osg[f]
665 decl.include()
668 rc = osg.class_("ReflexiveContainer")
669 rc.include()
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"]:
674 rc[name].exclude()
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):
678 decl.exclude()
679 else:
680 decl.call_policies = return_internal_reference()
682 rc.variables(allow_empty = True).exclude()
683 finalize(rc)
685 fc = osg.class_("FieldContainer")
686 fc.include()
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):
695 decl.exclude()
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
699 # it manually here.
700 elif decl.return_type.decl_string.find("ReflexiveContainerType") != -1:
701 decl.exclude()
702 else:
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()
711 finalize(fc)
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("""
722 namespace
725 bp::list getChildren(OSG::Node* node)
727 bp::list children;
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)));
735 return children;
739 """)
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>"])
750 return
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>();
765 """)
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(
773 "bind"
774 , bp::pure_virtual( bind_function_type(&::OSG::Connection::bind) )
775 , ( bp::arg("address")="" ) );
778 """, False)
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>();
792 """)
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(
800 # "bind"
801 # , bp::pure_virtual( bind_function_type(&::OSG::Connection::bind) )
802 # , ( bp::arg("address")="" ) );
805 #""", False)
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>();
820 """)
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(
828 # "bind"
829 # , bp::pure_virtual( bind_function_type(&::OSG::Connection::bind) )
830 # , ( bp::arg("address")="" ) );
833 #""", False)
836 return