5 import pygccxml
.declarations
6 import pygccxml
.declarations
as pd
10 def exposeTemplateType(templateType
):
12 temp_decl
= templateType
.decl
14 osggen
.exposeTemplateInst (temp_decl
)
15 osggen
.handleClassDefaults(temp_decl
, True)
17 for c
in temp_decl
.constructors():
20 def customizeWindow(osg
, class_name
):
22 c
= osg
.class_(class_name
)
25 c
.add_declaration_code("""
29 void initCallback(bp::object callable)
34 void wrapInit(OSG::%(class_name)s* self, bp::object callable)
36 self->init(boost::bind(initCallback, callable));
39 void defaultInit(OSG::%(class_name)s* self)
45 """ % {'class_name': class_name
})
47 c
.add_registration_code('def("init", defaultInit)')
48 c
.add_registration_code('def("init", wrapInit, bp::arg("oFunc"))')
49 except pygccxml
.declarations
.matcher
.declaration_not_found_t
:
50 print "Skipping init() handling for", class_name
53 def handleFindNamedComponent(osg
, class_name
):
54 c
= osg
.class_(class_name
)
55 c
["findNamedComponent"].call_policies
= \
56 return_value_policy(reference_existing_object
)
58 # c["findNamedComponent"].exclude()
61 # c.add_declaration_code("""
65 #OSG::FieldContainerRecPtr
66 #wrapFindNamedComponent(OSG::%s* self,
67 # const OSG::Char8* szName)
69 # return OSG::FieldContainerTransitPtr(self->findNamedComponent(szName));
75 # c.add_registration_code(
76 # 'def("findNamedComponent", wrapFindNamedComponent, (bp::arg("szName")))'
80 def handlAutoSlotReplace(osg
, cname
):
82 # GCC-XML does not give PyGCCXML enough information to set the default argument correctly
83 # for the use of OSG::State::AutoSlotRepalce as the default value of a method parameter of
84 # type int. We have to help it out.
87 for mname
in ["addChunk", "insertChunk", "subChunk", "find"]:
88 for decl
in c
.decls(mname
, allow_empty
= True):
89 for arg
in decl
.arguments
:
90 if arg
.default_value
== "AutoSlotReplace":
91 # NOTE: Using a string here is the correct behavior. The value of the string is
92 # substituted in the generated code.
93 arg
.default_value
= "OSG::State::AutoSlotReplace"
98 cls
= osg
["ShaderProcVariableBase"]
99 exportable_mems
= cls
.get_exportable_members()
101 if exportable_mems
is None:
103 elif exportable_mems
and type(exportable_mems
[0]) is types
.ListType
:
104 exportable_mems
= exportable_mems
[0]
106 redefined_funcs
= cls
.redefined_funcs()
107 if redefined_funcs
is None:
109 elif redefined_funcs
and type(redefined_funcs
[0]) is types
.ListType
:
110 redefined_funcs
= redefined_funcs
[0]
112 for member
in exportable_mems
+ redefined_funcs
:
113 print "mb : ", member
114 print " ]: ", member
.ignore
115 if hasattr(member
, "virtuality"):
116 print " }:", member
.virtuality
118 print "xxx ", cls
.is_wrapper_needed()
121 cls
= osg
["ShaderValueVariableBase"]
122 exportable_mems
= cls
.get_exportable_members()
124 if exportable_mems
is None:
126 elif exportable_mems
and type(exportable_mems
[0]) is types
.ListType
:
127 exportable_mems
= exportable_mems
[0]
129 redefined_funcs
= cls
.redefined_funcs()
130 if redefined_funcs
is None:
132 elif redefined_funcs
and type(redefined_funcs
[0]) is types
.ListType
:
133 redefined_funcs
= redefined_funcs
[0]
135 for member
in exportable_mems
+ redefined_funcs
:
136 print "mb : ", member
137 print " ]: ", member
.ignore
138 if hasattr(member
, "virtuality"):
139 print " }:", member
.virtuality
141 print "xxx ", cls
.is_wrapper_needed()
143 # print "FOOO ", exportable_mems
144 # print "BAAR ", redefined_funcs
146 cls
= osg
["FieldContainer"]
147 # osggen.excludeMembers(cls, "createAspectCopy", True)
148 cls
["createAspectCopy"].ignore
= True
149 cls
["createAspectCopy"].set_virtuality(pd
.VIRTUALITY_TYPES
.NOT_VIRTUAL
)
150 cls
["createAspectCopy"].already_exposed
= False
152 exportable_mems
= cls
.get_exportable_members()
154 if exportable_mems
is None:
156 elif exportable_mems
and type(exportable_mems
[0]) is types
.ListType
:
157 exportable_mems
= exportable_mems
[0]
159 redefined_funcs
= cls
.redefined_funcs()
160 if redefined_funcs
is None:
162 elif redefined_funcs
and type(redefined_funcs
[0]) is types
.ListType
:
163 redefined_funcs
= redefined_funcs
[0]
165 for member
in exportable_mems
+ redefined_funcs
:
166 print "mb : ", member
167 print " ]: ", member
.ignore
168 if hasattr(member
, "virtuality"):
169 print " }:", member
.virtuality