[Kde-bindings] Qt bindings for Lua

Mauro Iazzi mauro.iazzi at gmail.com
Thu Sep 13 09:13:54 UTC 2007


On 13/09/2007, Sebastian Sauer <mail at dipe.org> wrote:
> Mauro Iazzi wrote:
>
> > I strongly hope that this is of some interest to someone.
>
> Looks damn cool. I just ask myself why an own parser is used and not smoke
> which got already used for ruby, C#, php, ... ? anyway, keep up the great
> work and I'll press all of my fingers, that we have working LUA-bindings
> soon! :)
>

I tried to have it the smoke way, but I did not understand well how to
use it. So for a bunch of motives I resolved to make it by myself. One
of those motives is that I don't assume it is the best way of doing
this, just a simple one.

I also have a binding of the Qt's moc which does exactly the same of
QtScript for Lua. I could not give it the same interface of QtScript
(as suggested by a recent post in tha planet by Aaron Seigo) because
Lua and Javascript are not similar at all and I could not translate
the concepts of Javascript into Lua's. The subject (JS <-> Lua
translation) has undergone great discussion in the Lua mailing list,
but no definitive solution has been found. If anyone wants to see the
code, I will post. I may try to resurrect it if someone feels it is a
good idea.

gccxml is a powerful tool, which exposes directly an internal
representation of gcc, meant exactly for exporting the parsing work. I
know whether a class is abstract and such so that I make most of my
choices indipendently from what the code is.

Thus, the binding is not Qt specific, although I use only Qt for
testing, beacuse they are big but not complex. I implemented a small
filter in the generator, which allows me to strip internal methods (I
recognize it beacuse it contains underscores), so that is Qt specific.
Transparent use of QStrings is also Qt specific, but both are on top
of the actual generator, so they are easy to replace. Also X11 code is
stripped, so the generated code should work in places without it.

Moreover I have a per-class granularity. You can include bindings for
QPushButton and not QObject, QWidget or QAbstractButton. All works,
you just miss those. It is quite funny.

I discarded the LuaExpat dependency for a pure-lua solution, so now
the generator only depends on gccxml.

I have recently solved a lot of memory faults, I feel the code is
complete. I think I have to put it into a repository, so If noone is
contrary, I'll tell the list when it will be up somewhere.

Finally, I just consider this as a proof of concept, basically. Given
that it could use gcc directly (just writing a lot of C code, to
interface directly) this means that bindings could be done at compiler
level. I stress I have no clue about what _should_ be done, but this
is a test...

I'm glad that someone likes it, thank you

mauro



More information about the Kde-bindings mailing list