From: Gregory P. <gre...@ya...> - 2008-07-17 01:32:55
|
Thanks, I looked at the code you linked and the wrapper code. If you follow the calls in the code you see that you get to SWIG_TypeQueryModule and that function first looks for the mangled name and then, failing that looks for the unmangled one. In my case though it doesn't seem to work in the latter case. There's some stuff about partial vs. full initializations and I suspect this is the root cause. I also get the impression that the python interpreter called by PyRun_SimpleString doesn't see everything you do with calls to the C API though this doesn't make much sense. For instance just calling PyImport_ImportModule("mymod") and PyImport_AddModule("mymod") doesn't seem to work, you need to say "import mymod" in the python code too. I'm dynamically linking everything. Is this some linker phenomenon? - Greg --- On Wed, 7/16/08, Kai Sterker <kai...@gm...> wrote: From: Kai Sterker <kai...@gm...> Subject: Re: [Swig-user] How to access C/C++ objects from Python To: "SWIG Users" <swi...@li...> Date: Wednesday, July 16, 2008, 2:22 AM On Tue, Jul 15, 2008 at 11:23 PM, Gregory Propf <gre...@ya...> wrote: > Thanks, that worked but only after I discovered the need to call SWIG_init() > within the C++ program. If you don't do that the types table entries are > missing and attempting to use something like SWIGTYPE_p_YourCType->name will > segfault. I suppose if you know the SWIG type mangling convention you can > get away without it. That wasn't required in our case for some reason. I was assuming that SWIG sets up all it needs automatically on importing your Python module with PyImport_ImportModule. But I am not sure how the mechanism works exactly. We use the unmangled name of the C++ class (and namespace) as the name argument (i.e. "base::configuration") for a class configuration in namespace base. There's also some debugging code that will print the actual classes known to SWIG, but I omitted it for brevity. You can see the whole thing at http://cvs.savannah.gnu.org/viewvc/adonthell/src/py-wrappers/runtime/py_runtime.i?root=adonthell&view=markup&pathrev=HEAD > By the way, what did you use for c_owns. I just used > a 0 after looking at what the other #defines were. - Greg Yes, it's 0. Kai ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swig-user mailing list Swi...@li... https://lists.sourceforge.net/lists/listinfo/swig-user |