embedding an extension
Dave Kuhlman
dkuhlman at rexx.com
Wed Jan 16 18:25:06 EST 2002
Bengt Richter <bokr at oz.net> wrote:
>
> On 15 Jan 2002 08:33:47 GMT, "Arno Baan" <a.baan at fokkerspace.nl> wrote:
>
>>Hi,
>>
>>I'm trying to embed some python into an C++ program.
>>I've written an some extensions to python wich I need.
>>Now I'm able to create objects and perform their functions.
>>
>>What I would like to do is:
>>open existing objects in my C++ program and access these
>>using python code.
>>Is this possible and how can it be done??
>>
>>I hope someone can help me.
>>
> Maybe this 2.2 documentation will help?
>
> http://python.org/doc/current/ext/extending-with-embedding.html
>
Another suggestion -- Start with Modules/xxmodule.c in the Python
2.2 source distribution. This is a lot of work, but it will enable
you to implement a new Python type, instances of which wrap
instances of your C++ object. You will be able to implement this
new type so that the attributes of an instance of the new type give
access to the member functions and variables of your C++ class.
Section 2, "Defining New Types" in the "Extending and Embedding the
Python Interpreter" manual gives help with this.
I wish SWIG did this for us. Hmmm. Maybe I'd better go check.
[a few minutes later]
SWIG does do something in this direction. I don't understand it
well enough to explain or recommend it. I'm looking into it.
Perhaps a SWIG expert can educate us.
And, as to getting access to existing C++ objects -- Implement and
expose to Python a function that returns a tuple of wrapped
objects.
- Dave
--
Dave Kuhlman
dkuhlman at rexx.com
http://www.rexx.com/~dkuhlman
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
More information about the Python-list
mailing list