Enlightenment CVS committal Author : barbieri Project : e17 Module : proto
Dir : e17/proto/python-efl/python-evas/evas Modified Files: evas.c_evas.pyx Log Message: Dynamically map C-objects to Python-objects. =================================================================== RCS file: /cvs/e/e17/proto/python-efl/python-evas/evas/evas.c_evas.pyx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- evas.c_evas.pyx 11 May 2007 01:47:03 -0000 1.7 +++ evas.c_evas.pyx 12 Jul 2007 19:11:53 -0000 1.8 @@ -46,9 +46,33 @@ return Canvas_from_instance(<Evas *>ptr) +cdef object object_mapping + +object_mapping = { + "image": Image, + "text": Text, + "rectangle": Rectangle, + "line": Line, + "gradient": Gradient, + "polygon": Polygon, + } + + +def _object_mapping_register(char *name, cls): + if name in object_mapping: + raise ValueError("object type name '%s' already registered." % name) + object_mapping[name] = cls + + +def _object_mapping_unregister(char *name): + del object_mapping[name] + + cdef Object Object_from_instance(Evas_Object *obj): cdef void *data cdef Object o + cdef char *t + cdef Canvas c if obj == NULL: return None @@ -57,7 +81,10 @@ if data != NULL: o = <Object>data else: - o = Object(Canvas_from_instance(evas_object_evas_get(obj))) + t = evas_object_type_get(obj) + c = Canvas_from_instance(evas_object_evas_get(obj)) + cls = object_mapping.get(t, Object) + o = cls(c) o._set_obj(obj) return o ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs