Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fox for issue #38 #49

Merged
merged 3 commits into from

2 participants

@zbyhoo

This fix makes possible to close wax with wax_end() and during same application runtime execute again wax_start().

Modifications:
1) stoping wax_gc during wax_end() by invalidating wax_gc timer
2) not throwing an error when objc class already exists
3) zeroing lua_State variable during wax_end()

@probablycorey

Awesome :star: :mega:

@probablycorey probablycorey merged commit bba4229 into probablycorey:master
@zbyhoo

One more thing. I had problems running my compiled version of the Framework project (error saying about bad header in precompiled stdlib file or something like that). The only solution I found was disabling compile-stdlib.sh script . By mistake I pushed that commit to my forked wax repository. I see that this commit was also included in pull request (but I send pull request earlier, I don't know github that much).

I don't know if it's big issue, but probably the project file should be reverted, it's up to you. I'm really sorry for the problem.

Besides that, do you know why this error occured while I was running my compiled version of the Framework project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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 */
Something went wrong with that request. Please try again.