On Tue, Dec 8, 2009 at 5:55 PM, Nikolaus Rath <nikol...@rath.org> wrote: > > Hello, > > Is it possible to use Py++ to "convert" structures from a C header, say > > ,---- > | struct flock > | { > | short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ > | short int l_whence; /* Where `l_start' is relative to (like `lseek'). > */ > | #ifndef __USE_FILE_OFFSET64 > | __off_t l_start; /* Offset where the lock begins. */ > | __off_t l_len; /* Size of the locked area; zero means until EOF. > */ > | #else > | __off64_t l_start; /* Offset where the lock begins. */ > | __off64_t l_len; /* Size of the locked area; zero means until EOF. > */ > | #endif > | __pid_t l_pid; /* Process holding the lock. */ > | }; > `---- > > from fcntl.h into the corresponding ctypes Structure, > > ,---- > | class flock_t(Structure): > | _fields_ = [ > | ('l_type', c_short), > | ('l_whence', c_short), > | ('l_start', c_uint64), > | ('l_len', c_uint64), > | ('l_pid', c_int) > | ] > `---- > > while automatically taking into account the #ifdefs and how types like > off_t and pid_t are actually defined on the target system?
No, the generated code, will only work on the platform with the same struct definition. > The introduction on > http://www.language-binding.net/pyplusplus/pyplusplus.html says that > Py++ can act as a code generator for ctypes, but I could not find any > documentation for the sort of application that I describe here. Unfortunately I don't have time to write one. I am extremely busy this days. You can take a look on gmplib example: http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/examples/gmplib_dev/ It is fully working. You also can take a look on "wrap_library" "executable": http://sourceforge.net/projects/pygccxml/files/ctypes%20code%20generator/initial%20release/wrap_library.zip/download It creates ctypes code, using default settings. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig