Scripting C++ -- 2 -- a more concrete example.

Donovan Rebbechi elflord at panix.com
Fri Mar 1 13:17:09 EST 2002


In article <6bf54244.0203010925.38d237ed at posting.google.com>, Craig Maloney wrote:
> Donovan Rebbechi <elflord at panix.com> wrote in message news:<slrna7tidr.8aq.elflord at panix2.panix.com>...
>> In article <3C7E6642.2030202 at physics.ucsb.edu>, Craig Maloney wrote:
>> > If using a wrapper generator (e.g. SILOON) I don't see a way around the 
>> > marshalling of the call to get at the atom data structure.
>> 
>> I don't really understand exactly what the problem is. 
>> > 
>> > Of course, this would be taken care of by a revamp of the design of the 
>> > class library... maybe making the crystal an atom factory that produces 
>> > new atoms in its own address space.  But I would like to avoid thinking 
>> 
>> Now I'm really confused. If you're not using CORBA, the atoms are in the
>> same address space, aren't they ?
> 
> This is how I presumed that Boost also worked -- I must be mistaken.
> After having seen yours and Ralf's comments, I now have the impression
> that Boost works it's magic differently.
> 
> Perhaps Craig Rasmussen could enlighten us as to how SILOON deals with
> co-location issues such as the one above?
> 
> From the SILOON doc/design.html page :

Looks like SILOON is using some sort of client/server architecture, much like 
CORBA.

Sip, which is what I use, doesn't do this. It simply wraps C++ objects. 
Basically, Python objects are represented in C as PyObject* pointers. What
sip does is create a "derived" struct by aggregating a PyObject, and some 
additional stuff. So in the sip model, you'd just be using wrapped python 
objects.

It's not completely automatic, because there are some choices that can't be
made automatically. For example, there are tricky choices about ownership --
when you call "add", does the object you "add" to want to own a reference 
(bump up the reference count) ? You also do need to add code to return 
python tuples instead of using the C/C++ "return-by-pass-by-pointer" idiom. 

Like I said, even though it's not automatic, you get a good code generation
ratio. Also, even in instances where it's not completely automatic (eg 
exception mapping), you can use generated code as a starting point. I use 
macros to map exceptions, which makes this a very simple process.

Cheers,
-- 
Donovan



More information about the Python-list mailing list