Enlightenment CVS committal Author : barbieri Project : e17 Module : proto
Dir : e17/proto/python-efl/python-evas/evas Modified Files: __init__.py evas.c_evas_canvas.pxi evas.c_evas_object.pxi evas.c_evas_object_smart.pxi evas.c_evas_rect.pxi Log Message: Fix usage of Pyrex __new__, it was causing problems with inheritance. Pyrex's __new__() method is confusing, you cannot raise exceptions and every method should have the same signature, otherwise you'll get error from the parent class. This method, AFAIU is just meant to ensure things are initialized once. I moved my code to be executed from __init__(), then I can do regular python things, as check for correct type of parameters. =================================================================== RCS file: /cvs/e/e17/proto/python-efl/python-evas/evas/__init__.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- __init__.py 13 May 2007 07:25:14 -0000 1.8 +++ __init__.py 19 Jul 2007 15:06:44 -0000 1.9 @@ -74,89 +74,85 @@ Rect = c_evas.Rect class Canvas(c_evas.Canvas): - def __new__(type, method=None, size=None, viewport=None): - obj = c_evas.Canvas.__new__(type) - obj._new_evas() + def __init__(self, method=None, size=None, viewport=None): + c_evas.Canvas.__init__(self) + self._new_evas() if method: - obj.output_method_set(method) + self.output_method_set(method) if size: - obj.size_set(*size) + self.size_set(*size) if viewport: - obj.viewport_set(*viewport) - return obj + self.viewport_set(*viewport) + class SmartObject(c_evas.SmartObject): - def __new__(type, canvas, size=None, pos=None, geometry=None, color=None, - name=None, *args, **kargs): - if type is SmartObject or type is c_evas.SmartObject: + def __init__(self, canvas, size=None, pos=None, geometry=None, color=None, + name=None): + if type(self) is SmartObject or type(self) is c_evas.SmartObject: raise TypeError("Must not instantiate SmartObject, but subclasses") - obj = c_evas.SmartObject.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(size=size, pos=pos, geometry=geometry, - color=color, name=name) - return obj + c_evas.SmartObject.__init__(self, canvas) + self._new_obj() + self._set_common_params(size=size, pos=pos, geometry=geometry, + color=color, name=name) class Rectangle(c_evas.Rectangle): - def __new__(type, canvas, size=None, pos=None, geometry=None, color=None, + def __init__(self, canvas, size=None, pos=None, geometry=None, color=None, name=None): - obj = c_evas.Rectangle.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(size=size, pos=pos, geometry=geometry, - color=color, name=name) - return obj + c_evas.Rectangle.__init__(self, canvas) + self._new_obj() + self._set_common_params(size=size, pos=pos, geometry=geometry, + color=color, name=name) class Line(c_evas.Line): - def __new__(type, canvas, start=None, end=None, size=None, pos=None, + def __init__(self, canvas, start=None, end=None, size=None, pos=None, geometry=None, color=None, name=None): - obj = c_evas.Line.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(start=start, end=end, size=size, pos=pos, - geometry=geometry, color=color, name=name) - return obj + c_evas.Line.__init__(self, canvas) + self._new_obj() + self._set_common_params(start=start, end=end, size=size, pos=pos, + geometry=geometry, color=color, name=name) class Image(c_evas.Image): - def __new__(type, canvas, file=None, size=None, pos=None, geometry=None, - color=None, name=None): - obj = c_evas.Image.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(file=file, size=size, pos=pos, - geometry=geometry, color=color, name=name) - return obj + def __init__(self, canvas, file=None, size=None, pos=None, geometry=None, + color=None, name=None): + if not isinstance(canvas, c_evas.Canvas): + raise TypeError("First argument must be evas.Canvas") + c_evas.Image.__init__(self, canvas) + self._new_obj() + self._set_common_params(file=file, size=size, pos=pos, + geometry=geometry, color=color, name=name) class Gradient(c_evas.Gradient): - def __new__(type, canvas, size=None, pos=None, geometry=None, color=None, + def __init__(self, canvas, size=None, pos=None, geometry=None, color=None, name=None): - obj = c_evas.Gradient.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(size=size, pos=pos, geometry=geometry, - color=color, name=name) - return obj + c_evas.Gradient.__init__(self, canvas) + self._new_obj() + self._set_common_params(size=size, pos=pos, geometry=geometry, + color=color, name=name) class Polygon(c_evas.Polygon): - def __new__(type, canvas, points=None, size=None, pos=None, geometry=None, + def __init__(self, canvas, points=None, size=None, pos=None, geometry=None, color=None, name=None): - obj = c_evas.Polygon.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(points=points, size=size, pos=pos, - geometry=geometry, color=color, name=name) - return obj + c_evas.Polygon.__init__(self, canvas) + self._new_obj() + self._set_common_params(points=points, size=size, pos=pos, + geometry=geometry, color=color, name=name) class Text(c_evas.Text): - def __new__(type, canvas, text=None, font=None, font_source=None, + def __init__(self, canvas, text=None, font=None, font_source=None, style=None, shadow_color=None, glow_color=None, glow2_color=None, outline_color=None, size=None, pos=None, geometry=None, color=None, name=None): - obj = c_evas.Text.__new__(type, canvas) - obj._new_obj() - obj._set_common_params(text=text, font=font, font_source=font_source, - style=style, shadow_color=shadow_color, - glow_color=glow_color, glow2_color=glow2_color, - outline_color=outline_color, size=size, pos=pos, - geometry=geometry, color=color, name=name) - return obj + c_evas.Text.__init__(self, canvas) + self._new_obj() + self._set_common_params(text=text, font=font, font_source=font_source, + style=style, shadow_color=shadow_color, + glow_color=glow_color, glow2_color=glow2_color, + outline_color=outline_color, size=size, + pos=pos, geometry=geometry, color=color, + name=name) =================================================================== RCS file: /cvs/e/e17/proto/python-efl/python-evas/evas/evas.c_evas_canvas.pxi,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- evas.c_evas_canvas.pxi 13 Jul 2007 19:11:38 -0000 1.7 +++ evas.c_evas_canvas.pxi 19 Jul 2007 15:06:44 -0000 1.8 @@ -1,7 +1,7 @@ # This file is included verbatim by c_evas.pyx cdef public class Canvas [object PyEvasCanvas, type PyEvasCanvas_Type]: - def __new__(self): + def __new__(self, *a, **ka): self.obj = NULL def __dealloc__(self): =================================================================== RCS file: /cvs/e/e17/proto/python-efl/python-evas/evas/evas.c_evas_object.pxi,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- evas.c_evas_object.pxi 6 May 2007 17:26:56 -0000 1.6 +++ evas.c_evas_object.pxi 19 Jul 2007 15:06:44 -0000 1.7 @@ -9,11 +9,14 @@ cdef public class Object [object PyEvasObject, type PyEvasObject_Type]: - def __new__(self, Canvas evas): + def __new__(self, *a, **ka): self.obj = NULL - self._evas = evas + self._evas = None self._data = dict() self._callbacks = [None] * evas_event_callbacks_len + + def __init__(self, Canvas evas not None): + self._evas = evas def __str__(self): return "%s(0x%x, type=%r, refcount=%d, Evas_Object=0x%x)" % \ =================================================================== RCS file: /cvs/e/e17/proto/python-efl/python-evas/evas/evas.c_evas_object_smart.pxi,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- evas.c_evas_object_smart.pxi 5 Jun 2007 15:27:01 -0000 1.8 +++ evas.c_evas_object_smart.pxi 19 Jul 2007 15:06:44 -0000 1.9 @@ -63,7 +63,7 @@ obj = <SmartObject>Object_from_instance(o) other = Object_from_instance(clip) if obj._m_clip_set is not None: - obj._m_clip_set(obj) + obj._m_clip_set(obj, other) cdef void _smart_object_clip_unset(Evas_Object *o): @@ -83,7 +83,11 @@ ei = <object>event_info lst = obj._smart_callbacks[event] for func, args, kargs in lst: - func(obj, ei, *args, **kargs) + try: + func(obj, ei, *args, **kargs) + except Exception, e: + import traceback + traceback.print_exc() cdef long _smart_object_class_new(char *name) except 0: @@ -176,7 +180,7 @@ implementation, you may want to remove and replace it with something else. """ - def __new__(self, Canvas evas): + def __new__(self, *a, **ka): self._smart_callbacks = dict() cls = self.__class__ self._m_old_delete = self.delete =================================================================== RCS file: /cvs/e/e17/proto/python-efl/python-evas/evas/evas.c_evas_rect.pxi,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- evas.c_evas_rect.pxi 5 May 2007 02:20:31 -0000 1.2 +++ evas.c_evas_rect.pxi 19 Jul 2007 15:06:44 -0000 1.3 @@ -35,7 +35,7 @@ * inflate """ - def __new__(self, *args, **kargs): + def __init__(self, *args, **kargs): cdef Rect other self.x0 = 0 self.y0 = 0 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs