Archived

This topic is now archived and is closed to further replies.

Embedding and Extension Glue: Any Advances

This topic is 5304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Rummaging through the web I came across a couple of references to Humongous Entertainment''s Bruce Dawson''s GamaSutra article on using Python. I''ve read it before, when it was first published online (I should get back to receiving Game Developer in the mail), but what struck me this time was YAGA, a custom glue code generation system that simplified the process of extending Python with C++ classes - allowing Python classes to derive from C++ classes and so forth. I''m wondering if there are any freely available implementations of similar architectures, or even significant brainstormings on the subject. Manually extending Python with C or C++ can be tedious (lots of glue code), and I''d rather not do it (laziness is my number one programmer trait!) Thanks.

Share this post


Link to post
Share on other sites
Boost has a python library for that purpose. I've never really used it but I've heard good things about it. http://www.boost.org/libs/python/doc/index.html

[edited by - Horn on June 3, 2003 5:41:35 PM]

Share this post


Link to post
Share on other sites
boost:ython is nice, assuming you're right in line with boost's almost cultish devotion to pure OOP.

Also, check out SWIG (www.swig.org)--somewhat scripting-language independent, and very straightforward to use.

As for me, I don't use binding generators; I make my own wrapper functions which talk directly to the VM. The conscientious use of macro-ish helper functions simplifies this greatly. I've found that this gives me the best mix of efficiency, flexibility, and encapsulation.

EDIT: but, then, I don't use Python.

[edited by - sneftel on June 3, 2003 5:58:21 PM]

Share this post


Link to post
Share on other sites
I''m not in the least bit fanatical about OOP, and I generally don''t like using Boost because their techniques are complex/complicated. I''m convinced that good solutions are also fairly simple and elegant - and derive a lot of their robustness from those properties.

I''ll look into SWIG (and FuBi), but, Sneftel, I''d really like to hear more about your approach. I''m not averse to building a solution of my own if it affords greater flexibility and reduces my workload in the long run. And information you can offer is highly appreciated.

Share this post


Link to post
Share on other sites
I put some examples in the Forum FAQ. One very nice and clean one - if it suits your needs - is Pyrex. You essentially just write the extension in Python but can use C data types and functions.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Thanks for the Pyrex reference. It''s interesting, but I''ll need to spend some more time with it to see if it improves my workflow. It seems to be more oriented on the Python side of things - directly embedding native C types in Python and so forth. I haven''t exhausted the site, though, so don''t consider this conclusive. I''ll also look through the FAQ again.

Share this post


Link to post
Share on other sites