lua-users home
lua-l archive

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

2007/8/14, Matthew Armstrong <>:
> Some third-party libraries I use have lua bindings already created (by the
> owners or some nice contributor).  They are large enough that I really don't
> want to do them by hand again myself.  The problem is, these bindings are
> often created with different binding libraries (luabind/swing/tolua++).
> Each binding library expects the userdata's metatable to be in a certain
> format.  So if a userdata is created in one binding library, it can't be
> passed into another.
> Has anyone else encountered this problem?  And is there an elegant solution
> to it?

There's no standardized way to describe a userdata structure in Lua.
However most libraries use some kind of object-oriented notation with
functions to create objects, and methods on these objects.

If your libraries accept foreign objects, imho the elegant solution is
ignore the type of the objects (table or userdata) and their metatable
configuration (none, individual, shared, __index table, __index