fox for issue #38 #49

Merged
merged 3 commits into from Apr 6, 2012
View
@@ -2,3 +2,5 @@ build/
*.pbxuser
*.perspectivev3
wax.framework
+xcuserdata
+.DS_Store
View
@@ -29,11 +29,13 @@
static int exitApp(lua_State *L);
static int objcDebug(lua_State *L);
+static lua_State *currentL;
lua_State *wax_currentLuaState() {
- static lua_State *L;
- if (!L) L = lua_open();
- return L;
+ if (!currentL)
+ currentL = lua_open();
+
+ return currentL;
}
void uncaughtExceptionHandler(NSException *e) {
@@ -152,7 +154,9 @@ void wax_startWithServer() {
}
void wax_end() {
+ [wax_gc stop];
lua_close(wax_currentLuaState());
+ currentL = 0;
}
static void addGlobals(lua_State *L) {
View
@@ -73,10 +73,7 @@ static int __call(lua_State *L) {
const char *className = luaL_checkstring(L, 2);
Class klass = objc_getClass(className);
- if (klass) { // Class should not already exist!
- luaL_error(L, "Trying to create a class named '%s', but one already exists.", className);
- }
- else {
+ if (!klass) {
Class superClass;
if (lua_isuserdata(L, 3)) {
wax_instance_userdata *instanceUserdata = (wax_instance_userdata *)luaL_checkudata(L, 3, WAX_INSTANCE_METATABLE_NAME);
View
@@ -14,6 +14,7 @@
}
+ (void)start;
++ (void)stop;
+ (void)cleanupUnusedObject;
@end
View
@@ -19,8 +19,16 @@
@implementation wax_gc
+static NSTimer* timer = nil;
+
+ (void)start {
- [NSTimer scheduledTimerWithTimeInterval:WAX_GC_TIMEOUT target:self selector:@selector(cleanupUnusedObject) userInfo:nil repeats:YES];
+ [timer invalidate];
+ timer = [NSTimer scheduledTimerWithTimeInterval:WAX_GC_TIMEOUT target:self selector:@selector(cleanupUnusedObject) userInfo:nil repeats:YES];
+}
+
++ (void)stop {
+ [timer invalidate];
+ timer = nil;
}
+ (void)cleanupUnusedObject {
@@ -526,7 +526,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/zsh;
- shellScript = "\"$PROJECT_DIR/wax/lib/build-scripts/compile-stdlib.sh\"";
+ shellScript = "#\"$PROJECT_DIR/wax/lib/build-scripts/compile-stdlib.sh\"";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */