summaryrefslogtreecommitdiff
path: root/efl/emotion
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-04-06 23:48:16 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-04-06 23:48:16 +0300
commitd6dc3a2045b756e3a633fcfdac9312dc234fa00d (patch)
tree94a803961ea49b5185d3efbffb25a576a850fcd2 /efl/emotion
parent9cb0bbaf8b40e7e489ed8a28b1315a942b6f0a0f (diff)
Revert "Remove Python -> C string hacks"
A quote from Cython documentation: "The other direction, i.e. automatic encoding to C strings, is only supported for the ASCII codec (and the “default encoding”, which is runtime specific and may or may not be ASCII). This is because CPython handles the memory management in this case by keeping an encoded copy of the string alive together with the original unicode string. Otherwise, there would be no way to limit the lifetime of the encoded string in any sensible way, thus rendering any attempt to extract a C string pointer from it a dangerous endeavour." Cython plays it safe and we can't live with ASCII-only; reverting to our earlier "hacks" for string conversion. This reverts commit b547ff2aa2064b98021d6f458cfc3d44a9936544. Conflicts: efl/elementary/entry.pyx efl/elementary/object.pyx
Diffstat (limited to 'efl/emotion')
-rw-r--r--efl/emotion/efl.emotion.pyx10
1 files changed, 10 insertions, 0 deletions
diff --git a/efl/emotion/efl.emotion.pyx b/efl/emotion/efl.emotion.pyx
index be3a697..cbbde81 100644
--- a/efl/emotion/efl.emotion.pyx
+++ b/efl/emotion/efl.emotion.pyx
@@ -15,6 +15,7 @@
15# You should have received a copy of the GNU Lesser General Public License 15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>. 16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
17 17
18from cpython cimport PyUnicode_AsUTF8String
18from libc.stdint cimport uintptr_t 19from libc.stdint cimport uintptr_t
19 20
20from efl.eo cimport object_from_instance, _object_mapping_register, \ 21from efl.eo cimport object_from_instance, _object_mapping_register, \
@@ -169,6 +170,7 @@ def extension_may_play_get(filename):
169 .. versionadded:: 1.8 170 .. versionadded:: 1.8
170 171
171 """ 172 """
173 if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename)
172 return bool(emotion_object_extension_may_play_get( 174 return bool(emotion_object_extension_may_play_get(
173 <const char *>filename if filename is not None else NULL)) 175 <const char *>filename if filename is not None else NULL))
174 176
@@ -203,6 +205,8 @@ cdef class Emotion(evasObject):
203 self._set_obj(emotion_object_add(canvas.obj)) 205 self._set_obj(emotion_object_add(canvas.obj))
204 _register_decorated_callbacks(self) 206 _register_decorated_callbacks(self)
205 207
208 if isinstance(module_name, unicode):
209 module_name = PyUnicode_AsUTF8String(module_name)
206 if emotion_object_init(self.obj, 210 if emotion_object_init(self.obj,
207 <const char *>module_name if module_name is not None else NULL) == 0: 211 <const char *>module_name if module_name is not None else NULL) == 0:
208 raise EmotionModuleInitError("failed to initialize module '%s'" % 212 raise EmotionModuleInitError("failed to initialize module '%s'" %
@@ -248,12 +252,14 @@ cdef class Emotion(evasObject):
248 return _ctouni(emotion_object_file_get(self.obj)) 252 return _ctouni(emotion_object_file_get(self.obj))
249 253
250 def __set__(self, value): 254 def __set__(self, value):
255 if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
251 emotion_object_file_set(self.obj, 256 emotion_object_file_set(self.obj,
252 <const char *> value if value is not None else NULL) 257 <const char *> value if value is not None else NULL)
253 258
254 def file_get(self): 259 def file_get(self):
255 return _ctouni(emotion_object_file_get(self.obj)) 260 return _ctouni(emotion_object_file_get(self.obj))
256 def file_set(self, file_name): 261 def file_set(self, file_name):
262 if isinstance(file_name, unicode): file_name = PyUnicode_AsUTF8String(file_name)
257 emotion_object_file_set(self.obj, 263 emotion_object_file_set(self.obj,
258 <const char *> file_name if file_name is not None else NULL) 264 <const char *> file_name if file_name is not None else NULL)
259 265
@@ -429,12 +435,14 @@ cdef class Emotion(evasObject):
429 return _ctouni(emotion_object_video_subtitle_file_get(self.obj)) 435 return _ctouni(emotion_object_video_subtitle_file_get(self.obj))
430 436
431 def __set__(self, value): 437 def __set__(self, value):
438 if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
432 emotion_object_video_subtitle_file_set(self.obj, 439 emotion_object_video_subtitle_file_set(self.obj,
433 <const char *>value if value is not None else NULL) 440 <const char *>value if value is not None else NULL)
434 441
435 def video_subtitle_file_get(self): 442 def video_subtitle_file_get(self):
436 return _ctouni(emotion_object_video_subtitle_file_get(self.obj)) 443 return _ctouni(emotion_object_video_subtitle_file_get(self.obj))
437 def video_subtitle_file_set(self, file_name): 444 def video_subtitle_file_set(self, file_name):
445 if isinstance(file_name, unicode): file_name = PyUnicode_AsUTF8String(file_name)
438 emotion_object_video_subtitle_file_set(self.obj, 446 emotion_object_video_subtitle_file_set(self.obj,
439 <const char *>file_name if file_name is not None else NULL) 447 <const char *>file_name if file_name is not None else NULL)
440 448
@@ -1109,6 +1117,7 @@ cdef class Emotion(evasObject):
1109 e = intern(event) 1117 e = intern(event)
1110 lst = self._emotion_callbacks.setdefault(e, []) 1118 lst = self._emotion_callbacks.setdefault(e, [])
1111 if not lst: 1119 if not lst:
1120 if isinstance(event, unicode): event = PyUnicode_AsUTF8String(event)
1112 evas_object_smart_callback_add(self.obj, 1121 evas_object_smart_callback_add(self.obj,
1113 <const char *>event if event is not None else NULL, 1122 <const char *>event if event is not None else NULL,
1114 _emotion_callback, <void *>e) 1123 _emotion_callback, <void *>e)
@@ -1142,6 +1151,7 @@ cdef class Emotion(evasObject):
1142 if lst: 1151 if lst:
1143 return 1152 return
1144 self._emotion_callbacks.pop(event) 1153 self._emotion_callbacks.pop(event)
1154 if isinstance(event, unicode): event = PyUnicode_AsUTF8String(event)
1145 evas_object_smart_callback_del(self.obj, 1155 evas_object_smart_callback_del(self.obj,
1146 <const char *>event if event is not None else NULL, 1156 <const char *>event if event is not None else NULL,
1147 _emotion_callback) 1157 _emotion_callback)