Hi,

Gary Furnish wrote:
> Ok, I have a working patch, but it keeps failing in lxml in rather
> mysterious ways (after fixing your reported bugs)

> cdef extern from "lxml.etree_api.h":
> 
>     # first function to call!
>     cdef int import_lxml__etree() except -1
> 
>     cdef class lxml.etree._Document [ object LxmlDocument ]:
>         cdef tree.xmlDoc* _c_doc
> 
>     cdef class lxml.etree._Element [ object LxmlElement ]:
>         cdef _Document _doc
>         cdef tree.xmlNode* _c_node
> 
>     cdef class lxml.etree.ElementBase(_Element) [ object LxmlElementBase ]:
>         pass
> 

> Can you elaborate on how exactly this works?  It is by far the most
> mysterious code I have ever seen in Cython.

Cython generates a header file for the lxml.etree module ("lxml.etree_api.h")
that contains the "public" extension classes (or all? don't remember) and the
"public api" functions. The code excerpt above is from a .pxd file that
redefines the classes and functions used in lxml as a public API, so that
other Cython modules (especially lxml.objectify) can call into lxml.etree. The
advantage is that the API does not contain the C methods of the types, which
lxml does not export.

Does that make it clearer?

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to