Re: [PATCH] Payoffs fully implemented in a foreign language via SWIG

Posted by andrea-110 on
URL: http://quantlib.414.s1.nabble.com/PATCH-Payoffs-fully-implemented-in-a-foreign-language-via-SWIG-tp13242p13245.html

On 20/01/10 11:15, Luigi Ballabio wrote:

> On Mon, 2010-01-18 at 22:14 +0000, Andrea wrote:
>> On 17/01/10 21:31, Andrea wrote:
>>> I would like to post 2 patches (one for QuantLib, the other for
>> QuantLib-SWIG) to allow users to
>>> implement a payoff entirely in a foreign language (e.g. Java).
>>> These patches apply on top of the other patch I have just sent.
>>  
>> I've actually found a better solution, but it requires a global change
>> in QuantLib-SWIG.
>>
>> In SWIG there is already support for boost::shared_ptr<> that removes
>> distinction between raw pointer, value, reference and smart pointer
>> making it all easier.
>>
>> Does anybody know why it is not used?
>
> SWIG didn't provide it when we first wrote the interfaces, and I'm
> afraid we haven't keep abreast of the latest developments.  I'll have to
> check it out.  Would it result in an interface change as seen from the
> host language?
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.

I think the idea is to expose things as they are, then SWIG will take care of all the shared_ptr
details.

If you compile the file I have attached, you can see what it looks like.

It is very likely that the user will not notice any difference.

Coming back to my original problem, unfortunately it seems that using shared_ptr and directors does
not work (yet?) (SWIG generates invalid Java code). So for the time being the code I posted at the
top of the thread is still my best solution.

Andrea

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev

p.i (566 bytes) Download Attachment