moai/moai-dev — pull request #787 by patrickmeehan (2013-09-23 22:52:47+00:00)
Title: Feature dump Sep 23; revised Lua binding, SDL, misc

Sorry for the huge pull request. One of the challenges of the git workflow is that sometimes smaller pull requests on their own branches can't get merged in before I've taken back into my own development branch and continued work. It's not feasible for me to have a bunch of little feature branches waiting around - there are often inter-dependencies. So it's going to be monolithic pull requests more often the not.

This one is going to break some stuff. Here's a quick rundown of the breaky parts:

- I'm tired of *glut and moving to SDL. Decided to build SDL as a static lib which is supported on OSX but not so much on Windows. To that end I commented out a big chunk of SDL_stdlib.c. I'm sure there's a better solution through compiler settings and header substitution; I just didn't have time.
- The new SDL host is *minimal*. I'll add more features as I need them. Hoping the community will fill in the rest.
- Have not tried running the revised test runner host. Not sure if this was ever added to CI or used for anything.
- I built Xcode OSX but didn't have time for the iOS sample project. Am hoping someone volunteers to fix it up.
- I changed the naming scheme for the modules to clarify the initialization/finalization process. It used to be that 'app' initialization was implicit, but this led to asymmetry of calls in the host (even though it handled all cases). This bugged me, so I made it more explicit. Each module now has an app initialize/finalize and a context intitialize/finalize. (Didn't have time to do the mobile modules - just desktop/windows so far).
- I've added some helper files for the 'official' Moai host modules. They are under the 'host-modules' folder. This is still a little half-baked, but the idea is to make some of the host tedium reusable and hide a lot of the ugly #ifdef's.

Some important fixes/changes:

- I did a lot of work on the Lua binding as it pertains to GC. Still not sure if we are out of the woods, but the intermittent crashes I was seeing in out game have gone away.
- MOAISim now takes control of the GC when it starts running. So business as usual until the first sim loop, then collectgarbage gets replaces with a warning and MOAISim starts running the GC incrementally. This let me get rid of a bunch of release/retains in the dep graph and action tree update code.
- The engine-to-Lua lifecycle was improved and now correctly provides a ref table to singleton classes so Lua objects created inside of constructors should now be exposed to Lua correctly.
- I added a way to set a custom GC callback on Moai objects for debugging purposes (dangerous - use with care). Also added a flag on MOAILuaRuntime to log GC events.
- The new build settings on Xcode for iOS and OSX did *not* respect the implementation of the VFS via injection of zl_replace.h. This has been fixed. In the process I had to break zlcore into two libraries as zl-vfs is not supposed to have zl_replace.h injected. This is pretty darn important as the VFS will silently fail without this change.
- I added a flag to MOAIAction to disable its auto-stop on no children. The default keeps the original behavior.

I am starting some new projects that are going to add features to Moai SDK. I know this pull request is a pain, but if we can get it integrated, fixed and building that will pave the way for what's to come. Thanks!