summaryrefslogtreecommitdiff
path: root/efl/edje/efl.edje_edit_program.pxi
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2013-04-14 14:24:44 +0200
committerdavemds <dave@gurumeditation.it>2013-04-14 14:24:44 +0200
commit0fae488f776c2d3d0eea06f3d9990f62164fe5b5 (patch)
treee326473f4e97417ae781abcbffbad9059759bf00 /efl/edje/efl.edje_edit_program.pxi
parent9d85805b13151206df7f285109f71ba272e445a9 (diff)
Python-EFL: EdjeEdit, manage the various class 'name' prop in a saner way
Instead of keeping a py object now keep a stringshared char*, so that we can pass it directly to the C API without messing with conversions.
Diffstat (limited to '')
-rw-r--r--efl/edje/efl.edje_edit_program.pxi132
1 files changed, 48 insertions, 84 deletions
diff --git a/efl/edje/efl.edje_edit_program.pxi b/efl/edje/efl.edje_edit_program.pxi
index acca7e4..4ccfe90 100644
--- a/efl/edje/efl.edje_edit_program.pxi
+++ b/efl/edje/efl.edje_edit_program.pxi
@@ -18,117 +18,103 @@
18 18
19cdef class Program(object): 19cdef class Program(object):
20 cdef EdjeEdit edje 20 cdef EdjeEdit edje
21 cdef object name 21 cdef const_char *name
22 22
23 def __init__(self, EdjeEdit e, name): 23 def __init__(self, EdjeEdit e not None, name not None):
24 if isinstance(name, unicode): name = name.encode("UTF-8") 24 if isinstance(name, unicode): name = name.encode("UTF-8")
25 self.edje = e 25 self.edje = e
26 self.name = name 26 self.name = eina_stringshare_add(name)
27
28 def __dealloc__(self):
29 eina_stringshare_del(self.name)
27 30
28 property name: 31 property name:
29 def __get__(self): 32 def __get__(self):
30 return self.name.decode('UTF-8', 'strict') 33 return _ctouni(self.name)
31
32 def __set__(self, newname): 34 def __set__(self, newname):
33 self.rename(newname) 35 self.rename(newname)
34 36
35 def rename(self, newname): 37 def rename(self, newname not None):
36 cdef Eina_Bool ret 38 cdef Eina_Bool ret
37 if isinstance(newname, unicode): newname = newname.encode("UTF-8") 39 if isinstance(newname, unicode): newname = newname.encode("UTF-8")
38 ret = edje_edit_program_name_set(self.edje.obj, 40 ret = edje_edit_program_name_set(self.edje.obj, self.name,
39 <const_char *>self.name if self.name is not None else NULL,
40 <const_char *>newname if newname is not None else NULL) 41 <const_char *>newname if newname is not None else NULL)
41 if ret == 0: 42 if ret == 0:
42 return False 43 return False
43 self.name = newname 44 eina_stringshare_replace(&self.name, <const_char *>newname)
44 return True 45 return True
45 46
46 def edje_get(self): 47 def edje_get(self):
47 return self.edje 48 return self.edje
48 49
49 def run(self): 50 def run(self):
50 return bool(edje_edit_program_run(self.edje.obj, 51 return bool(edje_edit_program_run(self.edje.obj, self.name))
51 <const_char *>self.name if self.name is not None else NULL))
52 52
53 # XXX TODO: add (or better convert) all this to properties 53 # XXX TODO: add (or better convert) all this to properties
54 # like is done in Part() 54 # like is done in Part()
55 def source_get(self): 55 def source_get(self):
56 cdef const_char *s 56 cdef const_char *s
57 s = edje_edit_program_source_get(self.edje.obj, 57 s = edje_edit_program_source_get(self.edje.obj, self.name)
58 <const_char *>self.name if self.name is not None else NULL)
59 ret = _ctouni(s) 58 ret = _ctouni(s)
60 edje_edit_string_free(s) 59 edje_edit_string_free(s)
61 return ret 60 return ret
62 61
63 def source_set(self, source): 62 def source_set(self, source):
64 if isinstance(source, unicode): source = source.encode("UTF-8") 63 if isinstance(source, unicode): source = source.encode("UTF-8")
65 return bool(edje_edit_program_source_set(self.edje.obj, 64 return bool(edje_edit_program_source_set(self.edje.obj, self.name,
66 <const_char *>self.name if self.name is not None else NULL,
67 <const_char *>source if source is not None else NULL)) 65 <const_char *>source if source is not None else NULL))
68 66
69 def signal_get(self): 67 def signal_get(self):
70 cdef const_char *s 68 cdef const_char *s
71 s = edje_edit_program_signal_get(self.edje.obj, 69 s = edje_edit_program_signal_get(self.edje.obj, self.name)
72 <const_char *>self.name if self.name is not None else NULL)
73 ret = _ctouni(s) 70 ret = _ctouni(s)
74 edje_edit_string_free(s) 71 edje_edit_string_free(s)
75 return ret 72 return ret
76 73
77 def signal_set(self, signal): 74 def signal_set(self, signal):
78 if isinstance(signal, unicode): signal = signal.encode("UTF-8") 75 if isinstance(signal, unicode): signal = signal.encode("UTF-8")
79 return bool(edje_edit_program_signal_set(self.edje.obj, 76 return bool(edje_edit_program_signal_set(self.edje.obj, self.name,
80 <const_char *>self.name if self.name is not None else NULL,
81 <const_char *>signal if signal is not None else NULL)) 77 <const_char *>signal if signal is not None else NULL))
82 78
83 def in_from_get(self): 79 def in_from_get(self):
84 return edje_edit_program_in_from_get(self.edje.obj, 80 return edje_edit_program_in_from_get(self.edje.obj, self.name)
85 <const_char *>self.name if self.name is not None else NULL)
86 81
87 def in_from_set(self, double f): 82 def in_from_set(self, double f):
88 return bool(edje_edit_program_in_from_set(self.edje.obj, 83 return bool(edje_edit_program_in_from_set(self.edje.obj, self.name, f))
89 <const_char *>self.name if self.name is not None else NULL, f))
90 84
91 def in_range_get(self): 85 def in_range_get(self):
92 return edje_edit_program_in_range_get(self.edje.obj, 86 return edje_edit_program_in_range_get(self.edje.obj, self.name)
93 <const_char *>self.name if self.name is not None else NULL)
94 87
95 def in_range_set(self, double r): 88 def in_range_set(self, double r):
96 return bool(edje_edit_program_in_range_set(self.edje.obj, 89 return bool(edje_edit_program_in_range_set(self.edje.obj, self.name, r))
97 <const_char *>self.name if self.name is not None else NULL, r))
98 90
99 def action_get(self): 91 def action_get(self):
100 return edje_edit_program_action_get(self.edje.obj, 92 return edje_edit_program_action_get(self.edje.obj, self.name)
101 <const_char *>self.name if self.name is not None else NULL)
102 93
103 def action_set(self, action): 94 def action_set(self, action):
104 if isinstance(action, unicode): action = action.encode("UTF-8") 95 if isinstance(action, unicode): action = action.encode("UTF-8")
105 return bool(edje_edit_program_action_set(self.edje.obj, 96 return bool(edje_edit_program_action_set(self.edje.obj, self.name,
106 <const_char *>self.name if self.name is not None else NULL, 97 action))
107 action))
108 98
109 def targets_get(self): 99 def targets_get(self):
110 cdef Eina_List *lst 100 cdef Eina_List *lst
111 lst = edje_edit_program_targets_get(self.edje.obj, 101 lst = edje_edit_program_targets_get(self.edje.obj, self.name)
112 <const_char *>self.name if self.name is not None else NULL)
113 ret = convert_eina_list_strings_to_python_list(lst) 102 ret = convert_eina_list_strings_to_python_list(lst)
114 edje_edit_string_list_free(lst) 103 edje_edit_string_list_free(lst)
115 return ret 104 return ret
116 105
117 def target_add(self, target): 106 def target_add(self, target):
118 if isinstance(target, unicode): target = target.encode("UTF-8") 107 if isinstance(target, unicode): target = target.encode("UTF-8")
119 return bool(edje_edit_program_target_add(self.edje.obj, 108 return bool(edje_edit_program_target_add(self.edje.obj, self.name,
120 <const_char *>self.name if self.name is not None else NULL,
121 <const_char *>target if target is not None else NULL)) 109 <const_char *>target if target is not None else NULL))
122 110
123 def target_del(self, target): 111 def target_del(self, target):
124 if isinstance(target, unicode): target = target.encode("UTF-8") 112 if isinstance(target, unicode): target = target.encode("UTF-8")
125 return bool(edje_edit_program_target_del(self.edje.obj, 113 return bool(edje_edit_program_target_del(self.edje.obj, self.name,
126 <const_char *>self.name if self.name is not None else NULL,
127 <const_char *>target if target is not None else NULL)) 114 <const_char *>target if target is not None else NULL))
128 115
129 def targets_clear(self): 116 def targets_clear(self):
130 return bool(edje_edit_program_targets_clear(self.edje.obj, 117 return bool(edje_edit_program_targets_clear(self.edje.obj, self.name))
131 <const_char *>self.name if self.name is not None else NULL))
132 118
133 def afters_get(self): 119 def afters_get(self):
134 cdef Eina_List *lst 120 cdef Eina_List *lst
@@ -139,89 +125,72 @@ cdef class Program(object):
139 125
140 def after_add(self, after): 126 def after_add(self, after):
141 if isinstance(after, unicode): after = after.encode("UTF-8") 127 if isinstance(after, unicode): after = after.encode("UTF-8")
142 return bool(edje_edit_program_after_add(self.edje.obj, 128 return bool(edje_edit_program_after_add(self.edje.obj, self.name,
143 <const_char *>self.name if self.name is not None else NULL,
144 <const_char *>after if after is not None else NULL)) 129 <const_char *>after if after is not None else NULL))
145 130
146 def after_del(self, after): 131 def after_del(self, after):
147 if isinstance(after, unicode): after = after.encode("UTF-8") 132 if isinstance(after, unicode): after = after.encode("UTF-8")
148 return bool(edje_edit_program_after_del(self.edje.obj, 133 return bool(edje_edit_program_after_del(self.edje.obj, self.name,
149 <const_char *>self.name if self.name is not None else NULL,
150 <const_char *>after if after is not None else NULL)) 134 <const_char *>after if after is not None else NULL))
151 135
152 def afters_clear(self): 136 def afters_clear(self):
153 return bool(edje_edit_program_afters_clear(self.edje.obj, 137 return bool(edje_edit_program_afters_clear(self.edje.obj, self.name))
154 <const_char *>self.name if self.name is not None else NULL))
155 138
156 def state_get(self): 139 def state_get(self):
157 cdef const_char *s 140 cdef const_char *s
158 s = edje_edit_program_state_get(self.edje.obj, 141 s = edje_edit_program_state_get(self.edje.obj, self.name)
159 <const_char *>self.name if self.name is not None else NULL)
160 ret = _ctouni(s) 142 ret = _ctouni(s)
161 edje_edit_string_free(s) 143 edje_edit_string_free(s)
162 return ret 144 return ret
163 145
164 def state_set(self, state): 146 def state_set(self, state):
165 if isinstance(state, unicode): state = state.encode("UTF-8") 147 if isinstance(state, unicode): state = state.encode("UTF-8")
166 return bool(edje_edit_program_state_set(self.edje.obj, 148 return bool(edje_edit_program_state_set(self.edje.obj, self.name,
167 <const_char *>self.name if self.name is not None else NULL,
168 <const_char *>state if state is not None else NULL)) 149 <const_char *>state if state is not None else NULL))
169 150
170 def value_get(self): 151 def value_get(self):
171 return edje_edit_program_value_get(self.edje.obj, 152 return edje_edit_program_value_get(self.edje.obj, self.name)
172 <const_char *>self.name if self.name is not None else NULL)
173 153
174 def value_set(self, double v): 154 def value_set(self, double v):
175 return bool(edje_edit_program_value_set(self.edje.obj, 155 return bool(edje_edit_program_value_set(self.edje.obj, self.name, v))
176 <const_char *>self.name if self.name is not None else NULL, v))
177 156
178 def state2_get(self): 157 def state2_get(self):
179 cdef const_char *s 158 cdef const_char *s
180 s = edje_edit_program_state2_get(self.edje.obj, 159 s = edje_edit_program_state2_get(self.edje.obj, self.name)
181 <const_char *>self.name if self.name is not None else NULL)
182 ret = _ctouni(s) 160 ret = _ctouni(s)
183 edje_edit_string_free(s) 161 edje_edit_string_free(s)
184 return ret 162 return ret
185 163
186 def state2_set(self, state): 164 def state2_set(self, state):
187 if isinstance(state, unicode): state = state.encode("UTF-8") 165 if isinstance(state, unicode): state = state.encode("UTF-8")
188 return bool(edje_edit_program_state2_set(self.edje.obj, 166 return bool(edje_edit_program_state2_set(self.edje.obj, self.name,
189 <const_char *>self.name if self.name is not None else NULL,
190 <const_char *>state if state is not None else NULL)) 167 <const_char *>state if state is not None else NULL))
191 168
192 def value2_get(self): 169 def value2_get(self):
193 return edje_edit_program_value2_get(self.edje.obj, 170 return edje_edit_program_value2_get(self.edje.obj, self.name)
194 <const_char *>self.name if self.name is not None else NULL)
195 171
196 def value2_set(self, double v): 172 def value2_set(self, double v):
197 return bool(edje_edit_program_value2_set(self.edje.obj, 173 return bool(edje_edit_program_value2_set(self.edje.obj, self.name, v))
198 <const_char *>self.name if self.name is not None else NULL, v))
199 174
200 def transition_get(self): 175 def transition_get(self):
201 return edje_edit_program_transition_get(self.edje.obj, 176 return edje_edit_program_transition_get(self.edje.obj, self.name)
202 <const_char *>self.name if self.name is not None else NULL)
203 177
204 def transition_set(self, t): 178 def transition_set(self, t):
205 return bool(edje_edit_program_transition_set(self.edje.obj, 179 return bool(edje_edit_program_transition_set(self.edje.obj, self.name, t))
206 <const_char *>self.name if self.name is not None else NULL, t))
207 180
208 def transition_time_get(self): 181 def transition_time_get(self):
209 return edje_edit_program_transition_time_get(self.edje.obj, 182 return edje_edit_program_transition_time_get(self.edje.obj, self.name)
210 <const_char *>self.name if self.name is not None else NULL)
211 183
212 def transition_time_set(self, double t): 184 def transition_time_set(self, double t):
213 return bool(edje_edit_program_transition_time_set(self.edje.obj, 185 return bool(edje_edit_program_transition_time_set(self.edje.obj, self.name, t))
214 <const_char *>self.name if self.name is not None else NULL, t))
215 186
216 property api: 187 property api:
217 def __get__(self): 188 def __get__(self):
218 cdef: 189 cdef:
219 const_char *name 190 const_char *name
220 const_char *desc 191 const_char *desc
221 name = edje_edit_program_api_name_get(self.edje.obj, 192 name = edje_edit_program_api_name_get(self.edje.obj, self.name)
222 <const_char *>self.name if self.name is not None else NULL) 193 desc = edje_edit_program_api_description_get(self.edje.obj, self.name)
223 desc = edje_edit_program_api_description_get(self.edje.obj,
224 <const_char *>self.name if self.name is not None else NULL)
225 n, d = _ctouni(name), _ctouni(desc) 194 n, d = _ctouni(name), _ctouni(desc)
226 edje_edit_string_free(name) 195 edje_edit_string_free(name)
227 edje_edit_string_free(desc) 196 edje_edit_string_free(desc)
@@ -232,29 +201,24 @@ cdef class Program(object):
232 name, desc = value 201 name, desc = value
233 if isinstance(name, unicode): name = name.encode("UTF-8") 202 if isinstance(name, unicode): name = name.encode("UTF-8")
234 if isinstance(desc, unicode): desc = desc.encode("UTF-8") 203 if isinstance(desc, unicode): desc = desc.encode("UTF-8")
235 edje_edit_program_api_name_set(self.edje.obj, 204 edje_edit_program_api_name_set(self.edje.obj, self.name,
236 <const_char *>self.name if self.name is not None else NULL,
237 <const_char *>name if name is not None else NULL) 205 <const_char *>name if name is not None else NULL)
238 edje_edit_program_api_description_set(self.edje.obj, 206 edje_edit_program_api_description_set(self.edje.obj, self.name,
239 <const_char *>self.name if self.name is not None else NULL,
240 <const_char *>desc if desc is not None else NULL) 207 <const_char *>desc if desc is not None else NULL)
241 208
242 property script: 209 property script:
243 def __get__(self): 210 def __get__(self):
244 cdef char *code 211 cdef char *code
245 code = edje_edit_script_program_get(self.edje.obj, 212 code = edje_edit_script_program_get(self.edje.obj, self.name)
246 <const_char *>self.name if self.name is not None else NULL)
247 ret = _touni(code) 213 ret = _touni(code)
248 free(code) 214 free(code)
249 return ret 215 return ret
250 216
251 def __set__(self, code): 217 def __set__(self, code):
252 if isinstance(code, unicode): code = code.encode("UTF-8") 218 if isinstance(code, unicode): code = code.encode("UTF-8")
253 edje_edit_script_program_set(self.edje.obj, 219 edje_edit_script_program_set(self.edje.obj, self.name,
254 <const_char *>self.name if self.name is not None else NULL,
255 <const_char *>code if code is not None else NULL) 220 <const_char *>code if code is not None else NULL)
256 221
257 def __del__(self): 222 def __del__(self):
258 edje_edit_script_program_set(self.edje.obj, 223 edje_edit_script_program_set(self.edje.obj, self.name, NULL)
259 <const_char *>self.name if self.name is not None else NULL, NULL)
260 224