generic way to access C++ libs?
Diez B. Roggisch
deetsNOSPAM at web.de
Fri Nov 5 12:20:36 EST 2004
More information about the Python-list mailing list
Fri Nov 5 12:20:36 EST 2004
- Previous message (by thread): generic way to access C++ libs?
- Next message (by thread): generic way to access C++ libs?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> What I would like to have is some module (or whatever), with which I can > say "load this C++ library", and then, "create that C++ object" or "call > method x of C++ object y". C++ has no concept of runtime type information (except from saying "this is of class X). This sort of information is known as "reflection" in java or python, and that allows for late time bindings to those languages. In other words: you can create on the fly wrappers for them. But c++ lacking this means that you need to feed the specification of objecst - the header files - to some generator. WHich is exactly what happens in the wrapper generators like swig and sip. I never toyed around with boost, but I don't believe they made the impossible possible. So to answer your question: Its not possible. There are other reasons as well: C++ defines no binary layout of objects, the result is that a lib complied with different compilers (gcc, intel, msvc) results in incompatible binaries. So even if one would ship the lib with the header files: to actually generate the wrappers, the appropriate compliler has to be used. And as you rarely find compilers of different kinds on end user machines, you'll have to do it on the developers machine. > Without doing anything else (such as recompiling the library or generating > wrappers). As I just said: not doable. Third thing is that differences in language design make it necessary to invest developer time in creating wrappings: In c++ you can pass arguments by a pointer to them, allowing to modify them in the callers stackframe (or whereever they live). As this is not possible in python, you need to work around this, usually by returning a tuple of modified values in addition to the result of the method/function itself. So there are strong limits on automatically generationg wrappers - a minmimum of work has to be done. -- Regards, Diez B. Roggisch
- Previous message (by thread): generic way to access C++ libs?
- Next message (by thread): generic way to access C++ libs?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list