summaryrefslogtreecommitdiff
path: root/efl/edje/efl.edje_message.pxi
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
commit8b8639886059814a36f57164d5572e97bcb00a47 (patch)
tree1c5a170de002793c1402d6afcc16c63115d81caa /efl/edje/efl.edje_message.pxi
Put in a first, still wip, version of the python bindings in a merged tree.
This is meant to be the 1.8 version of the wrappers and will include everything that now is in the python folder. Atm this include evas, ecore, edje, elementary and emotion (emotion still commented in the build couse it need some more testing). Eo is used as a base for all the objects that inherit from it in C, but in real nothing is used from Eo, it is used more like a container to share code between the libs. All the docs has been stripped out because we want to use the new sphinx style docs that Kay has done in his git repo. (Kay: please wait a little bit to include it, as working on the libs without docs is much more easy) The new wrappers include a new container module called efl and thus you can live with both the old and the new installation. This also means that you need to import the new modules as: "from efl import evas" (instead of the old "import evas") The idea here is that you can make your code works with both version doing something like: try: import evas except: from efl import evas ...like is done in the gtk bindings Some stuff has been leaved out on purpose, because was old stuff (like the hacked evas rotation stuff) or because was not working as expected (like all the ecore.evas.XXX modules). See the TODO.txt file for more info. Probably some stuff is out just because I missed them, let me know if you miss something. Improvements from the old version: - Py3 compatible (still some work to be done, but really only TODO, no problems to resolv) - Should also works on other platforms, like windoz (but not tested) - Unittests greatly improved, you can also run ALL tests at once - much more simpler :) I will contine the works in the next weeks and hope someone will help too. NOTE: I switched back to setup.py instead of autotools, because that is the right way to compile python stuff. So to build just use: python setup.py install or python3 setup.py install Enjoy davemds SVN revision: 83831
Diffstat (limited to 'efl/edje/efl.edje_message.pxi')
-rw-r--r--efl/edje/efl.edje_message.pxi375
1 files changed, 375 insertions, 0 deletions
diff --git a/efl/edje/efl.edje_message.pxi b/efl/edje/efl.edje_message.pxi
new file mode 100644
index 0000000..1f51f81
--- /dev/null
+++ b/efl/edje/efl.edje_message.pxi
@@ -0,0 +1,375 @@
1# Copyright (C) 2007-2008 Gustavo Sverzut Barbieri
2#
3# This file is part of Python-Edje.
4#
5# Python-Edje is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Edje is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Edje. If not, see <http://www.gnu.org/licenses/>.
17
18
19cdef class Message:
20 """Base class to represent Edje messages.
21
22 @ivar type: message type.
23 @ivar id: message id.
24 """
25 property type:
26 def __get__(self):
27 return self._type
28
29 property id:
30 def __get__(self):
31 return self._id
32
33
34cdef class MessageString(Message):
35 """String message.
36
37 @ivar str: message contents.
38 @ivar val: same as str.
39 """
40 property str:
41 def __get__(self):
42 if self.obj == NULL:
43 raise ValueError("Object uninitialized")
44 if self.obj.str != NULL:
45 return self.obj.str
46
47 property val: # copy from 'str', to make api consistent
48 def __get__(self):
49 if self.obj == NULL:
50 raise ValueError("Object uninitialized")
51 if self.obj.str != NULL:
52 return self.obj.str
53
54
55cdef class MessageInt(Message):
56 """Integer message.
57
58 @ivar val: message contents.
59 """
60 property val:
61 def __get__(self):
62 if self.obj == NULL:
63 raise ValueError("Object uninitialized")
64 return self.obj.val
65
66
67cdef class MessageFloat(Message):
68 """Float message.
69
70 @ivar val: message contents.
71 """
72 property val:
73 def __get__(self):
74 if self.obj == NULL:
75 raise ValueError("Object uninitialized")
76 return self.obj.val
77
78
79cdef class MessageStringSet(Message):
80 """String set message.
81
82 @ivar val: message contents.
83 """
84 property val:
85 def __get__(self):
86 cdef int i
87 if self.obj == NULL:
88 raise ValueError("Object uninitialized")
89 lst = []
90 for i from 0 <= i < self.obj.count:
91 if self.obj.str[i] != NULL:
92 lst.append(self.obj.str[i])
93 return lst
94
95 def __len__(self):
96 if self.obj == NULL:
97 raise ValueError("Object uninitialized")
98 return self.obj.count
99
100 def __getitem__(self, int index):
101 if self.obj == NULL:
102 raise ValueError("Object uninitialized")
103 if index < 0 or index >= self.obj.count:
104 raise IndexError("list index out of range")
105 return self.obj.str[index]
106
107
108cdef class MessageIntSet(Message):
109 """Integer set message.
110
111 @ivar val: message contents.
112 """
113 property val:
114 def __get__(self):
115 cdef int i
116 if self.obj == NULL:
117 raise ValueError("Object uninitialized")
118 lst = []
119 for i from 0 <= i < self.obj.count:
120 lst.append(self.obj.val[i])
121 return lst
122
123 def __len__(self):
124 if self.obj == NULL:
125 raise ValueError("Object uninitialized")
126 return self.obj.count
127
128 def __getitem__(self, int index):
129 if self.obj == NULL:
130 raise ValueError("Object uninitialized")
131 if index < 0 or index >= self.obj.count:
132 raise IndexError("list index out of range")
133 return self.obj.val[index]
134
135
136cdef class MessageFloatSet(Message):
137 """Float set message.
138
139 @ivar val: message contents.
140 """
141 property val:
142 def __get__(self):
143 cdef int i
144 if self.obj == NULL:
145 raise ValueError("Object uninitialized")
146 lst = []
147 for i from 0 <= i < self.obj.count:
148 lst.append(self.obj.val[i])
149 return lst
150
151 def __len__(self):
152 if self.obj == NULL:
153 raise ValueError("Object uninitialized")
154 return self.obj.count
155
156 def __getitem__(self, int index):
157 if self.obj == NULL:
158 raise ValueError("Object uninitialized")
159 if index < 0 or index >= self.obj.count:
160 raise IndexError("list index out of range")
161 return self.obj.val[index]
162
163
164cdef class MessageStringInt(Message):
165 """String + Integer message.
166
167 @ivar str: string.
168 @ivar val: integer.
169 """
170 property str:
171 def __get__(self):
172 if self.obj == NULL:
173 raise ValueError("Object uninitialized")
174 if self.obj.str != NULL:
175 return self.obj.str
176
177 property val:
178 def __get__(self):
179 if self.obj == NULL:
180 raise ValueError("Object uninitialized")
181 return self.obj.val
182
183
184cdef class MessageStringFloat(Message):
185 """String + float message.
186
187 @ivar str: string.
188 @ivar val: float.
189 """
190 property str:
191 def __get__(self):
192 if self.obj == NULL:
193 raise ValueError("Object uninitialized")
194 if self.obj.str != NULL:
195 return self.obj.str
196
197 property val:
198 def __get__(self):
199 if self.obj == NULL:
200 raise ValueError("Object uninitialized")
201 return self.obj.val
202
203
204cdef class MessageStringIntSet(Message):
205 """String + Integer set message.
206
207 @ivar str: string.
208 @ivar val: integer list.
209 """
210 property str:
211 def __get__(self):
212 if self.obj == NULL:
213 raise ValueError("Object uninitialized")
214 if self.obj.str != NULL:
215 return self.obj.str
216
217 property val:
218 def __get__(self):
219 cdef int i
220 if self.obj == NULL:
221 raise ValueError("Object uninitialized")
222 lst = []
223 for i from 0 <= i < self.obj.count:
224 lst.append(self.obj.val[i])
225 return lst
226
227 def __len__(self):
228 if self.obj == NULL:
229 raise ValueError("Object uninitialized")
230 return self.obj.count
231
232 def __getitem__(self, int index):
233 if self.obj == NULL:
234 raise ValueError("Object uninitialized")
235 if index < 0 or index >= self.obj.count:
236 raise IndexError("list index out of range")
237 return self.obj.val[index]
238
239
240cdef class MessageStringFloatSet(Message):
241 """String + Float set message.
242
243 @ivar str: string.
244 @ivar val: float list.
245 """
246 property str:
247 def __get__(self):
248 if self.obj == NULL:
249 raise ValueError("Object uninitialized")
250 if self.obj.str != NULL:
251 return self.obj.str
252
253 property val:
254 def __get__(self):
255 cdef int i
256 if self.obj == NULL:
257 raise ValueError("Object uninitialized")
258 lst = []
259 for i from 0 <= i < self.obj.count:
260 lst.append(self.obj.val[i])
261 return lst
262
263 def __len__(self):
264 if self.obj == NULL:
265 raise ValueError("Object uninitialized")
266 return self.obj.count
267
268 def __getitem__(self, int index):
269 if self.obj == NULL:
270 raise ValueError("Object uninitialized")
271 if index < 0 or index >= self.obj.count:
272 raise IndexError("list index out of range")
273 return self.obj.val[index]
274
275
276cdef Message MessageString_from_ptr(void *msg):
277 cdef MessageString m
278 m = MessageString()
279 m.obj = <Edje_Message_String*>msg
280 return m
281
282
283cdef Message MessageInt_from_ptr(void *msg):
284 cdef MessageInt m
285 m = MessageInt()
286 m.obj = <Edje_Message_Int*>msg
287 return m
288
289
290cdef Message MessageFloat_from_ptr(void *msg):
291 cdef MessageFloat m
292 m = MessageFloat()
293 m.obj = <Edje_Message_Float*>msg
294 return m
295
296
297cdef Message MessageStringSet_from_ptr(void *msg):
298 cdef MessageStringSet m
299 m = MessageStringSet()
300 m.obj = <Edje_Message_String_Set*>msg
301 return m
302
303
304cdef Message MessageIntSet_from_ptr(void *msg):
305 cdef MessageIntSet m
306 m = MessageIntSet()
307 m.obj = <Edje_Message_Int_Set*>msg
308 return m
309
310
311cdef Message MessageFloatSet_from_ptr(void *msg):
312 cdef MessageFloatSet m
313 m = MessageFloatSet()
314 m.obj = <Edje_Message_Float_Set*>msg
315 return m
316
317
318cdef Message MessageStringInt_from_ptr(void *msg):
319 cdef MessageStringInt m
320 m = MessageStringInt()
321 m.obj = <Edje_Message_String_Int*>msg
322 return m
323
324
325cdef Message MessageStringFloat_from_ptr(void *msg):
326 cdef MessageStringFloat m
327 m = MessageStringFloat()
328 m.obj = <Edje_Message_String_Float*>msg
329 return m
330
331
332cdef Message MessageStringIntSet_from_ptr(void *msg):
333 cdef MessageStringIntSet m
334 m = MessageStringIntSet()
335 m.obj = <Edje_Message_String_Int_Set*>msg
336 return m
337
338
339cdef Message MessageStringFloatSet_from_ptr(void *msg):
340 cdef MessageStringFloatSet m
341 m = MessageStringFloatSet()
342 m.obj = <Edje_Message_String_Float_Set*>msg
343 return m
344
345
346cdef Message Message_from_type(Edje_Message_Type type, int id, void *msg):
347 cdef Message m
348 if type == EDJE_MESSAGE_NONE:
349 return None
350 elif type == EDJE_MESSAGE_SIGNAL:
351 m = MessageSignal()
352 elif type == EDJE_MESSAGE_STRING:
353 m = MessageString_from_ptr(msg)
354 elif type == EDJE_MESSAGE_INT:
355 m = MessageInt_from_ptr(msg)
356 elif type == EDJE_MESSAGE_FLOAT:
357 m = MessageFloat_from_ptr(msg)
358 elif type == EDJE_MESSAGE_STRING_SET:
359 m = MessageStringSet_from_ptr(msg)
360 elif type == EDJE_MESSAGE_INT_SET:
361 m = MessageIntSet_from_ptr(msg)
362 elif type == EDJE_MESSAGE_FLOAT_SET:
363 m = MessageFloatSet_from_ptr(msg)
364 elif type == EDJE_MESSAGE_STRING_INT:
365 m = MessageStringInt_from_ptr(msg)
366 elif type == EDJE_MESSAGE_STRING_FLOAT:
367 m = MessageStringFloat_from_ptr(msg)
368 elif type == EDJE_MESSAGE_STRING_INT_SET :
369 m = MessageStringIntSet_from_ptr(msg)
370 elif type == EDJE_MESSAGE_STRING_FLOAT_SET :
371 m = MessageStringFloatSet_from_ptr(msg)
372
373 m._type = type
374 m._id = id
375 return m