Hi Eric, Brian,
I must admit that until this came up, it hadn't occurred to me that the
code.haskell.org attack and rebuild would have this impact (even though it's
blindingly obvious in retrospect).
I will get the repo back online in the next day or so. Eric, if you contact
me off-line and explain what I need to do to upgrade to hashed format, I'll
be very happy to do so).
There are two aspects to wrapping additional functionality. One is basically
easy and the other is hard.
Wrapping core wxWidgets functionality is pretty straightforward.
1. In wxcore/src/include/wxc_glue.h, for each class required
1. Add a class derivation using the TClassDefExtend macro
2. Add suitable C function declarations, following some of the
existing code as an example. I recommend following the naming convention:
wxClassName_MethodName(), although you will need to do something for
methods which overload by parameter types (usually constructors)
2. In wxcore/src/cpp, for each class required
1. Add a new file, named for the class it contains. In your case, the
most suitable name would probably be display.cpp. This contains the
implementation for the prototype declarations you wrote in (1.2)
above. The
format is very straightforward, and you should follow examples from other
files. In particular:
1. Each wrapper function needs a 'self' parameter, which is a
pointer to an instance of the class you are wrapping.
2. If you are performing an operation which will return a
structure, you will need to allocate something suitable, as
Haskell doesn't
do it for you.
3. The exported functions require C linkage (i.e. no C++ name
mangling). The simplest way to do this is to ensure that your
functions are
defined inside an
extern "C" { ... }.
3. If you have any new constants, add them in wxcore/src/eiffel
4. Modify wxcore/wxcore.cabal, in the extra-source-files stanza to
include your new cpp file. Please also add a minor version update in
wxcore.cabal.
5. (Optional) - if you can think of a way to provide a more idiomatic
Haskell interface to your wrapped class, add something in
wx/src/Graphics/UI/WX. It is probably better to do this after you have been
using the bare wrapped interface for a while, as you will have a good feel
for how you use the functionality in practice.
6. (Optional - only if you did 5) - Add your Haskell module to the
Exposed-Modules stanza in wx.cabal, and bump the minor version.
You can then build from source as per the instructions. You should find that
wxcore/src/haskell/Graphics/UI/WXCore/WxcClassesAL.hs (or WxcClassesMZ.hs)
has been updated with Haskell wrappers for your C++ wrapper functions.
It is far harder to write a wrapper for a significant optional functionality
like WxSTC. WHile Shelarcy succeeded, the way this was done is not very
scalable as it requires modifications in wxdirect (the wrapper generator),
which is something to be avoided if possible.
Happily, wxDisplay fits comfortably into the first category.
Regards
Jeremy
On 9 March 2011 09:59, Eric Y. Kow <eric....@gmail.com> wrote:
> On Wed, Mar 09, 2011 at 02:00:19 +0000, Brian Victor wrote:
> > 1) What's the current source repo? The wiki points to
> > http://code.haskell.org/wxhaskell/ which is 404.
>
> That's still the right place, but it's not been restored since
> the recent attack on community.haskell.org.
>
> Jeremy, have you had a chance to look into putting the repository
> back online? Hopefully we can upgrade it to the hashed format
> along the way.
>
> > 2) Once I get the source, what do I need to do to wrap wxDisplay? Is
> > there a good model I can look at to copy? (I've only looked at
> > Haskell's FFI functionality briefly, so I expect a learning curve.)
> >
> > 3) How likely is it that a patch for this will be released relatively
> > quickly?
>
> I can't comment on the above. I think shelarchy managed to wrap wxSTC
> before
>
> Thanks,
>
> --
> Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
> For a faster response, try +44 (0)1273 64 2905 or
> xmpp:ko...@jabber.fr (Jabber or Google Talk only)
>
>
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> wxhaskell-users mailing list
> wxhaskell-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wxhaskell-users
>
>
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users