Roman Yakovenko <roman.yakove...@gmail.com> writes: > 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.
So as long as I generate the code on the local platform (e.g. during package installation) I will be fine, right? That's enough for me. >> 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. This looks really interesting. I will try to modify that for use with my library. Thanks for the link! > 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. This file seems to contain only lots of binary files, but no documentation or .py files, so I am a bit lost. What exactly is it supposed to do? Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig