]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/scripts/sip_tools.py
Mention wxZlib classes in archives overview.
[wxWidgets.git] / docs / doxygen / scripts / sip_tools.py
CommitLineData
0cbc1d02
KO
1import os
2
3from common import *
4
5class SIPBuilder:
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, "sip"))
12 if not os.path.exists(output_dir):
13 os.makedirs(output_dir)
14
15 for aclass in self.doxyparser.classes:
16 if aclass.name in excluded_classes:
17 print "Skipping %s" % aclass.name
18 continue
19
20 header_name = aclass.name[2:].lower()
edaadd8c 21 filename = os.path.join(output_dir, "_" + header_name + ".sip")
0cbc1d02
KO
22 enums_text = make_enums(aclass)
23 method_text = self.make_sip_methods(aclass)
24 base_class = get_first_value(aclass.bases)
25 if base_class != "":
26 base_class = ": %s" % base_class
27
28 text = """
29%s
30class %s %s
31{
32%%TypeHeaderCode
33#include <%s>
34%%End
35
36public:
37%s
38};
39""" % (enums_text, aclass.name, base_class, get_first_value(aclass.includes), method_text)
40
41 afile = open(filename, "wb")
42 afile.write(text)
43 afile.close()
44
45
46 def make_sip_methods(self, aclass):
47 retval = ""
48
49 for amethod in aclass.constructors + aclass.methods:
50 transfer = ""
51
52 # FIXME: we need to come up with a way of filtering the methods out by various criteria
53 # including parameters and method name, and how to deal with overloads
54 if aclass.name in ignored_methods:
55 should_ignore = False
56 for method in ignored_methods[aclass.name]:
57 print "method = %s" % method
58 if method == amethod.name:
59 params = ignored_methods[aclass.name][method]
60 should_ignore = True
61 for i in xrange(len(params)):
62 if i >= len(amethod.params):
63 should_ignore = False
64 break
65 elif amethod.params[i]["type"] != params[i]:
66 print "param type = %s, amethod.param type = %s" % (params[i], amethod.params[i]["type"])
67 should_ignore = False
68 break
69
70 if should_ignore:
71 continue
72
73 # We need to let SIP know when wx is responsible for deleting the object.
74 # We do this if the class is derived from wxWindow, since wxTLW manages child windows
75 # and wxApp deletes all wxTLWs on shutdown
76 if amethod in aclass.constructors and self.doxyparser.is_derived_from_base(aclass, "wxWindow"):
77 transfer = "/Transfer/"
78
79 if amethod.name.startswith("operator"):
80 continue
81
82 retval += " %s %s%s%s;\n\n" % (amethod.return_type.replace("virtual ", ""), amethod.name, amethod.argsstring, transfer)
83
84 return retval