annotate src/dbus-analyze-functions.py @ 11485:16b0da1f376f

[gaim-migrate @ 13727] Fix the /nick weirdness bug I introduced. Also, patch 1283539, from Peter Lawler (two changes) 1. When in a chat where Gaim can tell which users are buddies (i.e. non-Jabber chats), only the names of buddies are bolded. I'm not sure if I'll like this, but I'm committing it so we can all try it out. 2. "remove bold, underline, and italics when we're ignoring formatting, as well" committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 09 Sep 2005 20:14:32 +0000
parents 17142948653e
children 2329075592f4
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",
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
29 ]
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
30
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
31 # This is a list of functions that return a GList* whose elements are
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
32 # string, not pointers to objects. Don't put any functions here, it
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11328
diff changeset
33 # won't work.
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
34 stringlists = []
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
35
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
36 pointer = "#pointer#"
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
37 myexception = "My Exception"
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
38
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
39 def ctopascal(name):
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
40 newname = ""
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
41 for word in name.split("_"):
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
42 newname += word.capitalize()
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
43 return newname
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
44
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
45 class Parameter:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
46 def __init__(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
47 self.name = name
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
48 self.type = type
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
49
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
50 def fromtokens(tokens, parameternumber = -1):
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
51 if len(tokens) == 0:
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
52 raise myexception
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
53 if (len(tokens) == 1) or (tokens[-1] == pointer):
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
54 if parameternumber >= 0:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
55 return Parameter(tokens, "param%i" % parameternumber)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
56 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
57 raise myexception
11187
744c0708d11f [gaim-migrate @ 13303]
Piotr Zielinski <zielaj>
parents: 11175
diff changeset
58 else:
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
59 return Parameter(tokens[:-1], tokens[-1])
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
60
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
61 fromtokens = staticmethod(fromtokens)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
62
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
63 class Binding:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
64 def __init__(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
65 self.function = Parameter.fromtokens(functiontext.split())
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
66
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
67 if self.function.name in excluded:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
68 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
69
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
70 self.params = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
71 for i in range(len(paramtexts)):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
72 self.params.append(Parameter.fromtokens(paramtexts[i].split(), i))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
73
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
74 self.call = "%s(%s)" % (self.function.name,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
75 ", ".join([param.name for param in self.params]))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
76
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
77
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
78 def process(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
79 for param in self.params:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
80 self.processinput(param.type, param.name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
81
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
82 self.processoutput(self.function.type, "RESULT")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
83 self.flush()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
84
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
85
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
86 def processinput(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
87 const = False
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
88 if type[0] == "const":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
89 type = type[1:]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
90 const = True
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
91
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
92 if len(type) == 1:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
93 # simple types (int, gboolean, etc.) and enums
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
94 if (type[0] in simpletypes) or (type[0].startswith("Gaim")):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
95 return self.inputsimple(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
96
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
97
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
98 # va_list, replace by NULL
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
99 if type[0] == "va_list":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
100 return self.inputvalist(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 # pointers ...
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
103 if (len(type) == 2) and (type[1] == pointer):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
104 # strings
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
105 if type[0] == "char":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
106 if const:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
107 return self.inputstring(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
108 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
109 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
110
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
111 elif type[0] == "GHashTable":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
112 return self.inputhash(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
113
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
114 # known object types are transformed to integer handles
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
115 elif type[0].startswith("Gaim"):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
116 return self.inputgaimstructure(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
117
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
118 # unknown pointers are always replaced with NULL
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
119 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
120 return self.inputpointer(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
121 return
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
122
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
123 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
124
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
125
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
126 def processoutput(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
127 # the "void" type is simple ...
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
128 if type == ["void"]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
129 return self.outputvoid(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
130
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
131 const = False
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
132 if type[0] == "const":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
133 type = type[1:]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
134 const = True
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
135
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
136 # a string
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
137 if type == ["char", pointer]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
138 return self.outputstring(type, name, const)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
139
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
140 # simple types (ints, booleans, enums, ...)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
141 if (len(type) == 1) and \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
142 ((type[0] in simpletypes) or (type[0].startswith("Gaim"))):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
143 return self.outputsimple(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
144
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
145 # pointers ...
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
146 if (len(type) == 2) and (type[1] == pointer):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
147
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
148 # handles
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
149 if type[0].startswith("Gaim"):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
150 return self.outputgaimstructure(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
151
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
152 if type[0] in ["GList", "GSList"]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
153 return self.outputlist(type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
154
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
155 raise myexception
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
156
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
157
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
158 class ClientBinding (Binding):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
159 def __init__(self, functiontext, paramtexts, knowntypes, headersonly):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
160 Binding.__init__(self, functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
161 self.knowntypes = knowntypes
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
162 self.headersonly = headersonly
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
163 self.paramshdr = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
164 self.decls = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
165 self.inputparams = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
166 self.outputparams = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
167 self.returncode = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
168
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
169 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
170 print "%s %s(%s)" % (self.functiontype, self.function.name,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
171 ", ".join(self.paramshdr)),
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
172
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
173 if self.headersonly:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
174 print ";"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
175 return
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
176
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
177 print "{"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
178
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
179 for decl in self.decls:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
180 print decl
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 'dbus_g_proxy_call(gaim_proxy, "%s", NULL,' % ctopascal(self.function.name)
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 type_name in self.inputparams:
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
185 print "%s, %s, " % type_name,
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
186 print "G_TYPE_INVALID,"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
187
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
188 for type_name in self.outputparams:
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
189 print "%s, &%s, " % type_name,
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
190 print "G_TYPE_INVALID);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
191
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
192 for code in self.returncode:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
193 print code
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
194
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
195 print "}\n"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
196
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
197
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
198 def definegaimstructure(self, type):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
199 if (self.headersonly) and (type[0] not in self.knowntypes):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
200 print "struct _%s;" % type[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
201 print "typedef struct _%s %s;" % (type[0], type[0])
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
202 self.knowntypes.append(type[0])
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
203
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
204 def inputsimple(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
205 self.paramshdr.append("%s %s" % (type[0], name))
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
206 self.inputparams.append(("G_TYPE_INT", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
207
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
208 def inputvalist(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
209 self.paramshdr.append("va_list %s_NULL" % name)
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
210
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
211 def inputstring(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
212 self.paramshdr.append("const char *%s" % name)
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
213 self.inputparams.append(("G_TYPE_STRING", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
214
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
215 def inputgaimstructure(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
216 self.paramshdr.append("const %s *%s" % (type[0], name))
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
217 self.inputparams.append(("G_TYPE_INT", "GPOINTER_TO_INT(%s)" % name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
218 self.definegaimstructure(type)
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 inputpointer(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
221 name += "_NULL"
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
222 self.paramshdr.append("const %s *%s" % (type[0], name))
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
223 self.inputparams.append(("G_TYPE_INT", "0"))
11241
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 inputhash(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
226 self.paramshdr.append("const GHashTable *%s" % name)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
227 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
228
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
229 def outputvoid(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
230 self.functiontype = "void"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
231
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
232 def outputstring(self, type, name, const):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
233 self.functiontype = "char*"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
234 self.decls.append("char *%s = NULL;" % name)
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
235 self.outputparams.append(("G_TYPE_STRING", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
236 # self.returncode.append("NULLIFY(%s);" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
237 self.returncode.append("return %s;" % name);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
238
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
239 def outputsimple(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
240 self.functiontype = type[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
241 self.decls.append("%s %s = 0;" % (type[0], name))
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
242 self.outputparams.append(("G_TYPE_INT", name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
243 self.returncode.append("return %s;" % name);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
244
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
245 # we could add "const" to the return type but this would probably
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
246 # be a nuisance
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
247 def outputgaimstructure(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
248 name = name + "_ID"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
249 self.functiontype = "%s*" % type[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
250 self.decls.append("int %s = 0;" % name)
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
251 self.outputparams.append(("G_TYPE_INT", "%s" % name))
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
252 self.returncode.append("return (%s*) GINT_TO_POINTER(%s);" % (type[0], name));
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
253 self.definegaimstructure(type)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
254
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
255 def outputlist(self, type, name):
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
256 self.functiontype = "%s*" % type[0]
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
257 self.decls.append("GArray *%s;" % name)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
258 self.outputparams.append(('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name))
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
259 self.returncode.append("return garray_int_to_%s(%s);" %
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
260 (type[0].lower(), name));
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
261
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
262
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
263 class ServerBinding (Binding):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
264 def __init__(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
265 Binding.__init__(self, functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
266 self.dparams = ""
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
267 self.cparams = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
268 self.cdecls = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
269 self.ccode = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
270 self.cparamsout = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
271 self.ccodeout = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
272 self.argfunc = "dbus_message_get_args"
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
273
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
274 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
275 print "static DBusMessage*"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
276 print "%s_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) {" % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
277 self.function.name
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
278
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
279 print "DBusMessage *reply_DBUS;"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
280
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
281 for decl in self.cdecls:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
282 print decl
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
283
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
284 print "%s(message_DBUS, error_DBUS, " % self.argfunc,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
285 for param in self.cparams:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
286 print "DBUS_TYPE_%s, &%s," % param,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
287 print "DBUS_TYPE_INVALID);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
288
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
289 print "CHECK_ERROR(error_DBUS);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
290
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
291 for code in self.ccode:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
292 print code
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
293
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
294 print "reply_DBUS = dbus_message_new_method_return (message_DBUS);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
295
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
296 print "dbus_message_append_args(reply_DBUS, ",
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
297 for param in self.cparamsout:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
298 if type(param) is str:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
299 print "%s, " % param
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
300 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
301 print "DBUS_TYPE_%s, &%s, " % param,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
302 print "DBUS_TYPE_INVALID);"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
303
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
304 for code in self.ccodeout:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
305 print code
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
306
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
307 print "return reply_DBUS;\n}\n"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
308
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
309
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
310 def addstring(self, *items):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
311 for item in items:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
312 self.dparams += item + r"\0"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
313
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
314 def addintype(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
315 self.addstring("in", type, name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
316
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
317 def addouttype(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
318 self.addstring("out", type, name)
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
319
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
320
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
321 # input parameters
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
322
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
323 def inputsimple(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
324 self.cdecls.append("dbus_int32_t %s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
325 self.cparams.append(("INT32", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
326 self.addintype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
327
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
328 def inputvalist(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
329 self.cdecls.append("va_list %s;" % name);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
330 self.ccode.append("%s = NULL;" % name);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
331
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
332 def inputstring(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
333 self.cdecls.append("const char *%s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
334 self.cparams.append(("STRING", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
335 self.ccode .append("NULLIFY(%s);" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
336 self.addintype("s", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
337
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
338 def inputhash(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
339 self.argfunc = "gaim_dbus_message_get_args"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
340 self.cdecls.append("DBusMessageIter %s_ITER;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
341 self.cdecls.append("GHashTable *%s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
342 self.cparams.append(("ARRAY", "%s_ITER" % name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
343 self.ccode.append("%s = gaim_dbus_iter_hash_table(&%s_ITER, error_DBUS);" \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
344 % (name, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
345 self.ccode.append("CHECK_ERROR(error_DBUS);")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
346 self.ccodeout.append("g_hash_table_destroy(%s);" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
347 self.addintype("a{ss}", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
348
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
349 def inputgaimstructure(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
350 self.cdecls.append("dbus_int32_t %s_ID;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
351 self.cdecls.append("%s *%s;" % (type[0], name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
352 self.cparams.append(("INT32", name + "_ID"))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
353 self.ccode.append("GAIM_DBUS_ID_TO_POINTER(%s, %s_ID, %s, error_DBUS);" % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
354 (name, name, type[0]))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
355 self.addintype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
356
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
357 def inputpointer(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
358 self.cdecls.append("dbus_int32_t %s_NULL;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
359 self.cdecls .append("%s *%s;" % (type[0], name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
360 self.cparams.append(("INT32", name + "_NULL"))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
361 self.ccode .append("%s = NULL;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
362 self.addintype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
363
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
364 # output parameters
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
365
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
366 def outputvoid(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
367 self.ccode.append("%s;" % self.call) # just call the function
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
368
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
369 def outputstring(self, type, name, const):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
370 self.cdecls.append("const char *%s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
371 self.ccode.append("%s = null_to_empty(%s);" % (name, self.call))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
372 self.cparamsout.append(("STRING", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
373 self.addouttype("s", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
374 if not const:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
375 self.ccodeout.append("g_free(%s);" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
376
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
377 def outputsimple(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
378 self.cdecls.append("dbus_int32_t %s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
379 self.ccode.append("%s = %s;" % (name, self.call))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
380 self.cparamsout.append(("INT32", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
381 self.addouttype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
382
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
383 def outputgaimstructure(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
384 self.cdecls.append("dbus_int32_t %s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
385 self.ccode .append("GAIM_DBUS_POINTER_TO_ID(%s, %s, error_DBUS);" % (name, self.call))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
386 self.cparamsout.append(("INT32", name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
387 self.addouttype("i", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
388
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
389 # GList*, GSList*, assume that list is a list of objects
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
390
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
391 # fixme: at the moment, we do NOT free the memory occupied by
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
392 # 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
393
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
394 # fixme: we assume that this is a list of objects, not a list
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
395 # of strings
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
396
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
397 def outputlist(self, type, name):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
398 self.cdecls.append("dbus_int32_t %s_LEN;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
399 self.ccodeout.append("g_free(%s);" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
400
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
401 if self.function.name in stringlists:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
402 self.cdecls.append("char **%s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
403 self.ccode.append("%s = gaim_%s_to_array(%s, FALSE, &%s_LEN);" % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
404 (name, type[0], self.call, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
405 self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &%s, %s_LEN" \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
406 % (name, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
407 self.addouttype("as", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
408 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
409 self.cdecls.append("dbus_int32_t *%s;" % name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
410 self.ccode.append("%s = gaim_dbusify_%s(%s, FALSE, &%s_LEN);" % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
411 (name, type[0], self.call, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
412 self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &%s, %s_LEN" \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
413 % (name, name))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
414 self.addouttype("ai", name)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
415
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
416
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
417 class BindingSet:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
418 regexp = r"^(\w[^()]*)\(([^()]*)\)\s*;\s*$";
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
419
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
420 def __init__(self, inputfile, fprefix):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
421 self.inputiter = iter(inputfile)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
422 self.functionregexp = \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
423 re.compile("^%s(\w[^()]*)\(([^()]*)\)\s*;\s*$" % fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
424
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
425
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
426
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
427 def process(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
428 print "/* Generated by %s. Do not edit! */" % sys.argv[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
429
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
430 for line in self.inputiter:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
431 words = line.split()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
432 if len(words) == 0: # empty line
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
433 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
434 if line[0] == "#": # preprocessor directive
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
435 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
436 if words[0] in ["typedef", "struct", "enum", "static"]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
437 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
438
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
439 # accumulate lines until the parentheses are balance or an
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
440 # empty line has been encountered
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
441 myline = line.strip()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
442 while myline.count("(") > myline.count(")"):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
443 newline = self.inputiter.next().strip()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
444 if len(newline) == 0:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
445 break
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
446 myline += " " + newline
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
447
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
448 # is this a function declaration?
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
449 thematch = self.functionregexp.match(
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
450 myline.replace("*", " " + pointer + " "))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
451
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
452 if thematch is None:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
453 continue
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
454
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
455 functiontext = thematch.group(1)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
456 paramstext = thematch.group(2).strip()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
457
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
458 if (paramstext == "void") or (paramstext == ""):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
459 paramtexts = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
460 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
461 paramtexts = paramstext.split(",")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
462
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
463 try:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
464 self.processfunction(functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
465 except myexception:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
466 sys.stderr.write(myline + "\n")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
467 except:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
468 sys.stderr.write(myline + "\n")
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
469 raise
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
470
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
471 self.flush()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
472
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
473 class ServerBindingSet (BindingSet):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
474 def __init__(self, inputfile, fprefix):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
475 BindingSet.__init__(self, inputfile, fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
476 self.functions = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
477
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
478
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
479 def processfunction(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
480 binding = ServerBinding(functiontext, paramtexts)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
481 binding.process()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
482 self.functions.append((binding.function.name, binding.dparams))
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 flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
485 print "static GaimDBusBinding bindings_DBUS[] = { "
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
486 for function, params in self.functions:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
487 print '{"%s", "%s", %s_DBUS},' % \
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
488 (ctopascal(function), params, function)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
489
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
490 print "{NULL, NULL}"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
491 print "};"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
492
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
493 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
494
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
495 class ClientBindingSet (BindingSet):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
496 def __init__(self, inputfile, fprefix, headersonly):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
497 BindingSet.__init__(self, inputfile, fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
498 self.functions = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
499 self.knowntypes = []
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
500 self.headersonly = headersonly
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
501
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
502 def processfunction(self, functiontext, paramtexts):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
503 binding = ClientBinding(functiontext, paramtexts, self.knowntypes, self.headersonly)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
504 binding.process()
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
505
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
506 def flush(self):
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
507 pass
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
508
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
509 # Main program
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
510
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
511 options = {}
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
512
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
513 for arg in sys.argv[1:]:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
514 if arg[0:2] == "--":
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
515 mylist = arg[2:].split("=",1)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
516 command = mylist[0]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
517 if len(mylist) > 1:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
518 options[command] = mylist[1]
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
519 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
520 options[command] = None
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
521
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
522 if "export-only" in options:
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
523 fprefix = "DBUS_EXPORT\s+"
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
524 else:
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
525 fprefix = ""
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
526
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
527 sys.stderr.write("%s: Functions not exported:\n" % sys.argv[0])
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
528
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
529 if "client" in options:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
530 bindings = ClientBindingSet(sys.stdin, fprefix,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
531 options.has_key("headers"))
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
532 else:
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
533 bindings = ServerBindingSet(sys.stdin, fprefix)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
534 bindings.process()
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
535
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents: 11187
diff changeset
536
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
537
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
538