[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Adonthell-devel] Python question
From: |
Kai Sterker |
Subject: |
Re: [Adonthell-devel] Python question |
Date: |
Wed, 21 May 2003 16:58:16 +0200 |
On Wed, 21 May 2003 07:11:53 -0700 Mike Avery wrote:
> In order to test the get_char_snapshot moethod in the manager, I need
> to return a pointer to a structure. I want to do the testing in
> Python, although manager.h and manager.cc will need modifications for
> this.
>
> If I return a pointer to a C++ structure, is this a Pyton tuple, or a
> dict?
You will probably want to make that structure known to Python by adding
it to the py_adonthell.i file. Usually, it'll be enough to add #include
"yourclass.h" respectively %include "yourclass.h" at the proper places.
(You'll see where what needs to go).
Afterwards, upon running make, SWIG will create a wrapper for your
structure and the matching Python shadow class.
When calling your get_char_snapshot from the manager, you'll get that
shadow class, which encapsulates your original C++ object. It'll have
all the attributes your C++ class has and can be used in the same way.
And of course, your C++ object will reflect the changes made to that
shadow object.
Btw, that shadow class ends up being defined in modules/adonthell.py.
See there for more info about what is going on.
If you need further help, please tell me. Or refer to the SWIG manual. I
believe it contains a nice little tutorial.
Kai