I am trying to make a python wrapper for a C library using ctypes. The library has functions which require a pointer to a structure to be passed, which acts as a handle for future calls.
This structure has pointers to another internal structure that further has pointers to other structures.
typedef struct varnam { char *scheme_file; char *suggestions_file; struct varnam_internal *internal; } varnam; The varnam_internal structure has pointers to an sqlite database and so forth
struct varnam_internal { sqlite3 *db; sqlite3 *known_words; struct varray_t *r; struct token *v; ... } I tried ignoring the varnam_internal structure according to this SO answer. Something like
class Varnam(Structure): __fields__ = [("scheme_file",c_char_p), ("suggestions_file",c_char_p),("internal",c_void_p)] But this does not seem to work because I think the library needs to allocate varnam_internal for functioning properly.
Should I implement all the dependent structures in python? Is ctypes suitable for wrapping libraries like this? I have read about alternatives like Cython but I have no experience with Cython so is this doable in it?