annotate src/dbus-analyze-functions.py @ 19795:38e4a4b404e5

[gaim-migrate @ 16685] add delte group SOAP operation code ok committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Thu, 10 Aug 2006 15:43:55 +0000
parents 9726dbf3d844
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
1 import re
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
2 import string
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
3 import sys
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
4
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
5
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
6 # types translated into "int"
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
7 simpletypes = ["int", "gint", "guint", "gboolean"]
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
8
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
9 # List "excluded" contains functions that shouldn't be exported via
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
10 # DBus. If you remove a function from this list, please make sure
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
11 # that it does not break "make" with the configure option
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
12 # "--enable-dbus" turned on.
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
13
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
14 excluded = [\
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
15 # I don't remember why this function is excluded; something to do
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
16 # with the fact that it takes a (const) GList as a parameter.
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
17 "gaim_presence_add_list",
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
18
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
19 # These functions are excluded because they involve value of the
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
20 # type GaimConvPlacementFunc, which is a pointer to a function and
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
21 # (currently?) can't be translated into a DBus type. Normally,
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
22 # functions with untranslatable types are skipped, but this script
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
23 # assumes that all non-pointer type names beginning with "Gaim"
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
24 # are enums, which is not true in this case.
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
25 "gaim_conv_placement_add_fnc",
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
26 "gaim_conv_placement_get_fnc",
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
27 "gaim_conv_placement_get_current_func",
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
28 "gaim_conv_placement_set_current_func",
13775
9726dbf3d844 [gaim-migrate @ 16187]
Richard Laager <rlaager@wiktel.com>
parents: 13591
diff changeset
29
9726dbf3d844 [gaim-migrate @ 16187]
Richard Laager <rlaager@wiktel.com>
parents: 13591
diff changeset
30 # This is excluded because this script treats GaimLogReadFlags*
9726dbf3d844 [gaim-migrate @ 16187]
Richard Laager <rlaager@wiktel.com>
parents: 13591
diff changeset
31 # as pointer to a struct, instead of a pointer to an enum. This
9726dbf3d844 [gaim-migrate @ 16187]
Richard Laager <rlaager@wiktel.com>
parents: 13591
diff changeset
32 # causes a compilation error. Someone should fix this script.
9726dbf3d844 [gaim-migrate @ 16187]
Richard Laager <rlaager@wiktel.com>
parents: 13591
diff changeset
33 "gaim_log_read",
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
34 ]
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
35
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
36 # This is a list of functions that return a GList* whose elements are
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
37 # string, not pointers to objects. Don't put any functions here, it
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
38 # won't work.
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
39 stringlists = []
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
40
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
41 pointer = "#pointer#"
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
42 myexception = "My Exception"
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
43
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
44 def ctopascal(name):
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
45 newname = ""
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
46 for word in name.split("_"):
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
47 newname += word.capitalize()
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
48 return newname
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
49
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
50 class Parameter:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
51 def __init__(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
52 self.name = name
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
53 self.type = type
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
54
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
55 def fromtokens(tokens, parameternumber = -1):
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
56 if len(tokens) == 0:
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
57 raise myexception
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
58 if (len(tokens) == 1) or (tokens[-1] == pointer):
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
59 if parameternumber >= 0:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
60 return Parameter(tokens, "param%i" % parameternumber)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
61 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
62 raise myexception
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
63 else:
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
64 return Parameter(tokens[:-1], tokens[-1])
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
65
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
66 fromtokens = staticmethod(fromtokens)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
67
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
68 class Binding:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
69 def __init__(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
70 self.function = Parameter.fromtokens(functiontext.split())
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
71
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
72 if self.function.name in excluded:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
73 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
74
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
75 self.params = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
76 for i in range(len(paramtexts)):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
77 self.params.append(Parameter.fromtokens(paramtexts[i].split(), i))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
78
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
79 self.call = "%s(%s)" % (self.function.name,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
80 ", ".join([param.name for param in self.params]))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
81
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
82
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
83 def process(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
84 for param in self.params:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
85 self.processinput(param.type, param.name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
86
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
87 self.processoutput(self.function.type, "RESULT")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
88 self.flush()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
89
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
90
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
91 def processinput(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
92 const = False
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
93 if type[0] == "const":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
94 type = type[1:]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
95 const = True
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
96
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
97 if len(type) == 1:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
98 # simple types (int, gboolean, etc.) and enums
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
99 if (type[0] in simpletypes) or (type[0].startswith("Gaim")):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
100 return self.inputsimple(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
101
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
102
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
103 # va_list, replace by NULL
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
104 if type[0] == "va_list":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
105 return self.inputvalist(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
106
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
107 # pointers ...
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
108 if (len(type) == 2) and (type[1] == pointer):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
109 # strings
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
110 if type[0] == "char":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
111 if const:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
112 return self.inputstring(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
113 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
114 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
115
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
116 elif type[0] == "GHashTable":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
117 return self.inputhash(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
118
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
119 # known object types are transformed to integer handles
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
120 elif type[0].startswith("Gaim"):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
121 return self.inputgaimstructure(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
122
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
123 # unknown pointers are always replaced with NULL
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
124 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
125 return self.inputpointer(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
126 return
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
127
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
128 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
129
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
130
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
131 def processoutput(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
132 # the "void" type is simple ...
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
133 if type == ["void"]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
134 return self.outputvoid(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
135
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
136 const = False
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
137 if type[0] == "const":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
138 type = type[1:]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
139 const = True
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
140
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
141 # a string
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
142 if type == ["char", pointer]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
143 return self.outputstring(type, name, const)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
144
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
145 # simple types (ints, booleans, enums, ...)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
146 if (len(type) == 1) and \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
147 ((type[0] in simpletypes) or (type[0].startswith("Gaim"))):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
148 return self.outputsimple(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
149
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
150 # pointers ...
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
151 if (len(type) == 2) and (type[1] == pointer):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
152
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
153 # handles
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
154 if type[0].startswith("Gaim"):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
155 return self.outputgaimstructure(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
156
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
157 if type[0] in ["GList", "GSList"]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
158 return self.outputlist(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
159
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
160 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
161
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
162
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
163 class ClientBinding (Binding):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
164 def __init__(self, functiontext, paramtexts, knowntypes, headersonly):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
165 Binding.__init__(self, functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
166 self.knowntypes = knowntypes
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
167 self.headersonly = headersonly
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
168 self.paramshdr = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
169 self.decls = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
170 self.inputparams = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
171 self.outputparams = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
172 self.returncode = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
173
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
174 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
175 print "%s %s(%s)" % (self.functiontype, self.function.name,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
176 ", ".join(self.paramshdr)),
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
177
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
178 if self.headersonly:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
179 print ";"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
180 return
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
181
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
182 print "{"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
183
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
184 for decl in self.decls:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
185 print decl
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
186
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
187 print 'dbus_g_proxy_call(gaim_proxy, "%s", NULL,' % ctopascal(self.function.name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
188
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
189 for type_name in self.inputparams:
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
190 print "\t%s, %s, " % type_name,
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
191 print "G_TYPE_INVALID,"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
192
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
193 for type_name in self.outputparams:
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
194 print "\t%s, &%s, " % type_name,
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
195 print "G_TYPE_INVALID);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
196
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
197 for code in self.returncode:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
198 print code
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
199
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
200 print "}\n"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
201
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
202
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
203 def definegaimstructure(self, type):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
204 if (self.headersonly) and (type[0] not in self.knowntypes):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
205 print "struct _%s;" % type[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
206 print "typedef struct _%s %s;" % (type[0], type[0])
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
207 self.knowntypes.append(type[0])
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
208
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
209 def inputsimple(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
210 self.paramshdr.append("%s %s" % (type[0], name))
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
211 self.inputparams.append(("G_TYPE_INT", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
212
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
213 def inputvalist(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
214 self.paramshdr.append("va_list %s_NULL" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
215
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
216 def inputstring(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
217 self.paramshdr.append("const char *%s" % name)
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
218 self.inputparams.append(("G_TYPE_STRING", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
219
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
220 def inputgaimstructure(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
221 self.paramshdr.append("const %s *%s" % (type[0], name))
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
222 self.inputparams.append(("G_TYPE_INT", "GPOINTER_TO_INT(%s)" % name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
223 self.definegaimstructure(type)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
224
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
225 def inputpointer(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
226 name += "_NULL"
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
227 self.paramshdr.append("const %s *%s" % (type[0], name))
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
228 self.inputparams.append(("G_TYPE_INT", "0"))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
229
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
230 def inputhash(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
231 self.paramshdr.append("const GHashTable *%s" % name)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
232 self.inputparams.append(('dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)', name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
233
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
234 def outputvoid(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
235 self.functiontype = "void"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
236
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
237 def outputstring(self, type, name, const):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
238 self.functiontype = "char*"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
239 self.decls.append("char *%s = NULL;" % name)
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
240 self.outputparams.append(("G_TYPE_STRING", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
241 # self.returncode.append("NULLIFY(%s);" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
242 self.returncode.append("return %s;" % name);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
243
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
244 def outputsimple(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
245 self.functiontype = type[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
246 self.decls.append("%s %s = 0;" % (type[0], name))
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
247 self.outputparams.append(("G_TYPE_INT", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
248 self.returncode.append("return %s;" % name);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
249
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
250 # we could add "const" to the return type but this would probably
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
251 # be a nuisance
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
252 def outputgaimstructure(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
253 name = name + "_ID"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
254 self.functiontype = "%s*" % type[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
255 self.decls.append("int %s = 0;" % name)
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
256 self.outputparams.append(("G_TYPE_INT", "%s" % name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
257 self.returncode.append("return (%s*) GINT_TO_POINTER(%s);" % (type[0], name));
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
258 self.definegaimstructure(type)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
259
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
260 def outputlist(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
261 self.functiontype = "%s*" % type[0]
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
262 self.decls.append("GArray *%s;" % name)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
263 self.outputparams.append(('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name))
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
264 self.returncode.append("return garray_int_to_%s(%s);" %
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
265 (type[0].lower(), name));
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
266
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
267
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
268 class ServerBinding (Binding):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
269 def __init__(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
270 Binding.__init__(self, functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
271 self.dparams = ""
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
272 self.cparams = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
273 self.cdecls = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
274 self.ccode = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
275 self.cparamsout = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
276 self.ccodeout = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
277 self.argfunc = "dbus_message_get_args"
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
278
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
279 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
280 print "static DBusMessage*"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
281 print "%s_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) {" % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
282 self.function.name
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
283
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
284 print "\tDBusMessage *reply_DBUS;"
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
285
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
286 for decl in self.cdecls:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
287 print decl
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
288
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
289 print "\t%s(message_DBUS, error_DBUS, " % self.argfunc,
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
290 for param in self.cparams:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
291 print "DBUS_TYPE_%s, &%s," % param,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
292 print "DBUS_TYPE_INVALID);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
293
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
294 print "\tCHECK_ERROR(error_DBUS);"
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
295
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
296 for code in self.ccode:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
297 print code
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
298
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
299 print "\treply_DBUS = dbus_message_new_method_return (message_DBUS);"
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
300
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
301 print "\tdbus_message_append_args(reply_DBUS, ",
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
302 for param in self.cparamsout:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
303 if type(param) is str:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
304 print "%s, " % param
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
305 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
306 print "DBUS_TYPE_%s, &%s, " % param,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
307 print "DBUS_TYPE_INVALID);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
308
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
309 for code in self.ccodeout:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
310 print code
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
311
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
312 print "\treturn reply_DBUS;\n}\n"
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
313
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
314
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
315 def addstring(self, *items):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
316 for item in items:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
317 self.dparams += item + r"\0"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
318
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
319 def addintype(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
320 self.addstring("in", type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
321
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
322 def addouttype(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
323 self.addstring("out", type, name)
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
324
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
325
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
326 # input parameters
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
327
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
328 def inputsimple(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
329 self.cdecls.append("\tdbus_int32_t %s;" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
330 self.cparams.append(("INT32", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
331 self.addintype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
332
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
333 def inputvalist(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
334 self.cdecls.append("\tvoid * %s;" % name);
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
335 self.ccode.append("\t%s = NULL;" % name);
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
336
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
337 def inputstring(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
338 self.cdecls.append("\tconst char *%s;" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
339 self.cparams.append(("STRING", name))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
340 self.ccode .append("\tNULLIFY(%s);" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
341 self.addintype("s", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
342
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
343 def inputhash(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
344 self.argfunc = "gaim_dbus_message_get_args"
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
345 self.cdecls.append("\tDBusMessageIter %s_ITER;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
346 self.cdecls.append("\tGHashTable *%s;" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
347 self.cparams.append(("ARRAY", "%s_ITER" % name))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
348 self.ccode.append("\t%s = gaim_dbus_iter_hash_table(&%s_ITER, error_DBUS);" \
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
349 % (name, name))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
350 self.ccode.append("\tCHECK_ERROR(error_DBUS);")
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
351 self.ccodeout.append("\tg_hash_table_destroy(%s);" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
352 self.addintype("a{ss}", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
353
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
354 def inputgaimstructure(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
355 self.cdecls.append("\tdbus_int32_t %s_ID;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
356 self.cdecls.append("\t%s *%s;" % (type[0], name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
357 self.cparams.append(("INT32", name + "_ID"))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
358 self.ccode.append("\tGAIM_DBUS_ID_TO_POINTER(%s, %s_ID, %s, error_DBUS);" % \
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
359 (name, name, type[0]))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
360 self.addintype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
361
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
362 def inputpointer(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
363 self.cdecls.append("\tdbus_int32_t %s_NULL;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
364 self.cdecls .append("\t%s *%s;" % (type[0], name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
365 self.cparams.append(("INT32", name + "_NULL"))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
366 self.ccode .append("\t%s = NULL;" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
367 self.addintype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
368
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
369 # output parameters
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
370
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
371 def outputvoid(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
372 self.ccode.append("\t%s;" % self.call) # just call the function
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
373
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
374 def outputstring(self, type, name, const):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
375 self.cdecls.append("\tconst char *%s;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
376 self.ccode.append("\t%s = null_to_empty(%s);" % (name, self.call))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
377 self.cparamsout.append(("STRING", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
378 self.addouttype("s", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
379 if not const:
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
380 self.ccodeout.append("\tg_free(%s);" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
381
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
382 def outputsimple(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
383 self.cdecls.append("\tdbus_int32_t %s;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
384 self.ccode.append("\t%s = %s;" % (name, self.call))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
385 self.cparamsout.append(("INT32", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
386 self.addouttype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
387
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
388 def outputgaimstructure(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
389 self.cdecls.append("\tdbus_int32_t %s;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
390 self.ccode .append("\tGAIM_DBUS_POINTER_TO_ID(%s, %s, error_DBUS);" % (name, self.call))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
391 self.cparamsout.append(("INT32", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
392 self.addouttype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
393
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
394 # GList*, GSList*, assume that list is a list of objects
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
395
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
396 # fixme: at the moment, we do NOT free the memory occupied by
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
397 # the list, we should free it if the list has NOT been declared const
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
398
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
399 # fixme: we assume that this is a list of objects, not a list
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
400 # of strings
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
401
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
402 def outputlist(self, type, name):
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
403 self.cdecls.append("\tdbus_int32_t %s_LEN;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
404 self.ccodeout.append("\tg_free(%s);" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
405
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
406 if self.function.name in stringlists:
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
407 self.cdecls.append("\tchar **%s;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
408 self.ccode.append("\t%s = gaim_%s_to_array(%s, FALSE, &%s_LEN);" % \
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
409 (name, type[0], self.call, name))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
410 self.cparamsout.append("\tDBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &%s, %s_LEN" \
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
411 % (name, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
412 self.addouttype("as", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
413 else:
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
414 self.cdecls.append("\tdbus_int32_t *%s;" % name)
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
415 self.ccode.append("\t%s = gaim_dbusify_%s(%s, FALSE, &%s_LEN);" % \
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
416 (name, type[0], self.call, name))
13591
dcfda39ad547 [gaim-migrate @ 15977]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12627
diff changeset
417 self.cparamsout.append("\tDBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &%s, %s_LEN" \
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
418 % (name, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
419 self.addouttype("ai", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
420
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
421
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
422 class BindingSet:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
423 regexp = r"^(\w[^()]*)\(([^()]*)\)\s*;\s*$";
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
424
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
425 def __init__(self, inputfile, fprefix):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
426 self.inputiter = iter(inputfile)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
427 self.functionregexp = \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
428 re.compile("^%s(\w[^()]*)\(([^()]*)\)\s*;\s*$" % fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
429
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
430
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
431
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
432 def process(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
433 print "/* Generated by %s. Do not edit! */" % sys.argv[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
434
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
435 for line in self.inputiter:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
436 words = line.split()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
437 if len(words) == 0: # empty line
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
438 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
439 if line[0] == "#": # preprocessor directive
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
440 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
441 if words[0] in ["typedef", "struct", "enum", "static"]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
442 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
443
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
444 # accumulate lines until the parentheses are balance or an
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
445 # empty line has been encountered
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
446 myline = line.strip()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
447 while myline.count("(") > myline.count(")"):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
448 newline = self.inputiter.next().strip()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
449 if len(newline) == 0:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
450 break
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
451 myline += " " + newline
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
452
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
453 # is this a function declaration?
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
454 thematch = self.functionregexp.match(
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
455 myline.replace("*", " " + pointer + " "))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
456
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
457 if thematch is None:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
458 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
459
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
460 functiontext = thematch.group(1)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
461 paramstext = thematch.group(2).strip()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
462
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
463 if (paramstext == "void") or (paramstext == ""):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
464 paramtexts = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
465 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
466 paramtexts = paramstext.split(",")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
467
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
468 try:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
469 self.processfunction(functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
470 except myexception:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
471 sys.stderr.write(myline + "\n")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
472 except:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
473 sys.stderr.write(myline + "\n")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
474 raise
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
475
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
476 self.flush()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
477
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
478 class ServerBindingSet (BindingSet):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
479 def __init__(self, inputfile, fprefix):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
480 BindingSet.__init__(self, inputfile, fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
481 self.functions = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
482
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
483
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
484 def processfunction(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
485 binding = ServerBinding(functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
486 binding.process()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
487 self.functions.append((binding.function.name, binding.dparams))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
488
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
489 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
490 print "static GaimDBusBinding bindings_DBUS[] = { "
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
491 for function, params in self.functions:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
492 print '{"%s", "%s", %s_DBUS},' % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
493 (ctopascal(function), params, function)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
494
12627
2078f65a8e98 [gaim-migrate @ 14963]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12051
diff changeset
495 print "{NULL, NULL, NULL}"
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
496 print "};"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
497
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
498 print "#define GAIM_DBUS_REGISTER_BINDINGS(handle) gaim_dbus_register_bindings(handle, bindings_DBUS)"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
499
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
500 class ClientBindingSet (BindingSet):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
501 def __init__(self, inputfile, fprefix, headersonly):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
502 BindingSet.__init__(self, inputfile, fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
503 self.functions = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
504 self.knowntypes = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
505 self.headersonly = headersonly
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
506
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
507 def processfunction(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
508 binding = ClientBinding(functiontext, paramtexts, self.knowntypes, self.headersonly)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
509 binding.process()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
510
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
511 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
512 pass
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
513
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
514 # Main program
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
515
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
516 options = {}
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
517
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
518 for arg in sys.argv[1:]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
519 if arg[0:2] == "--":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
520 mylist = arg[2:].split("=",1)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
521 command = mylist[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
522 if len(mylist) > 1:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
523 options[command] = mylist[1]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
524 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
525 options[command] = None
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
526
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
527 if "export-only" in options:
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
528 fprefix = "DBUS_EXPORT\s+"
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
529 else:
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
530 fprefix = ""
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
531
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
532 sys.stderr.write("%s: Functions not exported:\n" % sys.argv[0])
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
533
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
534 if "client" in options:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
535 bindings = ClientBindingSet(sys.stdin, fprefix,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
536 options.has_key("headers"))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
537 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
538 bindings = ServerBindingSet(sys.stdin, fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
539 bindings.process()
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
540
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
541
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
542
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
543