summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2012-06-10 08:11:24 +0000
committerKai Huuhko <kai.huuhko@gmail.com>2012-06-10 08:11:24 +0000
commitd852661525c982e35bb5b47868060ad4ece34c91 (patch)
treefd68a1194b6ca2e92f200d83be9a34792569d844
parente9b1ca8f3b6d0095b47de162b592b967ff0e10bc (diff)
python-evas: Get rid of hacks.
SVN revision: 71892
-rw-r--r--evas/evas.c_evas.pyx13
-rw-r--r--evas/evas.c_evas_canvas.pxi2
-rw-r--r--evas/evas.c_evas_object.pxi11
-rw-r--r--evas/evas.c_evas_object_box.pxi7
-rw-r--r--evas/evas.c_evas_object_image.pxi20
-rw-r--r--evas/evas.c_evas_object_line.pxi8
-rw-r--r--evas/evas.c_evas_object_polygon.pxi8
-rw-r--r--evas/evas.c_evas_object_rectangle.pxi8
-rw-r--r--evas/evas.c_evas_object_smart.pxi16
-rw-r--r--evas/evas.c_evas_object_text.pxi8
-rw-r--r--evas/evas.c_evas_object_textblock.pxi7
-rw-r--r--m4/cython.m42
-rw-r--r--m4/python.m44
13 files changed, 44 insertions, 70 deletions
diff --git a/evas/evas.c_evas.pyx b/evas/evas.c_evas.pyx
index e5231ad..311cefc 100644
--- a/evas/evas.c_evas.pyx
+++ b/evas/evas.c_evas.pyx
@@ -241,7 +241,7 @@ def color_parse(desc, is_premul=None):
241 b = 0 241 b = 0
242 a = 0 242 a = 0
243 243
244 if isinstance(desc, basestring): 244 if isinstance(desc, str):
245 if not desc or desc[0] != "#": 245 if not desc or desc[0] != "#":
246 raise ValueError("Invalid color description") 246 raise ValueError("Invalid color description")
247 desc_len = len(desc) 247 desc_len = len(desc)
@@ -369,16 +369,6 @@ class EvasLoadError(Exception):
369 self.key = key 369 self.key = key
370 Exception.__init__(self, "%s (file=%s, key=%s)" % (msg, filename, key)) 370 Exception.__init__(self, "%s (file=%s, key=%s)" % (msg, filename, key))
371 371
372
373cdef extern from "Python.h":
374 ctypedef struct PyTypeObject:
375 PyTypeObject *ob_type
376
377cdef void _install_metaclass(PyTypeObject *ctype, object metaclass):
378 Py_INCREF(metaclass)
379 ctype.ob_type = <PyTypeObject*>metaclass
380
381
382class EvasObjectMeta(type): 372class EvasObjectMeta(type):
383 def __init__(cls, name, bases, dict_): 373 def __init__(cls, name, bases, dict_):
384 type.__init__(cls, name, bases, dict_) 374 type.__init__(cls, name, bases, dict_)
@@ -398,7 +388,6 @@ class EvasObjectMeta(type):
398 evt = getattr(val, "evas_event_callback") 388 evt = getattr(val, "evas_event_callback")
399 append((name, evt)) 389 append((name, evt))
400 390
401
402include "evas.c_evas_rect.pxi" 391include "evas.c_evas_rect.pxi"
403include "evas.c_evas_canvas_callbacks.pxi" 392include "evas.c_evas_canvas_callbacks.pxi"
404include "evas.c_evas_canvas.pxi" 393include "evas.c_evas_canvas.pxi"
diff --git a/evas/evas.c_evas_canvas.pxi b/evas/evas.c_evas_canvas.pxi
index f84e694..3ffe964 100644
--- a/evas/evas.c_evas_canvas.pxi
+++ b/evas/evas.c_evas_canvas.pxi
@@ -184,7 +184,7 @@ cdef public class Canvas [object PyEvasCanvas, type PyEvasCanvas_Type]:
184 184
185 if isinstance(method, (int, long)): 185 if isinstance(method, (int, long)):
186 engine_id = method 186 engine_id = method
187 elif isinstance(method, basestring): 187 elif isinstance(method, str):
188 engine_id = evas_render_method_lookup(method) 188 engine_id = evas_render_method_lookup(method)
189 else: 189 else:
190 raise TypeError("method must be integer or string") 190 raise TypeError("method must be integer or string")
diff --git a/evas/evas.c_evas_object.pxi b/evas/evas.c_evas_object.pxi
index e1908cb..d44443d 100644
--- a/evas/evas.c_evas_object.pxi
+++ b/evas/evas.c_evas_object.pxi
@@ -109,7 +109,7 @@ cdef _object_del_callback_from_list(Object obj, int type, func):
109 return False 109 return False
110 110
111 111
112cdef public class Object [object PyEvasObject, type PyEvasObject_Type]: 112cdef public class Object (object) [object PyEvasObject, type PyEvasObject_Type]:
113 """Basic Graphical Object (or actor). 113 """Basic Graphical Object (or actor).
114 114
115 Objects are managed by L{Canvas} in a non-immediate way, that is, 115 Objects are managed by L{Canvas} in a non-immediate way, that is,
@@ -217,6 +217,9 @@ cdef public class Object [object PyEvasObject, type PyEvasObject_Type]:
217 anti_alias_set, anti_alias_get, anti_alias, pointer_mode_set, 217 anti_alias_set, anti_alias_get, anti_alias, pointer_mode_set,
218 pointer_mode_get, pointer_mode 218 pointer_mode_get, pointer_mode
219 """ 219 """
220
221 __metaclass__ = EvasObjectMeta
222
220 def __cinit__(self, *a, **ka): 223 def __cinit__(self, *a, **ka):
221 self.obj = NULL 224 self.obj = NULL
222 self.evas = None 225 self.evas = None
@@ -1655,6 +1658,6 @@ cdef public class Object [object PyEvasObject, type PyEvasObject_Type]:
1655 return self.parent_get() 1658 return self.parent_get()
1656 1659
1657 1660
1658cdef extern from "Evas.h": # hack to force type to be known 1661#cdef extern from "Evas.h": # hack to force type to be known
1659 cdef PyTypeObject PyEvasObject_Type # hack to install metaclass 1662 #cdef PyTypeObject PyEvasObject_Type # hack to install metaclass
1660_install_metaclass(&PyEvasObject_Type, EvasObjectMeta) 1663#_install_metaclass(&PyEvasObject_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_box.pxi b/evas/evas.c_evas_object_box.pxi
index 8f98ec7..334aa42 100644
--- a/evas/evas.c_evas_object_box.pxi
+++ b/evas/evas.c_evas_object_box.pxi
@@ -23,6 +23,9 @@ cdef public class Box(Object) [object PyEvasBox, type PyEvasBox_Type]:
23 """Box(canvas, size=None, pos=None, geometry=None, color=None, name=None) -> Box instance 23 """Box(canvas, size=None, pos=None, geometry=None, color=None, name=None) -> Box instance
24 24
25 """ 25 """
26
27 __metaclass__ = EvasObjectMeta
28
26 def __init__(self, Canvas canvas not None, **kargs): 29 def __init__(self, Canvas canvas not None, **kargs):
27 Object.__init__(self, canvas) 30 Object.__init__(self, canvas)
28 if self.obj == NULL: 31 if self.obj == NULL:
@@ -84,7 +87,3 @@ cdef public class Box(Object) [object PyEvasBox, type PyEvasBox_Type]:
84 87
85 def remove_all(self, Eina_Bool clear): 88 def remove_all(self, Eina_Bool clear):
86 return evas_object_box_remove_all(self.obj, clear) 89 return evas_object_box_remove_all(self.obj, clear)
87
88cdef extern from "Evas.h": # hack to force type to be known
89 cdef PyTypeObject PyEvasBox_Type # hack to install metaclass
90_install_metaclass(&PyEvasBox_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_image.pxi b/evas/evas.c_evas_object_image.pxi
index 22fbae9..3fb83de 100644
--- a/evas/evas.c_evas_object_image.pxi
+++ b/evas/evas.c_evas_object_image.pxi
@@ -134,6 +134,9 @@ cdef public class Image(Object) [object PyEvasImage, type PyEvasImage_Type]:
134 pixels_dirty, image_data_set, image_data_update_add 134 pixels_dirty, image_data_set, image_data_update_add
135 135
136 """ 136 """
137
138 __metaclass__ = EvasObjectMeta
139
137 def __init__(self, Canvas canvas not None, **kargs): 140 def __init__(self, Canvas canvas not None, **kargs):
138 Object.__init__(self, canvas) 141 Object.__init__(self, canvas)
139 if self.obj == NULL: 142 if self.obj == NULL:
@@ -142,7 +145,7 @@ cdef public class Image(Object) [object PyEvasImage, type PyEvasImage_Type]:
142 145
143 def _set_common_params(self, file=None, **kargs): 146 def _set_common_params(self, file=None, **kargs):
144 if file: 147 if file:
145 if isinstance(file, basestring): 148 if isinstance(file, str):
146 file = (file, None) 149 file = (file, None)
147 self.file_set(*file) 150 self.file_set(*file)
148 Object._set_common_params(self, **kargs) 151 Object._set_common_params(self, **kargs)
@@ -184,7 +187,7 @@ cdef public class Image(Object) [object PyEvasImage, type PyEvasImage_Type]:
184 return self.file_get() 187 return self.file_get()
185 188
186 def __set__(self, value): 189 def __set__(self, value):
187 if isinstance(value, basestring): 190 if isinstance(value, str):
188 value = (value, None) 191 value = (value, None)
189 self.file_set(*value) 192 self.file_set(*value)
190 193
@@ -611,11 +614,6 @@ cdef public class Image(Object) [object PyEvasImage, type PyEvasImage_Type]:
611 self.event_callback_del(EVAS_CALLBACK_IMAGE_UNLOADED, func) 614 self.event_callback_del(EVAS_CALLBACK_IMAGE_UNLOADED, func)
612 615
613 616
614cdef extern from "Evas.h": # hack to force type to be known
615 cdef PyTypeObject PyEvasImage_Type # hack to install metaclass
616_install_metaclass(&PyEvasImage_Type, EvasObjectMeta)
617
618
619cdef void _cb_on_filled_image_resize(void *data, Evas *e, 617cdef void _cb_on_filled_image_resize(void *data, Evas *e,
620 Evas_Object *obj, 618 Evas_Object *obj,
621 void *event_info) with gil: 619 void *event_info) with gil:
@@ -630,6 +628,9 @@ cdef public class FilledImage(Image) [object PyEvasFilledImage,
630 This L{Image} subclass already calls L{Image.fill_set()} on resize so 628 This L{Image} subclass already calls L{Image.fill_set()} on resize so
631 it will match and so be scaled to fill the whole area. 629 it will match and so be scaled to fill the whole area.
632 """ 630 """
631
632 __metaclass__ = EvasObjectMeta
633
633 def __init__(self, Canvas canvas not None, **kargs): 634 def __init__(self, Canvas canvas not None, **kargs):
634 Image.__init__(self, canvas, **kargs) 635 Image.__init__(self, canvas, **kargs)
635 w, h = self.size_get() 636 w, h = self.size_get()
@@ -640,8 +641,3 @@ cdef public class FilledImage(Image) [object PyEvasFilledImage,
640 def fill_set(self, int x, int y, int w, int h): 641 def fill_set(self, int x, int y, int w, int h):
641 "Not available for this class." 642 "Not available for this class."
642 raise NotImplementedError("FilledImage doesn't support fill_set()") 643 raise NotImplementedError("FilledImage doesn't support fill_set()")
643
644
645cdef extern from "Evas.h": # hack to force type to be known
646 cdef PyTypeObject PyEvasFilledImage_Type # hack to install metaclass
647_install_metaclass(&PyEvasFilledImage_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_line.pxi b/evas/evas.c_evas_object_line.pxi
index f85f23d..8701ed0 100644
--- a/evas/evas.c_evas_object_line.pxi
+++ b/evas/evas.c_evas_object_line.pxi
@@ -24,6 +24,9 @@ cdef public class Line(Object) [object PyEvasLine, type PyEvasLine_Type]:
24 Straight line. 24 Straight line.
25 25
26 """ 26 """
27
28 __metaclass__ = EvasObjectMeta
29
27 def __init__(self, Canvas canvas not None, **kargs): 30 def __init__(self, Canvas canvas not None, **kargs):
28 Object.__init__(self, canvas) 31 Object.__init__(self, canvas)
29 if self.obj == NULL: 32 if self.obj == NULL:
@@ -138,8 +141,3 @@ cdef public class Line(Object) [object PyEvasLine, type PyEvasLine_Type]:
138 cdef int x2, y2 141 cdef int x2, y2
139 evas_object_line_xy_get(self.obj, NULL, NULL, &x2, &y2) 142 evas_object_line_xy_get(self.obj, NULL, NULL, &x2, &y2)
140 return (x2, y2) 143 return (x2, y2)
141
142
143cdef extern from "Evas.h": # hack to force type to be known
144 cdef PyTypeObject PyEvasLine_Type # hack to install metaclass
145_install_metaclass(&PyEvasLine_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_polygon.pxi b/evas/evas.c_evas_object_polygon.pxi
index af152cd..ecf66a6 100644
--- a/evas/evas.c_evas_object_polygon.pxi
+++ b/evas/evas.c_evas_object_polygon.pxi
@@ -23,6 +23,9 @@ cdef public class Polygon(Object) [object PyEvasPolygon,
23 points=None) -> Polygon instance 23 points=None) -> Polygon instance
24 24
25 """ 25 """
26
27 __metaclass__ = EvasObjectMeta
28
26 def __init__(self, Canvas canvas not None, **kargs): 29 def __init__(self, Canvas canvas not None, **kargs):
27 Object.__init__(self, canvas) 30 Object.__init__(self, canvas)
28 if self.obj == NULL: 31 if self.obj == NULL:
@@ -44,8 +47,3 @@ cdef public class Polygon(Object) [object PyEvasPolygon,
44 47
45 def points_clear(self): 48 def points_clear(self):
46 evas_object_polygon_points_clear(self.obj) 49 evas_object_polygon_points_clear(self.obj)
47
48
49cdef extern from "Evas.h": # hack to force type to be known
50 cdef PyTypeObject PyEvasPolygon_Type # hack to install metaclass
51_install_metaclass(&PyEvasPolygon_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_rectangle.pxi b/evas/evas.c_evas_object_rectangle.pxi
index 5c8f33d..155717e 100644
--- a/evas/evas.c_evas_object_rectangle.pxi
+++ b/evas/evas.c_evas_object_rectangle.pxi
@@ -22,13 +22,11 @@ cdef public class Rectangle(Object) [object PyEvasRectangle,
22 """Rectangle(canvas, size=None, pos=None, geometry=None, color=None, name=None) -> Rectangle instance 22 """Rectangle(canvas, size=None, pos=None, geometry=None, color=None, name=None) -> Rectangle instance
23 23
24 """ 24 """
25
26 __metaclass__ = EvasObjectMeta
27
25 def __init__(self, Canvas canvas not None, **kargs): 28 def __init__(self, Canvas canvas not None, **kargs):
26 Object.__init__(self, canvas) 29 Object.__init__(self, canvas)
27 if self.obj == NULL: 30 if self.obj == NULL:
28 self._set_obj(evas_object_rectangle_add(self.evas.obj)) 31 self._set_obj(evas_object_rectangle_add(self.evas.obj))
29 self._set_common_params(**kargs) 32 self._set_common_params(**kargs)
30
31
32cdef extern from "Evas.h": # hack to force type to be known
33 cdef PyTypeObject PyEvasRectangle_Type # hack to install metaclass
34_install_metaclass(&PyEvasRectangle_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_smart.pxi b/evas/evas.c_evas_object_smart.pxi
index 4afcc16..25cde0f 100644
--- a/evas/evas.c_evas_object_smart.pxi
+++ b/evas/evas.c_evas_object_smart.pxi
@@ -363,6 +363,9 @@ cdef public class SmartObject(Object) [object PyEvasSmartObject,
363 @see: L{ClippedSmartObject} 363 @see: L{ClippedSmartObject}
364 364
365 """ 365 """
366
367 __metaclass__ = EvasSmartObjectMeta
368
366 def __cinit__(self, *a, **ka): 369 def __cinit__(self, *a, **ka):
367 self._smart_callbacks = dict() 370 self._smart_callbacks = dict()
368 cls = self.__class__ 371 cls = self.__class__
@@ -686,11 +689,6 @@ cdef public class SmartObject(Object) [object PyEvasSmartObject,
686 self.member_add(obj) 689 self.member_add(obj)
687 return obj 690 return obj
688 691
689cdef extern from "Evas.h": # hack to force type to be known
690 cdef PyTypeObject PyEvasSmartObject_Type # hack to install metaclass
691_install_metaclass(&PyEvasSmartObject_Type, EvasSmartObjectMeta)
692
693
694cdef public class ClippedSmartObject(SmartObject) \ 692cdef public class ClippedSmartObject(SmartObject) \
695 [object PyEvasClippedSmartObject, type PyEvasClippedSmartObject_Type]: 693 [object PyEvasClippedSmartObject, type PyEvasClippedSmartObject_Type]:
696 """ClippedSmartObject(canvas, size=None, pos=None, geometry=None, 694 """ClippedSmartObject(canvas, size=None, pos=None, geometry=None,
@@ -718,6 +716,9 @@ cdef public class ClippedSmartObject(SmartObject) \
718 @todo: remove current code and wrap C version (now it's in evas). 716 @todo: remove current code and wrap C version (now it's in evas).
719 717
720 """ 718 """
719
720 __metaclass__ = EvasSmartObjectMeta
721
721 def __init__(self, Canvas canvas not None, **kargs): 722 def __init__(self, Canvas canvas not None, **kargs):
722 if type(self) is ClippedSmartObject: 723 if type(self) is ClippedSmartObject:
723 raise TypeError("Must not instantiate ClippedSmartObject, but " 724 raise TypeError("Must not instantiate ClippedSmartObject, but "
@@ -767,8 +768,3 @@ cdef public class ClippedSmartObject(SmartObject) \
767 def clip_unset(self): 768 def clip_unset(self):
768 "Default implementation that acts on the the clipper." 769 "Default implementation that acts on the the clipper."
769 evas_object_clip_unset(self.clipper.obj) 770 evas_object_clip_unset(self.clipper.obj)
770
771
772cdef extern from "Evas.h": # hack to force type to be known
773 cdef PyTypeObject PyEvasClippedSmartObject_Type # hack to install metaclass
774_install_metaclass(&PyEvasClippedSmartObject_Type, EvasSmartObjectMeta)
diff --git a/evas/evas.c_evas_object_text.pxi b/evas/evas.c_evas_object_text.pxi
index cfb33e3..27045d0 100644
--- a/evas/evas.c_evas_object_text.pxi
+++ b/evas/evas.c_evas_object_text.pxi
@@ -36,6 +36,9 @@ cdef public class Text(Object) [object PyEvasText, type PyEvasText_Type]:
36 char_pos_get, char_coords_get 36 char_pos_get, char_coords_get
37 37
38 """ 38 """
39
40 __metaclass__ = EvasObjectMeta
41
39 def __init__(self, Canvas canvas not None, **kargs): 42 def __init__(self, Canvas canvas not None, **kargs):
40 Object.__init__(self, canvas) 43 Object.__init__(self, canvas)
41 if self.obj == NULL: 44 if self.obj == NULL:
@@ -350,8 +353,3 @@ cdef public class Text(Object) [object PyEvasText, type PyEvasText_Type]:
350 property style_pad: 353 property style_pad:
351 def __get__(self): 354 def __get__(self):
352 return self.style_pad_get() 355 return self.style_pad_get()
353
354
355cdef extern from "Evas.h": # hack to force type to be known
356 cdef PyTypeObject PyEvasText_Type # hack to install metaclass
357_install_metaclass(&PyEvasText_Type, EvasObjectMeta)
diff --git a/evas/evas.c_evas_object_textblock.pxi b/evas/evas.c_evas_object_textblock.pxi
index c352b8f..49a859b 100644
--- a/evas/evas.c_evas_object_textblock.pxi
+++ b/evas/evas.c_evas_object_textblock.pxi
@@ -22,6 +22,9 @@ cdef public class Textblock(Object) [object PyEvasTextblock, type PyEvasTextbloc
22 text_markup=None, style=None) -> Textblock instance 22 text_markup=None, style=None) -> Textblock instance
23 23
24 """ 24 """
25
26 __metaclass__ = EvasObjectMeta
27
25 def __init__(self, Canvas canvas not None, **kargs): 28 def __init__(self, Canvas canvas not None, **kargs):
26 Object.__init__(self, canvas) 29 Object.__init__(self, canvas)
27 if self.obj == NULL: 30 if self.obj == NULL:
@@ -151,7 +154,3 @@ cdef public class Textblock(Object) [object PyEvasTextblock, type PyEvasTextbloc
151 property style_insets: 154 property style_insets:
152 def __get__(self): 155 def __get__(self):
153 return self.style_insets_get() 156 return self.style_insets_get()
154
155cdef extern from "Evas.h": # hack to force type to be known
156 cdef PyTypeObject PyEvasTextblock_Type # hack to install metaclass
157_install_metaclass(&PyEvasTextblock_Type, EvasObjectMeta)
diff --git a/m4/cython.m4 b/m4/cython.m4
index ba1d432..5353b6d 100644
--- a/m4/cython.m4
+++ b/m4/cython.m4
@@ -8,7 +8,7 @@ ifelse([$1], [], [_msg=""], [_msg=" >= $1"])
8AC_MSG_CHECKING(for Cython$_msg) 8AC_MSG_CHECKING(for Cython$_msg)
9AC_CACHE_VAL(py_cv_cython, [ 9AC_CACHE_VAL(py_cv_cython, [
10 10
11prog="import Cython.Compiler.Version; print Cython.Compiler.Version.version" 11prog="import Cython.Compiler.Version; print(Cython.Compiler.Version.version)"
12CYTHON_VERSION=`$PYTHON -c "$prog" 2>&AC_FD_CC` 12CYTHON_VERSION=`$PYTHON -c "$prog" 2>&AC_FD_CC`
13 13
14py_cv_cython=no 14py_cv_cython=no
diff --git a/m4/python.m4 b/m4/python.m4
index 02acac8..f625251 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -47,8 +47,8 @@ if test -x "$PYTHON_INCLUDES"; then
47PYTHON_INCLUDES="-I$PYTHON_INCLUDES" 47PYTHON_INCLUDES="-I$PYTHON_INCLUDES"
48else 48else
49dnl deduce PYTHON_INCLUDES 49dnl deduce PYTHON_INCLUDES
50py_prefix=`$PYTHON -c "import sys; print sys.prefix"` 50py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"`
51py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` 51py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
52if test -x "$PYTHON-config"; then 52if test -x "$PYTHON-config"; then
53PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null` 53PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
54else 54else