]> git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/scripts/swig_tools.py
Add IEEE 754 single/double precision support to wxDataStream classes.
[wxWidgets.git] / docs / doxygen / scripts / swig_tools.py
1 import os
2
3 from common import *
4
5 class SWIGBuilder:
6 def __init__(self, doxyparse, outputdir):
7 self.doxyparser = doxyparse
8 self.output_dir = outputdir
9
10 def make_bindings(self):
11 output_dir = os.path.abspath(os.path.join(self.output_dir, "swig"))
12 if not os.path.exists(output_dir):
13 os.makedirs(output_dir)
14
15 for aclass in self.doxyparser.classes:
16 header_name = aclass.name[2:].lower()
17 if aclass.name in excluded_classes:
18 #print "Skipping %s" % aclass.name
19 continue
20
21 filename = os.path.join(output_dir, "_" + header_name + ".i")
22 enums_text = make_enums(aclass)
23 method_text = self.make_swig_methods(aclass)
24 text = """
25 %%newgroup
26
27 %s
28 class %s : publib %s
29 {
30
31 public:
32 %s
33 };
34 """ % (enums_text, aclass.name, get_first_value(aclass.bases), method_text)
35
36 afile = open(filename, "wb")
37 afile.write(text)
38 afile.close()
39
40
41 def make_swig_methods(self, aclass):
42 retval = ""
43
44 retval += """
45 %%pythonAppend %s "self._setOORInfo(self)"
46 %%pythonAppend %s() ""
47 %%typemap(out) %s*; // turn off this typemap
48 """ % (aclass.name, aclass.name, aclass.name)
49
50 for amethod in aclass.constructors:
51 retval += " %s%s;\n\n" % (amethod.name, amethod.argsstring)
52
53 retval += """
54 // Turn it back on again
55 %%typemap(out) %s* { $result = wxPyMake_wxObject($1, $owner); }
56 """ % aclass.name
57
58 for amethod in aclass.methods:
59 retval += " %s %s%s;\n\n" % (amethod.return_type, amethod.name, amethod.argsstring)
60
61 return retval