Mercurial > pidgin
comparison libpurple/dbus-analyze-functions.py @ 26068:f95aa2b14bec
propagate from branch 'im.pidgin.pidgin' (head 96db74f0ccbe2a283893e33f0f7bff5a827f48d9)
to branch 'im.pidgin.pidgin.vv' (head 55aa623e09a7429df54b4e068dcba4c67c5fe779)
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Fri, 30 Jan 2009 08:58:07 +0000 |
parents | a1c4ae9a2fcc |
children | 2520d5fe48a3 |
comparison
equal
deleted
inserted
replaced
26067:a6e53d23bcbb | 26068:f95aa2b14bec |
---|---|
115 self.params = [] | 115 self.params = [] |
116 for i in range(len(paramtexts)): | 116 for i in range(len(paramtexts)): |
117 self.params.append(Parameter.fromtokens(paramtexts[i].split(), i)) | 117 self.params.append(Parameter.fromtokens(paramtexts[i].split(), i)) |
118 | 118 |
119 self.call = "%s(%s)" % (self.function.name, | 119 self.call = "%s(%s)" % (self.function.name, |
120 ", ".join([param.name for param in self.params])) | 120 ", ".join(param.name for param in self.params)) |
121 | 121 |
122 | 122 |
123 def process(self): | 123 def process(self): |
124 for param in self.params: | 124 for param in self.params: |
125 self.processinput(param.type, param.name) | 125 self.processinput(param.type, param.name) |
158 | 158 |
159 # known object types are transformed to integer handles | 159 # known object types are transformed to integer handles |
160 elif type[0].startswith("Purple") or type[0] == "xmlnode": | 160 elif type[0].startswith("Purple") or type[0] == "xmlnode": |
161 return self.inputpurplestructure(type, name) | 161 return self.inputpurplestructure(type, name) |
162 | 162 |
163 # special case for *_get_data functions, be careful here... | |
164 elif (type[0] == "size_t") and (name == "len"): | |
165 return self.inputgetdata(type, name) | |
166 | |
163 # unknown pointers are always replaced with NULL | 167 # unknown pointers are always replaced with NULL |
164 else: | 168 else: |
165 return self.inputpointer(type, name) | 169 return self.inputpointer(type, name) |
166 | 170 |
167 raise myexception | 171 raise myexception |
193 if type[0].startswith("Purple"): | 197 if type[0].startswith("Purple"): |
194 return self.outputpurplestructure(type, name) | 198 return self.outputpurplestructure(type, name) |
195 | 199 |
196 if type[0] in ["GList", "GSList"]: | 200 if type[0] in ["GList", "GSList"]: |
197 return self.outputlist(type, name) | 201 return self.outputlist(type, name) |
202 | |
203 # Special case for *_get_data functions | |
204 if type[0] == "gconstpointer": | |
205 return self.outputgetdata(type, name) | |
198 | 206 |
199 raise myexception | 207 raise myexception |
200 | 208 |
201 | 209 |
202 class ClientBinding (Binding): | 210 class ClientBinding (Binding): |
307 self.decls.append("GArray *%s;" % name) | 315 self.decls.append("GArray *%s;" % name) |
308 self.outputparams.append(('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name)) | 316 self.outputparams.append(('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name)) |
309 self.returncode.append("return garray_int_to_%s(%s);" % | 317 self.returncode.append("return garray_int_to_%s(%s);" % |
310 (type[0].lower(), name)); | 318 (type[0].lower(), name)); |
311 | 319 |
312 | 320 # Special case for *_get_data functions, don't need client bindings, |
321 # but do need the name so it doesn't crash | |
322 def inputgetdata(self, type, name): | |
323 raise myexception | |
324 def outputgetdata(self, type, name): | |
325 raise myexception | |
326 | |
313 class ServerBinding (Binding): | 327 class ServerBinding (Binding): |
314 def __init__(self, functiontext, paramtexts): | 328 def __init__(self, functiontext, paramtexts): |
315 Binding.__init__(self, functiontext, paramtexts) | 329 Binding.__init__(self, functiontext, paramtexts) |
316 self.dparams = "" | 330 self.dparams = "" |
317 self.cparams = [] | 331 self.cparams = [] |
473 self.ccode.append("\tg_%s_free(list);" % type[0].lower()[1:]) | 487 self.ccode.append("\tg_%s_free(list);" % type[0].lower()[1:]) |
474 self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &%s, %s_LEN" \ | 488 self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &%s, %s_LEN" \ |
475 % (name, name)) | 489 % (name, name)) |
476 self.addouttype("ai", name) | 490 self.addouttype("ai", name) |
477 | 491 |
492 # Special case for *_get_data functions | |
493 def inputgetdata(self, type, name): | |
494 self.cdecls.append("\tsize_t %s = 0;" % name) | |
495 return True | |
496 def outputgetdata(self, type, name): | |
497 # This is a total hack, but self.call is set up before the parameters | |
498 # are processed, so we can't tell it to pass a parameter by reference. | |
499 self.call = "%s(%s)" % (self.function.name, | |
500 ", ".join(param.name if param.name != "len" else "&len" for param in self.params)) | |
501 | |
502 self.cdecls.append("\tgconstpointer %s;" % name) | |
503 self.ccode.append("\t%s = %s;" % (name, self.call)) | |
504 self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &%s, %s" \ | |
505 % (name, "len")) | |
506 self.addouttype("ay", name) | |
478 | 507 |
479 class BindingSet: | 508 class BindingSet: |
480 regexp = r"^(\w[^()]*)\(([^()]*)\)\s*;\s*$"; | 509 regexp = r"^(\w[^()]*)\(([^()]*)\)\s*;\s*$"; |
481 | 510 |
482 def __init__(self, inputfile, fprefix): | 511 def __init__(self, inputfile, fprefix): |