]> git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/scripts/c_tools.py
Rename all WEB_VIEW* style identifiers to WEBVIEW*.
[wxWidgets.git] / docs / doxygen / scripts / c_tools.py
1 """
2 C bindings generator
3 Author: Luke A. Guest
4 """
5
6 import os
7
8 from common import *
9
10 class CBuilder:
11 def __init__(self, doxyparse, outputdir):
12 self.doxyparser = doxyparse
13 self.output_dir = outputdir
14
15 def make_bindings(self):
16 output_dir = os.path.abspath(os.path.join(self.output_dir, "c"))
17 if not os.path.exists(output_dir):
18 os.makedirs(output_dir)
19
20 for aclass in self.doxyparser.classes:
21 # This bit doesn't work, because the aclass.name is not the same as
22 # those listed in common
23 if aclass.name in excluded_classes:
24 #print "Skipping %s" % aclass.name
25 continue
26
27 self.make_c_header(output_dir, aclass)
28
29
30 def make_c_header(self, output_dir, aclass):
31 filename = os.path.join(output_dir, aclass.name[2:].lower() + ".hh")
32 enums_text = make_enums(aclass)
33 method_text = self.make_c_methods(aclass)
34 class_name = aclass.name[2:].capitalize()
35 text = """
36 // Enums
37 %s
38
39 %s
40 """ % (enums_text, method_text)
41
42 afile = open(filename, "wb")
43 afile.write(text)
44 afile.close()
45
46
47 def make_c_methods(self, aclass):
48 retval = ""
49
50 wxc_classname = 'wxC' + aclass.name[2:].capitalize()
51
52 for amethod in aclass.constructors:
53 retval += """
54 // %s
55 %s%s;\n\n
56 """ % (amethod.brief_description, wxc_classname + '* ' + wxc_classname + '_' + amethod.name, amethod.argsstring)
57
58 for amethod in aclass.methods:
59 if amethod.name.startswith('m_'):
60 # for some reason, public members are listed as methods
61 continue
62
63 args = '(' + wxc_classname + '* obj'
64 if amethod.argsstring.find('()') != -1:
65 args += ')'
66 else:
67 args += ', ' + amethod.argsstring[1:].strip()
68
69 retval += """
70 // %s
71 %s %s%s;\n
72 """ % (amethod.detailed_description, amethod.return_type, wxc_classname + '_' + amethod.name, args)
73
74 return retval