I've created a test branch (philmoz-modulesV2) for review/testing of some rework I've done on the module system.
The core changes are:
1. Auto-load of modules when the module functions are used.
This replaces code like:
if (libscriptapi)
libscriptapi->set_as_ret(0);
with just
libscriptapi->set_as_ret(0);
2. Cleaned up unloading and management of module lifetime.
Each loop of the keyboard task the code now asks each module if it can be unloaded. If it returns true then the module is removed.
This leaves knowledge and management of the module to the module itself rather than in the core CHDK code. The dng, grid, zebra and edge overlay modules can now unload when not being used instead of remaining in memory.
The code also alerts modules when CHDK is leaving <ALT> mode. Many of the modules are only valid in ALT mode (games etc) so they need to quit and unload if the user presses the ALT button.
3. Added logging of the load/unload of the modules to a text file.
This can be enabled in the Miscellaneous stuff --> Modules menu. There is also a menu option to delete the log file. The log file is always appended to so it can grow out of control if logging is left on. The log also includes a timestamp when the system writes the first entry each time the camera is restarted.
4. Updated Lua to version 5.1.5 (Feb 2012 release) from 5.1.3 (Jan 2008 release).
I also looked at 5.2; but the changes are much more substantial so will take a lot more effort to update.
Phil.