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 OSGDrawableLib for the integration with the OpenSG CMake system
30 def preScanSetup(gen_classes
, fc_infos
, core_mods
, free_funcs
, free_func_mods
, exc_types
):
32 #fc_infos["GeoProperty"] = CoreInfo("GeoProperty", "StateChunk", ["getData"])
36 # Build up list of template methods that we need to instantiate so we can get all of them exposed.
37 gip_tmpl_instances
= \
38 ["template OSG::%s OSG::GeoIntegralProperty::getValue<OSG::%s>(const OSG::SizeT) const" % \
39 (t
, t
) for t
in settings
.geo_integral_types
]
40 gip_tmpl_instances
.extend(
41 ["template void OSG::GeoIntegralProperty::setValue<OSG::%s>(const OSG::%s&, const OSG::SizeT)" % \
42 (t
, t
) for t
in settings
.geo_integral_param_types
]
44 gip_tmpl_instances
.extend(
45 ["template void OSG::GeoIntegralProperty::addValue<OSG::%s>(const OSG::%s&)" % \
46 (t
, t
) for t
in settings
.geo_integral_param_types
]
48 gip_tmpl_instances
.extend(
49 ["template void OSG::GeoIntegralProperty::push_back<OSG::%s>(const OSG::%s&)" % \
50 (t
, t
) for t
in settings
.geo_integral_param_types
]
53 # Expose all the real versions we want
56 # Expose the GeoIntegralProperty class
57 # - The getValue stuff will trigger code that renames the overloaded template methods to use names
58 # sach as getValue_Color3f.
59 # - The tmpl_instances are used to make sure that the compiler sees all the versions of these
60 # overloaded methods that we need.
61 # TODO: Determine if the return value from OSG::GeoIntegralProperty::mapBuffer() could be mapped
62 # into something like a bytearray.
63 gip
= osggen
.FCInfo("GeoIntegralProperty", "GeoProperty",
64 templateMethods
= ["getValue"], templateInstances
= gip_tmpl_instances
,
65 excludeList
= ["mapBuffer"])
66 fc_infos
[gip
.name
] = gip
68 # TODO: Determine if the return value from OSG::GeoIntegralBufferRefProperty::mapBuffer() could
69 # be mapped into something like a bytearray.
70 gibrp
= osggen
.FCInfo("GeoIntegralBufferRefProperty", "GeoIntegralBufferProperty",
71 excludeList
= ["mapBuffer"])
72 fc_infos
[gibrp
.name
] = gibrp
74 # TODO: Determine if the return value from OSG::GeoVectorBufferRefProperty::mapBuffer() could
75 # be mapped into something like a bytearray.
76 gvbrp
= osggen
.FCInfo("GeoVectorBufferRefProperty", "GeoVectorBufferProperty",
77 excludeList
= ["mapBuffer"])
78 fc_infos
[gvbrp
.name
] = gvbrp
81 # Map of core id to callables to call on (class, base) decl
82 core_mods
["Slices"] = [ [lambda c
: c
["Edge"].exclude(),
83 lambda c
: c
["Slice"].exclude(),
84 lambda c
: c
["createSlice"].exclude(),
85 lambda c
: c
["drawSlices"].exclude()],
88 # ---- Free functions ----- #
90 free_funcs
.extend(["calcVertexNormals",
91 "calcVertexNormalsGeo",
100 "makeConicalFrustumGeo",
106 "makeLatLongSphereGeo",
116 def excludeFCDSetup(opensg_src_dir
, fc_ignore_list
, skip_fcds
):
122 geo_vec_prop_templates
= None
123 geo_int_prop_templates
= None
125 def genTemplatesSetup(template_builder
, tbuilder
, non_fc_template_instances
):
129 global geo_vec_prop_templates
130 global geo_int_prop_templates
132 cmh_sd_temp
= tbuilder
.Template("OSG::ContainerMixinHead<OSG::StageDrawableDesc>",
133 "ContainerMixinHeadStageDrawableDesc")
134 sdp_temp
= tbuilder
.Template("OSG::StageDrawableParent", "StageDrawableParent")
137 # Geo vector template types
138 geo_vec_prop_templates
= []
139 for x
in settings
.geo_vec_prop_names
:
140 geo_vec_prop_templates
.append(tbuilder
.Template("OSG::%s"%x, x
))
142 geo_int_prop_templates
= []
143 for x
in settings
.geo_integral_prop_names
:
144 geo_int_prop_templates
.append(tbuilder
.Template("OSG::%s"%x, x
))
150 def postScanSetup(osg
, template_alias_db
):
152 splitGenHelper
.exposeTemplateType(cmh_sd_temp
)
153 # XXX: This should work.
154 #cmh_sd_temp.decl["createAspectCopy"].exclude()
156 splitGenHelper
.exposeTemplateType(sdp_temp
)
161 def postGenClassesSetup(osg
, mb
):
167 def postFCDInfoSetup(osg
, mb
, adddition_exp
):
169 # Expose the derived geo prop classes (there are a *lot* of them)
170 print "----- Geo Props -------"
172 def expose_geo_prop(temp
, base_name
):
175 osggen
.handleClassDefaults(c
, True)
177 osggen
.addFCPtrCode(c
, mb
, c
.name
, base_name
) # Register the fcptr conversions
179 # Exclude some methods that are difficult or impossible to wrap well
180 for p
in ["editFieldPtr", "getFieldPtr", "editField", "mapBuffer"]:
181 c
.decls(p
,allow_empty
=True).exclude()
183 # Just use the base class version of these methods
184 for n
in ["getDimension","getNormalize","clear","resize","size","setValue","push_back","addValue"]:
185 c
.decls(n
,allow_empty
=True).exclude()
187 for temp
in geo_vec_prop_templates
:
188 expose_geo_prop(temp
, "OSG::GeoVectorProperty")
189 for temp
in geo_int_prop_templates
:
190 expose_geo_prop(temp
, "OSG::GeoIntegralProperty")