Started work on GTK+/GLib module
Adrián Pérez de Castro <[email protected]> Mon, 05 Jul 2004 18:27:27 +0200
| Newsgroups | gmane.comp.lang.lua.luacheia |
|---|---|
| Message-ID | <[email protected]> |
--=-OazBqFe/t6CvHQ0aoimf
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Hello!
As promised I started working in a thin GTK+ and GLib
wrapper module for Lua. I finally decided to wrap GLib=20
as well as GTK+/GDK, because it contains some useful
functionality that is not present at the moment in
Lua/LuaCheia. There are several possible approaches=20
for the binding:
A. Separate modules for each of GLib, GDK and GTK+
B. A module for GLib and another with GTK+ and GDK
(usually there's no point in using GDK outside of=20
GTK+, but GLib alone might be useful).
C. An all-in-one module containing the three libs.
D. Suggestions?
I have started the work as an all-in-one module, but it
might be changed easily if needed/wanted.
Another issue: I tried using tolua to make the binding,
but for some reason the generated code does not like the
GTK+ object system. The most annoying issue I have found
is that upcasting objects (i.e: casting a GtkWindow into=20
a GtkWidget) makes tolua believe that the casted object
effectively changed its type! (so you can't pass the
GtkWindow to a function that expects a GtkWindow unless
you re-cast the object into a GtkWindow). This constant
cast-up and cast-down would make Lua code look like a
rollercoaster track, so I decided to make a hand-written
binding.=20
(Q: Does anyone know wether SWIG would work with Lua5?)
Note that I have commited preliminary, proof-of-concept
code, to the CVS. I like to make code available to the
public soon ;). GTK won't work at this stage (mostly
because you can't call gtk_init yet), but some GLib=20
stuff is working. Just compile as usual and tap into=20
your LuaCheia interpreter:
=3D cheia.load "gtk" -- should return 'true'
for i,v in glib do print(i, v) end
for i,v in gtk do print(i, v) end
=3D glib.str_has_suffix("foobar", "bar") -- returns true
=3D glib.get_tmp_dir() -- returns '/tmp' or similar
The mapping of functions is straightforward, so:
* in GLib: g_do_something becomes glib.do_something
* in GTK+: gtk_do_something becomes gtk.do_something=20
* ...and so on
Enjoy, and give feedback if you feel that something should
be changed.
--
Adrian Perez
moebius _at_ eml.cc
--=-OazBqFe/t6CvHQ0aoimf
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada
digitalmente
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQBA6YFvghBwwjayrGQRAuifAKC8XDnzbPaPPgnew/4gP+zW9l0quwCggRJz
qhxZAufEHE3KGQpQXr0kzxM=
=7DFg
-----END PGP SIGNATURE-----
--=-OazBqFe/t6CvHQ0aoimf--
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com