Making Lua and C++ live happily together
Diluculum is a library that intends to make the coexistence of C++ and Lua more harmonious. In this regard, it offers essentially three “services”:
- A nice way to access data stored in a Lua interpreter.
- A not so bad way to write functions in C++ and make them available to Lua.
- A limited and just barely usable way to register C++ classes and objects in a Lua state.
Assorted facts about Diluculum
Diluculum…
- Is fully documented. In particular, check the User’s Guide for some examples of use. (There used to be a Russian version of the User’s Guide, provided by Dmitriy Shmikov, but the link is broken by now).
- Has unit tests for pretty much everything in it.
- Requires Lua 5.1. It will not compile with Lua 5.0.
- Is reasonably portable. It should work at least under Linux with GCC 4.x and under Windows with Visual Studio 2008.
- Depends on Lua and Boost.
- has a build system based on CMake, but I strongly recommend to add Diluculum source files directly to your own projects.
- Is distributed under the MIT license (the same as Lua).
- Means something like “dawn” or “daybreak” in Latin, according to a dictionary I consulted some day.
Latest release
Latest release is 0.5.3, released on 02010-07-22. It can be downloaded here: Diluculum-0.5.3.tar.gz. This contains two changes:
- Strings going from C++ to Lua with embedded zeros are now properly handled by. (This is the opposite of the bug fixed in the previous release).
- Diluculum::LuaFunctions can now be constructed from a chunk of Lua source code, passed to the constructor as a string. (By default, it is constructed from an empty chunk)
Again, thanks to Christof Warlich for both of these points. (But for the second one, I didn’t follow his suggestion, so I am the one to blame!)
Donate
Liked Diluculum? What about a tip? Any amount will make my day. Donation is handled by PayPal. It is safe and you don’t need a PayPal account.
Old releases
- Diluclum 0.5.2 (Diluculum-0.5.2.tar.gz), 02010-05-28.
- Strings coming from Lua with embedded zeros were not properly handled by Diluculum. Thanks to Christof Warlich for finding the bug and pointing out how to fix it.
- Diluculum 0.5.1 (Diluculum-0.5.1.tar.gz), 02010-01-15.
- Added a method LuaState::globals(), which provides access to the table of gloabals (AKA "_G"). This was implemented in response to a bug report by Yuriy Shmal.
- Diluculum 0.5 (Diluculum-0.5.tar.gz), 02009-07-22.
- Added support to store functions in LuaValues. This allows some nice tricks like letting the Lua side register callbacks implemented in Lua, that will be eventually called by the C++ side (and this works even with anonymous functions).
- Removed the dependency on Boost.Variant. Boost is still a dependency, but this will reduce the size of the binaries considerably, specially in debug builds. (Thanks to Jason Gauci for the initial implementation of this feature.)
- Added a LuaValue::asObjectPtr() method, that provides handy access in the C++ side to a pointer to objects instantiated in Lua. (Another feature by Jason Gauci.)
- Added a LuaValue::asInteger() method. (Yet another contribution of Jason Gauci.)
- The build system has been changed to CMake. Anyway, I strongly recommend everyone to add Diluculum source files to their own projects.
- Fixed some little bugs here and there.
- Diluculum 0.4 (Diluculum-0.4.tar.gz), 02007-02-06.
- When exporting C++ classes to Lua, it is no longer necessary to call two macros for each exported method.
- Added support for creating dynamically loadable modules (those Lua modules stored in a dynamic library, which is loaded when the Lua programmer says require "MyModule").
- Diluculum 0.3.1 (Diluculum-0.3.1.tar.gz, 02006-07-26).
- Fixed a small (not so small, depending on how you see it…) error in the definition of the DILUCULUM_REGISTER_OBJECT() macro.
- Added a Makefile for Linux/GCC.
- Added a Code Blocks project file, contributed by Hakki Dogusan.
- Diluculum 0.3 (Diluculum-0.3.tar.gz), 02006-07-03).
- The first public release.
Contact
Diluculum is developed by Leandro Motta Barros. The preferred channel to talk about Diluculum is its mailing list. Anyway, if you really, really want to contact the author directly, look at the About page for contact information.