Lua binding


#1

Is there any lua binding solutions that can bind a C++ class to lua? Including lua function callback.


#2

Yes, you can write your own Native Extension (NE) and communicate between C/Cpp code and Lua code.
There is native extensions manual:


Example Extensions:

C API functions:
http://pgl.yoyo.org/luai/i/3.7+Functions+and+Types

Regarding Lua function callback.
Example of callback registration:

Invoke Callback:


#3

I know this, but I found If I want to bind a C++ class to lua, it has a lot of glue codes, Is there some solutions like tolua?


#4

Sorry for my misunderstanding.
Maybe @Mathias_Westerdahl could help with your question.


#5

There are several tools for generating Lua bindings from header files etc I haven’t tried any of them myself though.

http://lua-users.org/wiki/BindingCodeToLua

I’ve heard of sol and sol2 in the list above and it is supposedly a very good solution.


#6

No, I haven’t heard of anything like this. @britzl’s suggestions are probably a good approach though, if necessary.