[Pyrex] Inheritance of external extension type?

Gustavo Sverzut Barbieri barbieri at gmail.com
Wed May 2 03:27:43 UTC 2007


How should I proceed to create an extension type that inherits an
external extension type?

I have the following structure:

   python-evas/evas/   # get installed as "evas" under site-packages
      __init__.py     # sugar over c_evas.py
      c_evas.pyx
      c_evas.pxd
      c_evas.h  # generated by pyrex

here I define "Object", my base object, to be exported, defined as:

   cdef public class Object [object PyEvasObject, type PyEvasObject_Type]:
       cdef Evas_Object *obj
       cdef Canvas _evas
       cdef object _data
       cdef object _callbacks
       cdef public int _unset_obj(self) except 0
       cdef public int _set_obj(self, Evas_Object *obj) except 0


  python-edje/edje/   # get installed as "edje" under site-pacakges
      __init__.py     # sugar over c_edje.py
      c_edje.pyx
      c_edje.pxd
      evas.c_evas.pxd
      c_evas.h  # copy from python-evas/evas/c_evas.h

evas.c_evas.pxd files has:

   cdef extern from "c_evas.h":
       cdef class evas.c_evas.Object [object PyEvasObject]:
           cdef Evas_Object *obj
           cdef Canvas _evas
           cdef object _data
           cdef object _callbacks
           cdef int _unset_obj(self) except 0
           cdef int _set_obj(self, Evas_Object *obj) except 0


c_edje.pxd has:

   cimport evas.c_evas
   import evas.c_evas

   cdef public class Edje(evas.c_evas.Object) [object PyEdjeObject,
type PyEdjeObject_Type]:
       cdef object _text_change_cb
       cdef object _message_handler_cb


But this doesn't work as expected, showing these compiler errors:

edje/c_edje.c:152: error: field '__pyx_base' has incomplete type
edje/c_edje.c:7072: error: '__pyx_vtabptr_4evas_6c_evas_Object'
undeclared (first use in this function)

The first error is about using "struct
__pyx_vtabstruct_4evas_6c_evas_Object", that is not defined in
c_edje.c or in c_evas.h. Actually, it's not defined even in c_evas.c,
since there it doesn't have "evas" namespace and is:

   struct __pyx_vtabstruct_6c_evas_Object

instead of:

   struct __pyx_vtabstruct_4evas_6c_evas_Object

The second error is about access to an inexistent variable. This
variable is present in c_evas.c, but it's marked as "static", so
unaccessible, no matter if I put it in "c_evas.h" as "extern".

what's wrong with this?

Thanks,

-- 
Gustavo Sverzut Barbieri
--------------------------------------
Jabber: barbieri at gmail.com
   MSN: barbieri at gmail.com
  ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010



More information about the Pyrex mailing list