Permalink
Browse files

Merge pull request #49 from zbyhoo/master

fox for issue #38
  • Loading branch information...
2 parents 95c2a41 + 7711c80 commit bba422996f8b9fe9027f4a31b2290c987035c3e8 @probablycorey committed Apr 6, 2012
Showing with 21 additions and 9 deletions.
  1. +2 −0 .gitignore
  2. +7 −3 lib/wax.m
  3. +1 −4 lib/wax_class.m
  4. +1 −0 lib/wax_gc.h
  5. +9 −1 lib/wax_gc.m
  6. +1 −1 tools/Framework/Framework.xcodeproj/project.pbxproj
View
2 .gitignore
@@ -2,3 +2,5 @@ build/
*.pbxuser
*.perspectivev3
wax.framework
+xcuserdata
+.DS_Store
View
10 lib/wax.m
@@ -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
5 lib/wax_class.m
@@ -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
1 lib/wax_gc.h
@@ -14,6 +14,7 @@
}
+ (void)start;
++ (void)stop;
+ (void)cleanupUnusedObject;
@end
View
10 lib/wax_gc.m
@@ -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 {
View
2 tools/Framework/Framework.xcodeproj/project.pbxproj
@@ -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 */

0 comments on commit bba4229

Please sign in to comment.