Hi Steffen,

Compelling argument.  I'll stop wasting time with Inline.

Regards

Steve


-----Original Message-----
From: Steffen Mueller [mailto:[email protected]] 
Sent: 06 April 2010 04:52
To: Steve Cookson
Cc: [email protected]
Subject: Re: Converting wxRTCPrinting for accessing from Perl.

Hi Steve,

please bear in mind that I'm by no means a Wx expert.

Steve Cookson wrote:
> I'm about to embark on converting richtextprint.cpp (706 lines of C++ with
> light commenting) so that I can access it from Perl and print wxRTCs.  Can
I
> ask your suggestions as to the easiest way?  There seem to be four main
> routes:
> 
> - rewrite entirely in Perl (for me, this is the least taxing but probably
> most time consuming route);
> 
> - use Inline::CPP (not sure how reliable this module is.  It doesn't seem
to
> have been maintained since 2002 and I've had some difficulties installing
> from CPAN);
> 
> - XSUB (I've no idea what this involves.  Maybe a bit of access code for
> each method, there are about 13 of them.  I've read the doc, but I'm no
> clearer.);
> 
> - SWIG, (seems like an automated XSUB, but again, having read the doc, no
> light was shed!).

I think the proper way to do this is wrapping the C++ code with XS. 
Rewriting in Perl just means extra maintenance burden down the road. 
It's been a long time since I investigated SWIG, but back then, it 
didn't produce particularly good code for my purposes, so I'm not a big 
fan. Inline::$Anything is a bad choice for code that goes to CPAN. Thus, 
writing XS is the sole survivor :)

Now, I'm sure Mattia has a much better grasp of how easy or hard it 
would be to include that particular component in the Wx build itself. 
The upside of that would be that it could use the Wx-related 
infrastructure of the Wx.pm distribution.

Barring that, you could have a look at ExtUtils::XSpp, which Mattia 
wrote for use in Wx. It's essentially XS augmented to work well with 
C++. The Wx.pm distribution itself is the largest example of its use, 
but you can find simpler ones like Math::ThinPlateSpline.

Best regards,
Steffen

PS: The easiest way to start a new XS module and even more so an XS++ 
module is to copy a simple, existing one and doing a big 
s/oldname/newname/g run. Prevents you from having to understand all the 
boilerplate right from the start.

Reply via email to