I'm new to Lua, and trying to understand some of the fundamentals. Something I want to understand is binding Lua to C++ instances.
I am not interested in third party libraries, I want to understand this at a more fundamental level - thanks :)
Here are my questions:
- My assumption based on what I have read, is that Lua can only bind to static C functions. Is this correct?
- Does that mean that to bind an instance of a C++ class, I'd first need to write static functions for each method and property getter/setter I want, accepting an instance pointer as a paramter.
- I'd register these functions with Lua.
- I'd pass Lua a pointer to the instance of the C++ class.
- From Lua I'd call one of the registered functions, passing the C++ instance pointer.
- The static function dereferences the pointer, calling the equivalent method.
Does this make sense? Or have I gotten something wrong?
Thanks for reading this far.