diff src/luan/modules/http/LuanHandler.java @ 1563:8fbcc4747091

remove LuanFunction.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 09 Nov 2020 01:37:57 -0700
parents b89212fd04b5
children c922446f53aa
line wrap: on
line diff
--- a/src/luan/modules/http/LuanHandler.java	Sun Nov 08 16:50:59 2020 -0700
+++ b/src/luan/modules/http/LuanHandler.java	Mon Nov 09 01:37:57 2020 -0700
@@ -67,10 +67,10 @@
 			Fns fns = new Fns(this);
 			LuanTable Http = (LuanTable)luanInit.require("luan:http/Http.luan");
 			if( Http.get(luanInit,"reset_luan") == null )
-				Http.put( luanInit, "reset_luan", new LuanJavaFunction(luanInit,resetLuanMethod,fns) );
-			Http.put( luanInit, "eval_in_root", new LuanJavaFunction(luanInit,evalInRootMethod,fns) );
-			Http.put( luanInit, "disable_luan", new LuanJavaFunction(luanInit,disableLuanMethod,fns) );
-			Http.put( luanInit, "dont_gc", new LuanJavaFunction(luanInit,dontGcMethod,fns) );
+				Http.put( luanInit, "reset_luan", new LuanJavaFunction(resetLuanMethod,fns) );
+			Http.put( luanInit, "eval_in_root", new LuanJavaFunction(evalInRootMethod,fns) );
+			Http.put( luanInit, "disable_luan", new LuanJavaFunction(disableLuanMethod,fns) );
+			Http.put( luanInit, "dont_gc", new LuanJavaFunction(dontGcMethod,fns) );
 		} catch(LuanException e) {
 			throw new RuntimeException(e);
 		}
@@ -153,7 +153,7 @@
 				LuanCloner cloner = new LuanCloner(LuanCloner.Type.INCREMENTAL);
 				fn = (LuanFunction)cloner.get(fn);
 			}
-			return fn.call(args);
+			return fn.call(luan,args);
 		} finally {
 			LuanLogger.endThreadLogging();
 			rwLock.readLock().unlock();
@@ -190,7 +190,7 @@
 			LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE);
 			luan = (Luan)cloner.clone(currentLuan);
 		}
-		luan.load(text,"<eval_in_root>",false,null).call();
+		luan.load(text,"<eval_in_root>",false,null).call(luan);
 		currentLuan = luan;
 	}
 
@@ -256,7 +256,7 @@
 			luan = (Luan)cloner.clone(currentLuan);
 		}
 		LuanTable module = (LuanTable)luan.require("luan:http/Http.luan");
-		return (Response)module.fn(luan,"handle_error").call( request, e.table(luan) );
+		return (Response)module.fn("handle_error").call( luan, request, e.table(luan) );
 	}
 
 	private Response serviceLuan(Request request)
@@ -278,10 +278,10 @@
 			fn = (LuanFunction)cloner.get(mod);
 		}
 		LuanTable module = (LuanTable)luan.require("luan:http/Http.luan");
-		module.fn(luan,"new_request").call(request);
-		module.fn(luan,"new_response").call();
-		fn.call();
-		return (Response)module.fn(luan,"finish").call();
+		module.fn("new_request").call(luan,request);
+		module.fn("new_response").call(luan);
+		fn.call(luan);
+		return (Response)module.fn("finish").call(luan);
 	}
 
 	private Response serviceNotFound(Request request)
@@ -292,7 +292,7 @@
 		synchronized(luanInit) {
 			enableLoad("luan:http/Http.luan");
  			LuanTable module = (LuanTable)currentLuan.require("luan:http/Http.luan");
-			fn = module.fn(currentLuan,"not_found_handler");
+			fn = module.fn("not_found_handler");
 			if( fn == null )
 				return null;
 			LuanCloner cloner = new LuanCloner(LuanCloner.Type.INCREMENTAL);
@@ -300,13 +300,13 @@
 			fn = (LuanFunction)cloner.get(fn);
 		}
 		LuanTable module = (LuanTable)luan.require("luan:http/Http.luan");
-		module.fn(luan,"new_request").call(request);
-		module.fn(luan,"new_response").call();
-		Object obj = Luan.first(fn.call());
+		module.fn("new_request").call(luan,request);
+		module.fn("new_response").call(luan);
+		Object obj = Luan.first(fn.call(luan));
 		if( !(obj instanceof Boolean) )
 			throw new LuanException("not_found_handler must return boolean");
 		boolean handled = (Boolean)obj;
-		return handled ? (Response)module.fn(luan,"finish").call() : null;
+		return handled ? (Response)module.fn("finish").call(luan) : null;
 	}
 
 	private void enableLoad(String... mods) throws LuanException {