lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi list !

I am *very* happy to announce a major leap forward for the dubLua
bindings generator for C++ code. The most important enhancement is the
support for 'super' and 'bind' settings in the class documentation:

/** Foobar is a special widget that flashes with advertisement about
lottery winnings.
 *
 * @dub super: 'QObject, QWidget'
 *            bind: 'Foobar.yml'
 */
class Foobar : public QWidget {
public:
  Foobar() {}
  void size();
};

When this is parsed by Doxygen and the bindings are generated by dub,
all methods declared for QObject and QWidget in their respective
headers (or pseudo-headers) will be bound to the Foobar class.

Moreover if you want to have some more Luaish bindings (return
multiple values, work on tables, etc), you can define the binding in a
yaml file (in the same directory as the header):

Foobar.yml
lua:
  # dub automatically detects and parses the arguments and checks their type
  # we only need to write the body
  doSomething: |
    lua_pushnumber(L, self->width());
    lua_pushnumber(L, self->height());
    return 2

This might no seem very impressive but it really makes bindings with
some customization to existing libraries (Qt) much easier...

Cheers,

Gaspard

==== What is dub ?

https://github.com/lubyk/dub

Dub is a Ruby gem that creates Lua bindings by reading the output from
Doxygen (a C++ header parser). It is used extensively in Lubyk to
create all the bindings. The documentation is so bad currently that
either you manage to read the code in lubyk
(https://github.com/lubyk/lubyk/blob/master/modules/bind.rb) or you
can just email me for help...

                                                               Gaspard