[Pyrex] Inheriting from an externally defined extension type
Konrad Hinsen
hinsen at cnrs-orleans.fr
Fri Feb 6 12:32:52 CET 2004
Consider the following code:
cdef extern from "spam.h":
ctypedef class spam.Spam [object PySpamObject]:
cdef int spam
cdef class SpamAndEggs(Spam):
cdef int eggs
def __init__(self, spam, eggs):
self.spam = spam
self.eggs = eggs
cdef cook(self):
print "Frying ", spam, " spam and ", eggs, "eggs."
Compiling this with Pyrex 0.9 yields a C module containing
struct __pyx_vtabstruct_4spam_SpamAndEggs {
struct None __pyx_base;
PyObject *((*cook)(struct __pyx_obj_4spam_SpamAndEggs *));
};
There is no "struct None" defined, so the C compiler complains.
A messge in the archive by Paul Prescod from January 14 proposes a patch for
this problem. After this patch, the above code becomes:
struct __pyx_vtabstruct_4spam_SpamAndEggs {
struct __pyx_vtabstruct_4spam_Spam __pyx_base;
PyObject *((*cook)(struct __pyx_obj_4spam_SpamAndEggs *));
};
Unfortunately, struct __pyx_vtabstruct_4spam_Spam isn't defined either,
because Spam is not a class generated by Pyrex. Later in the C code, there
are two references to
__pyx_vtabptr_4spam_Spam;
which doesn't exist either, for the same reason.
Does anyone have a solution or a workaround?
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
More information about the Pyrex
mailing list