Summary
In this chapter, we learned how to call C++ code from Lua. We first learned how to register a simple C++ function to Lua. All registered functions must conform to lua_CFunction
. Then, we found out how to override Lua library functions. Finally, we implemented a C++ class and exported it to Lua. We also came across the concepts of upvalue and light userdata along the way.
In the next chapter, we will continue our journey with more details on user-defined data in C++ and more data-exchanging mechanisms.