[haiku-development] Re: The Call for Scripting Languages: Lua

  • From: Jack Small <jaxs@xxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 28 Sep 2009 13:57:59 -0700


On Sep 27, 2009, at 11:02 AM, Rob Hoelz wrote:

Jack Small <jaxs@xxxxxxxx> wrote:

Second, the one thing SWIG does not do is allow you to subclass C++
objects and overload functions in a dynamic runtime interpreter.
AFIK, there is no truly dynamic way of doing it with C++ because of
its inline runtime.  If someone knows better I'd love to be wrong!
So far, every tutorial I've ever seen about writing BeOS/Haiku apps
begins with subclassing BApplication.  Most of the GUI API assumes
you will subclass various views.

My experience with SWIG is minimal, so I'm not sure if it would be
capable of this, but here's how I would do it if I were wrapping C++ in
Lua by hand:

class Foo
...
class LuaFoo : public Foo
...

Unfortunately this is a language specific static mapping. Each language would have to write their own, and nobody would actually be using the same API.

In a dynamic runtime there is some way to create subclasses at runtime. Usually you can rename, delete them, and a number of other things as well. AFAIK C++ does not have such a mechanism.

This is why I'm suggesting writing a C GUI API layer. If we were to create a more generic layer of item subclasses it could be used from any non-C++ language and preserve the advantages of shared sources.

More later,
Jack



Other related posts: