comparison src/dbus-analyze-functions.py @ 11277:421a8523ad04

[gaim-migrate @ 13467] added support for lists and hash tables to libgaim-client committer: Tailor Script <tailor@pidgin.im>
author Piotr Zielinski <zielaj>
date Tue, 16 Aug 2005 15:22:35 +0000
parents 66f872f30e40
children b8c93c40ee2e
comparison
equal deleted inserted replaced
11276:17ebda61c6ce 11277:421a8523ad04
188 print decl 188 print decl
189 189
190 print 'dbus_g_proxy_call(gaim_proxy, "%s", NULL,' % ctopascal(self.function.name) 190 print 'dbus_g_proxy_call(gaim_proxy, "%s", NULL,' % ctopascal(self.function.name)
191 191
192 for type_name in self.inputparams: 192 for type_name in self.inputparams:
193 print "G_TYPE_%s, %s, " % type_name, 193 print "%s, %s, " % type_name,
194 print "G_TYPE_INVALID," 194 print "G_TYPE_INVALID,"
195 195
196 for type_name in self.outputparams: 196 for type_name in self.outputparams:
197 print "G_TYPE_%s, &%s, " % type_name, 197 print "%s, &%s, " % type_name,
198 print "G_TYPE_INVALID);" 198 print "G_TYPE_INVALID);"
199 199
200 for code in self.returncode: 200 for code in self.returncode:
201 print code 201 print code
202 202
207 if (self.headersonly) and (type[0] not in self.knowntypes): 207 if (self.headersonly) and (type[0] not in self.knowntypes):
208 print "struct _%s;" % type[0] 208 print "struct _%s;" % type[0]
209 print "typedef struct _%s %s;" % (type[0], type[0]) 209 print "typedef struct _%s %s;" % (type[0], type[0])
210 self.knowntypes.append(type[0]) 210 self.knowntypes.append(type[0])
211 211
212 # fixme 212 # fixme: import the definitions of the enumerations from gaim
213 # header files
213 def definegaimenum(self, type): 214 def definegaimenum(self, type):
214 if (self.headersonly) and (type[0] not in self.knowntypes) \ 215 if (self.headersonly) and (type[0] not in self.knowntypes) \
215 and (type[0] not in simpletypes): 216 and (type[0] not in simpletypes):
216 print "typedef int %s;" % type[0] 217 print "typedef int %s;" % type[0]
217 self.knowntypes.append(type[0]) 218 self.knowntypes.append(type[0])
218 219
219 def inputsimple(self, type, name): 220 def inputsimple(self, type, name):
220 self.paramshdr.append("%s %s" % (type[0], name)) 221 self.paramshdr.append("%s %s" % (type[0], name))
221 self.inputparams.append(("INT", name)) 222 self.inputparams.append(("G_TYPE_INT", name))
222 self.definegaimenum(type) 223 self.definegaimenum(type)
223 224
224 def inputvalist(self, type, name): 225 def inputvalist(self, type, name):
225 self.paramshdr.append("...") 226 self.paramshdr.append("va_list %s_NULL" % name)
226 227
227 def inputstring(self, type, name): 228 def inputstring(self, type, name):
228 self.paramshdr.append("const char *%s" % name) 229 self.paramshdr.append("const char *%s" % name)
229 self.inputparams.append(("STRING", name)) 230 self.inputparams.append(("G_TYPE_STRING", name))
230 231
231 def inputgaimstructure(self, type, name): 232 def inputgaimstructure(self, type, name):
232 self.paramshdr.append("%s *%s" % (type[0], name)) 233 self.paramshdr.append("const %s *%s" % (type[0], name))
233 self.inputparams.append(("INT", "GPOINTER_TO_INT(%s)" % name)) 234 self.inputparams.append(("G_TYPE_INT", "GPOINTER_TO_INT(%s)" % name))
234 self.definegaimstructure(type) 235 self.definegaimstructure(type)
235 236
236 def inputpointer(self, type, name): 237 def inputpointer(self, type, name):
237 self.paramshdr.append("%s *%s" % (type[0], name)) 238 name += "_NULL"
238 self.inputparams.append(("INT", "0")) 239 self.paramshdr.append("const %s *%s" % (type[0], name))
240 self.inputparams.append(("G_TYPE_INT", "0"))
239 241
240 def inputhash(self, type, name): 242 def inputhash(self, type, name):
241 raise myexception 243 self.paramshdr.append("const GHashTable *%s" % name)
242 244 self.inputparams.append(('dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)', name))
243 245
244 def outputvoid(self, type, name): 246 def outputvoid(self, type, name):
245 self.functiontype = "void" 247 self.functiontype = "void"
246 248
247 def outputstring(self, type, name, const): 249 def outputstring(self, type, name, const):
248 self.functiontype = "char*" 250 self.functiontype = "char*"
249 self.decls.append("char *%s = NULL;" % name) 251 self.decls.append("char *%s = NULL;" % name)
250 self.outputparams.append(("STRING", name)) 252 self.outputparams.append(("G_TYPE_STRING", name))
251 # self.returncode.append("NULLIFY(%s);" % name) 253 # self.returncode.append("NULLIFY(%s);" % name)
252 self.returncode.append("return %s;" % name); 254 self.returncode.append("return %s;" % name);
253 255
254 def outputsimple(self, type, name): 256 def outputsimple(self, type, name):
255 self.functiontype = type[0] 257 self.functiontype = type[0]
256 self.decls.append("%s %s = 0;" % (type[0], name)) 258 self.decls.append("%s %s = 0;" % (type[0], name))
257 self.outputparams.append(("INT", name)) 259 self.outputparams.append(("G_TYPE_INT", name))
258 self.returncode.append("return %s;" % name); 260 self.returncode.append("return %s;" % name);
259 self.definegaimenum(type) 261 self.definegaimenum(type)
260 262
263 # we could add "const" to the return type but this would probably
264 # be a nuisance
261 def outputgaimstructure(self, type, name): 265 def outputgaimstructure(self, type, name):
262 name = name + "_ID" 266 name = name + "_ID"
263 self.functiontype = "%s*" % type[0] 267 self.functiontype = "%s*" % type[0]
264 self.decls.append("int %s = 0;" % name) 268 self.decls.append("int %s = 0;" % name)
265 self.outputparams.append(("INT", "%s" % name)) 269 self.outputparams.append(("G_TYPE_INT", "%s" % name))
266 self.returncode.append("return (%s*) GINT_TO_POINTER(%s);" % (type[0], name)); 270 self.returncode.append("return (%s*) GINT_TO_POINTER(%s);" % (type[0], name));
267 self.definegaimstructure(type) 271 self.definegaimstructure(type)
268 272
269 def outputlist(self, type, name): 273 def outputlist(self, type, name):
270 raise myexception 274 self.functiontype = "%s*" % type[0]
271 275 self.decls.append("GArray *%s;" % name)
276 self.outputparams.append(('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name))
277 self.returncode.append("return garray_int_to_%s(%s);" %
278 (type[0].lower(), name));
272 279
273 280
274 class ServerBinding (Binding): 281 class ServerBinding (Binding):
275 def __init__(self, functiontext, paramtexts): 282 def __init__(self, functiontext, paramtexts):
276 Binding.__init__(self, functiontext, paramtexts) 283 Binding.__init__(self, functiontext, paramtexts)
533 if "export-only" in options: 540 if "export-only" in options:
534 fprefix = "DBUS_EXPORT\s+" 541 fprefix = "DBUS_EXPORT\s+"
535 else: 542 else:
536 fprefix = "" 543 fprefix = ""
537 544
545 sys.stderr.write("%s: Functions not exported:\n" % sys.argv[0])
546
538 if "client" in options: 547 if "client" in options:
539 bindings = ClientBindingSet(sys.stdin, fprefix, 548 bindings = ClientBindingSet(sys.stdin, fprefix,
540 options.has_key("headers")) 549 options.has_key("headers"))
541 else: 550 else:
542 bindings = ServerBindingSet(sys.stdin, fprefix) 551 bindings = ServerBindingSet(sys.stdin, fprefix)