[Pyrex] wrapping structures that can not be created directly
Phil Frost
indigo at bitglue.com
Sat Dec 11 07:15:17 CET 2004
I am trying to wrap a C library that has a number of structures that are
not allocated directly, but obtained by methods on other structures.
In this case, it's a filesystem library. There is a structure and set of
associated functions for a directory, but a directory can only be
obtained by 'getroot' on a filesystem or 'lookup' on an existing
directory. What I want to do is something like:
cdef class Directory:
cdef dir_t *dir
def __new__(self, dir_t *dir):
self.dir = dir
This way, a Directory can never be created without self.dir being a
valid pointer to dir_t. I'd like to avoid checking that self.dir is not
NULL in each method if possible.
How would you suggest dealing with this situation?
More information about the Pyrex
mailing list