[haiku-development] Re: Scripting languages

  • From: Donn Cave <donn@xxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 16 May 2011 11:19:42 -0700 (PDT)

Quoth Ryan Leavengood <leavengood@xxxxxxxxx>,
...
> With the recent work of Jon Yoder (aka darkwyrm) on
> libcharlemagne[1,2], which may become the "standard" Haiku C API
> wrapper, doing the above with Haskell (and other languages for that
> matter) may be easier now. In fact maybe you could share some of your
> work on a BeOS C API wrapper as it may be useful for Jon for
> libcharlemagne.

Interesting.  I have, for both Python and Haskell, tried to apply
the API more directly.  So, for example the window constructor from
the Haskell version of the CHaikuRun program in Jon's blog -

winCx this = do
    view <- withCString "v" $ \ name ->
        cBView Nothing nullBViewDispatch (BRect 0 0 400 300) name [] []
    cBViewSetViewColor view (B_rgb_color 224 224 224 255)
    label <- withCString "just any name" $ \ name ->
        withCString "Hello Haiku from the Haskell language" $ \ text ->
            cBStringView Nothing nullBStringViewDispatch (BRect 10 10 350 60)
                name text [] [B_WILL_DRAW]
    cBViewAddChild view (fromBStringViewPtr label) nullPtr
    cBWindowAddChild this view nullPtr

cBWindowAddChild is a Haskell library function, that calls
c_BWindowAddChild, that calls HWindow->AddChild - so a couple
of layers, but they're very thin layers that do Haskell-specific 
stuff, and I generate them automatically.

The way I see it, the work that can really benefit multiple languages
is the API reference, that can be input to interface generators.
We've corresponded about this here before - similar to interface/Window.h,
but more easily parsed and with extra information as required by more
modern languages.

        Donn

Other related posts: