[C++-sig] Re: Exposing C++ objects to Python at runtime

Raoul Gough RaoulGough at yahoo.co.uk
Thu Nov 27 12:53:59 CET 2003


Daniel Wallin <dalwan01 at student.umu.se> writes:

> Raoul Gough wrote:
>> Daniel Wallin <dalwan01 at student.umu.se> writes:
>>
>>>Raoul Gough wrote:
>>>
>>>>Daniel Wallin <dalwan01 at student.umu.se> writes:
>> [snip]
>>
>>>
>>>The code which does the actual conversion is separated from the function
>>>descriptor. perform_conversion() is completetly language dependent and
>>>just an implementation detail in this case.
>> The point I'm trying to make is that I believe the code in
>> perform_conversion (at some point down the call chain) has to have
>> compile-time knowledge of the C++ type. This means that a simple
>> abstract base class interface will not suffice (at least, not one that
>> is independent of the scripting language in question).
>
> Custom converters aside, there are really very few conversion left that
> depend on the wrapped language; conversions to/from primitive types, and
> conversions to/from UDT's wrapped with class_<>. The UDT conversion is
> only dependent on the wrapped language in that it needs to be able to
> extract a void* to the UDT object from the argument, it doesn't require
> any compile time knowledge to generate code that depends on the
> language.
[snip]

OK, I see what you mean. Once you've got a void * to the real C++
object, you can pass this through a simple abstract interface to
handle value extraction, allocation, copying, destruction and so
on. The templated code would then only have to provide implementations
based on void * instead of per-scripting-language. Sounds very
interesting for multi-language support. Implementation, anyone?

-- 
Raoul Gough.
export LESS='-X'





More information about the Cplusplus-sig mailing list