8
Abstracting a C++ Type Exporter
In the previous chapter, we learned how to export a C++ class to Lua as a user-defined type. An instance of the class is exported to Lua to serve as the prototype for the type.
The exercise from the previous chapter required you to create a factory class for the type. However, with that requirement, each type needs its own factory class.
In this chapter, we will learn how to implement a general C++ type exporter so that you can use it as the factory class for any C++ type, without redoing the work.
In this chapter, we will cover the following topics:
- Reviewing the factory implementation
- Designing a type exporter
- Stubbing the type exporter
- Defining LuaModuleDef
- Re-implementing luaNew
- Are you flexible enough? ...
Get Integrate Lua with C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.