Re: Adding functions to QuantLib SWIG
Posted by
Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p6151.html
On Tue, Apr 17, 2012 at 12:11 AM, Zhi Xuan Fang <
[hidden email]> wrote:
> I am currently working on QuantLib SWIG 1.0 with SWIG version 1.3.29. I am
> having troubles adding functions to a class. For example adding the function
> int addlfunc(){ return 1;} to class Quote. From the marketelements.i file, I
> tried
>
> %{
> using QuantLib::Quote;
> %}
>
> %ignore Quote;
> class Quote {
> public:
> Real value() const;
> %extend{
> int addlfunc(){
> return 1;
> }
> }
> };
>
> however it doesn't build. I am new to SWIG but when I was looking at their
> documentation, %extend seems to be the answer.
Yes, but the class actually exported as Quote to the target language
is boost::shared_ptr<Quote>. Try extending that, as in:
%extend boost::shared_ptr<Quote> {
int addlfunc(){
return 1;
}
}
> In addition, does quantlib swig not allow reference to vectors as a function
> argument?
That's tricky. What language are you exporting to?
Luigi
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users