changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Bindings / Python / osgSetupBindings_OSGDrawable.py.in
blobbe51254fda5a38eb48a1e3f539f87d4e9616534d
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 OSGDrawableLib for the integration with the OpenSG CMake system
21 # (GV)
24 from goodies import *
26 import osggen
27 import settings
28 import splitGenHelper
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()],
86 [] ]
88 # ---- Free functions ----- #
90 free_funcs.extend(["calcVertexNormals",
91 "calcVertexNormalsGeo",
92 "calcFaceNormalsGeo",
93 "makePlane",
94 "makePlaneGeo",
95 "makeCone",
96 "makeConeGeo",
97 "makeCylinder",
98 "makeCylinderGeo",
99 "makeConicalFrustum",
100 "makeConicalFrustumGeo",
101 "makeTorus",
102 "makeTorusGeo",
103 "makeSphere",
104 "makeSphereGeo",
105 "makeLatLongSphere",
106 "makeLatLongSphereGeo",
107 "makeBox",
108 "makeBoxGeo",
109 "makeCoordAxis",
110 "makeCoordAxisGeo",
111 "makeTeapot",
112 "makeTeapotGeo"])
116 def excludeFCDSetup(opensg_src_dir, fc_ignore_list, skip_fcds):
118 return
120 cmh_sd_temp = None
121 sdp_temp = None
122 geo_vec_prop_templates = None
123 geo_int_prop_templates = None
125 def genTemplatesSetup(template_builder, tbuilder, non_fc_template_instances):
127 global cmh_sd_temp
128 global sdp_temp
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))
146 return
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)
158 return
161 def postGenClassesSetup(osg, mb):
163 return
167 def postFCDInfoSetup(osg, mb, adddition_exp):
169 # Expose the derived geo prop classes (there are a *lot* of them)
170 print "----- Geo Props -------"
171 # Helper method
172 def expose_geo_prop(temp, base_name):
173 c = temp.decl
174 c.include()
175 osggen.handleClassDefaults(c, True)
176 finalize(c)
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")
192 return