Mercurial > pidgin
comparison src/dbus-analyze-functions.py @ 11331:64fadbf3810f
[gaim-migrate @ 13544]
General polishing of DBus code, improving examples, removing obsolete files.
committer: Tailor Script <tailor@pidgin.im>
author | Piotr Zielinski <zielaj> |
---|---|
date | Wed, 24 Aug 2005 02:34:40 +0000 |
parents | b8c93c40ee2e |
children | 17142948653e |
comparison
equal
deleted
inserted
replaced
11330:d41a83d221b0 | 11331:64fadbf3810f |
---|---|
1 # This programs takes a C header file as the input and produces: | |
2 # | |
3 # with option --mode=xml: xml dbus specification | |
4 # with option --mode=c: C wrappers | |
5 # | |
6 | |
7 import re | 1 import re |
8 import string | 2 import string |
9 import sys | 3 import sys |
10 | 4 |
11 | 5 |
12 # list of object types | 6 # types translated into "int" |
13 | |
14 # objecttypes = [] | |
15 | |
16 # for objecttype in file("dbus-auto-structs.txt"): | |
17 # objecttypes.append(objecttype.strip()) | |
18 | |
19 # a dictionary of simple types | |
20 # each TYPE maps into a pair (dbus-type-name, compatible-c-type-name) | |
21 # if compatible-c-type-name is None then it is the same as TYPE | |
22 | |
23 # simpletypes = { | |
24 # "int" : ("i", None), | |
25 # "gint" : ("i", None), | |
26 # "guint" : ("u", None), | |
27 # "gboolean" : ("i", "int") | |
28 # } | |
29 | |
30 | |
31 simpletypes = ["int", "gint", "guint", "gboolean"] | 7 simpletypes = ["int", "gint", "guint", "gboolean"] |
32 | 8 |
33 # for enum in file("dbus-auto-enums.txt"): | 9 # List "excluded" contains functions that shouldn't be exported via |
34 # simpletypes[enum.strip()] = ("i", "int") | 10 # DBus. If you remove a function from this list, please make sure |
35 | 11 # that it does not break "make" with the configure option |
36 # functions that shouldn't be exported | 12 # "--enable-dbus" turned on. |
37 | 13 |
38 excluded = ["gaim_conv_placement_add_fnc", | 14 excluded = [\ |
39 "gaim_presence_add_list"] | 15 # I don't remember why this function is excluded; something to do |
40 | 16 # with the fact that it takes a (const) GList as a parameter. |
17 "gaim_presence_add_list", | |
18 | |
19 # these two macros are excluded because they occur both as | |
20 # macros and as enum constants, which breaks libgaim-client. | |
21 "GAIM_CONV_IM", | |
22 "GAIM_CONV_CHAT", | |
23 | |
24 # These functions are excluded because they involve value of the | |
25 # type GaimConvPlacementFunc, which is a pointer to a function and | |
26 # (currently?) can't be translated into a DBus type. Normally, | |
27 # functions with untranslatable types are skipped, but this script | |
28 # assumes that all non-pointer type names beginning with "Gaim" | |
29 # are enums, which is not true in this case. | |
30 "gaim_conv_placement_add_fnc", | |
31 "gaim_conv_placement_get_fnc", | |
32 "gaim_conv_placement_get_current_func", | |
33 "gaim_conv_placement_set_current_func", | |
34 ] | |
35 | |
36 # This is a list of functions that return a GList* whose elements are | |
37 # string, not pointers to objects. Don't put any functions here, it | |
38 # won't work. | |
41 stringlists = [] | 39 stringlists = [] |
42 | 40 |
43 pointer = "#pointer#" | 41 pointer = "#pointer#" |
44 myexception = "My Exception" | 42 myexception = "My Exception" |
45 | 43 |
206 if (self.headersonly) and (type[0] not in self.knowntypes): | 204 if (self.headersonly) and (type[0] not in self.knowntypes): |
207 print "struct _%s;" % type[0] | 205 print "struct _%s;" % type[0] |
208 print "typedef struct _%s %s;" % (type[0], type[0]) | 206 print "typedef struct _%s %s;" % (type[0], type[0]) |
209 self.knowntypes.append(type[0]) | 207 self.knowntypes.append(type[0]) |
210 | 208 |
211 # fixme: import the definitions of the enumerations from gaim | |
212 # header files | |
213 def definegaimenum(self, type): | |
214 if (self.headersonly) and (type[0] not in self.knowntypes) \ | |
215 and (type[0] not in simpletypes): | |
216 print "typedef int %s;" % type[0] | |
217 self.knowntypes.append(type[0]) | |
218 | |
219 def inputsimple(self, type, name): | 209 def inputsimple(self, type, name): |
220 self.paramshdr.append("%s %s" % (type[0], name)) | 210 self.paramshdr.append("%s %s" % (type[0], name)) |
221 self.inputparams.append(("G_TYPE_INT", name)) | 211 self.inputparams.append(("G_TYPE_INT", name)) |
222 self.definegaimenum(type) | |
223 | 212 |
224 def inputvalist(self, type, name): | 213 def inputvalist(self, type, name): |
225 self.paramshdr.append("va_list %s_NULL" % name) | 214 self.paramshdr.append("va_list %s_NULL" % name) |
226 | 215 |
227 def inputstring(self, type, name): | 216 def inputstring(self, type, name): |
255 def outputsimple(self, type, name): | 244 def outputsimple(self, type, name): |
256 self.functiontype = type[0] | 245 self.functiontype = type[0] |
257 self.decls.append("%s %s = 0;" % (type[0], name)) | 246 self.decls.append("%s %s = 0;" % (type[0], name)) |
258 self.outputparams.append(("G_TYPE_INT", name)) | 247 self.outputparams.append(("G_TYPE_INT", name)) |
259 self.returncode.append("return %s;" % name); | 248 self.returncode.append("return %s;" % name); |
260 self.definegaimenum(type) | |
261 | 249 |
262 # we could add "const" to the return type but this would probably | 250 # we could add "const" to the return type but this would probably |
263 # be a nuisance | 251 # be a nuisance |
264 def outputgaimstructure(self, type, name): | 252 def outputgaimstructure(self, type, name): |
265 name = name + "_ID" | 253 name = name + "_ID" |