|
From: Andrea <mar...@go...> - 2010-01-23 20:13:54
|
On 22/01/10 11:06, Luigi Ballabio wrote:
> On Wed, 2010-01-20 at 21:08 +0000, Andrea wrote:
>> It looks like it makes things a lot easier.
>> Basically one has to export the raw C++ inheritance.
>> Then swig will remove all differences between pointers, references,
>> shared_ptr, wrapping them when needed.
>> I think it would simplify what Quantlib-SWIG does now, where it needs
>> to expose classes inheriting from shared_ptr<I> rather than I itself.
>
>> It is very likely that the user will not notice any difference.
>
> Ok, I see. Yes, that would simplify the interfaces somewhat. However,
> there's the problem that shared_ptr is not supported in all the
> languages we're exporting to.
>
I tried a bit more to use swig shared_ptr support (just the template definition and not th emore
advanced feature), but that also has problems.
Basically in quantlib-swig a share_ptr is
template <class T>
class shared_ptr {
public:
T* operator->();
};
while in SWIG's shared_ptr.i it is
template <class T>
class shared_ptr {
};
QuantLi-SWIG relies massively on the operator -> which force SWIG to add all methods of T to the
shared_ptr class.
So in the end, I am still with the first version, and I will just try to make it safe with some
observer/observable pattern so that I know when the reference held by the wrapper is destroyed (I
hope at least).
Andrea
|