lua-users home
lua-l archive

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

Dwight Schauer <> writes:
> With SWIG C structures are treated as userdata in Lua. Is there any
> automatic way to convert one of these to a Lua table that can more
> easily be marshalled? Or do I have to make a struct to table copy
> function (and back) on a per structure definition basis?

That's really a Swig issue, not a Lua one.

I suspect it's possible -- much of Swig's Lua-C interface is
table-driven, particularly data access and type-checking.

I'd look at the C code generated by Swig (it's fairly repetitive, and
not hard to understand).  E.g., look at how it implements the __index
metatable operation for Swig userdata.


Learning, n. The kind of ignorance distinguishing the studious.