[Pyrex] Inheritance of external extension type?
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed May 2 09:16:43 UTC 2007
Gustavo Sverzut Barbieri wrote:
> 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
These should be named
evas.c_evas.pyx
evas.c_evas.pxd
> 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
Get rid of this file. You should *not* have a second copy of
evas.c_evas.pxd. The whole point of .pxd files is that the
definition is written once and shared by all .pyx files that
use it.
I've attached some example files to show how to do it.
By the way, you don't have to use "public" just so you can
share extension types between Pyrex modules. You only need
to use it if you want to expose your extension type to
non-Pyrex C code. If you don't need to do that, you can
write the definition in evas.c_evas.pxd simply as
cdef class Object:
...
Also, you never need to declare C methods as "public".
--
Greg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.zip
Type: application/zip
Size: 923 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20070502/00d17823/attachment.zip
More information about the Pyrex
mailing list