Wednesday, January 26, 2011

Closer to Scripting Language Support

In the few weeks since my last post I've been working more on bringing the ability to write graphical Haiku applications to languages outside of C++. PDesigner has seen some refactoring, and now it's a lot lighter -- all of the object system code upon which PDesigner has been built was spun out into its own library, libcharlemagne. I'm working with SWIG in order to be able to generate the necessary bindings for the supported languages.

I've run into a small snag, however: I don't know very much about other languages except for a passing familiarity with Python, and certainly not enough about it to know what I'm doing. Just last night I checked in some code to the repository which, in theory, should make it possible to write a Haiku app from Python, Lua, or just about any other scripting language supported by SWIG. There's also a C interface for those people who want to use it. Documentation will be coming soon.

Once I get it to the point where other people will want to use it, it will be available both with the Paladin suite and as a separate download. If you have a little time to tinker and know something about using SWIG for your favorite non-C++ language, get in touch with me.


  1. Did you make SWIG interface files for the Haiku API? Because that would be amazing! I think it's going to be really big news when the Haiku API gets bindings for Python and Ruby. :D

    If you did, would it possible for me to use the simple commands for "Building a Python module" found on the SWIG tutorial and start creating Haiku applications in Python?

  2. Sort of. I've actually created an object system library (libcharlemagne) which presents a much more generic interface to all of the Haiku API, making SWIG generation a *lot* easier. Not all of the Haiku API is accessible at this point, but most of the Interface Kit is and some of the App Kit is, too. At this point, it's possible to create a full-fledged Haiku app from C (not C++), but the code for BApplication isn't tested.... yet. Hopefully tonight I'll get to that.

    Yes, you should be able to use SWIG to create a Python interface. I just don't know enough about either of them to be effective. If you check out the Paladin sources from SourceForge, you'll also have the sources for libcharlemagne, if you're interested.

  3. I read through the libcharlemagne files. Let me see if I understand:

    You created a small collection of C functions that can be used to access the Haiku API. As you add more and more subclasses to PData, more and more of the Haiku API will become available. You suggest using SWIP to wrap the C functions. that correct?

    I read through a lot of the SWIG documentation. I think it's a good choice. I'm thinking the best solution is to make SWIG interface files for the Haiku API header files themselves. I think I'll try out a simple SWIG + Haiku API test tonight.

  4. I wrote the C interface before I knew anything about SWIG. I'm going to use them more to test than anything else, realy.

    I actually made a SWIG file for the C++ classes in the library that you are meant to use directly. The C++ code doesn't have anything complicated in it except for one header which uses templates a bit.