commit b7db5d518937efe578ba244a8d3205d2ade0f240
parent 9646ce0db3e5d3fa7126cf828ebf1f81b83506d3
Author: Commit-Bot <unknown>
Date: Mon, 29 Nov 2010 18:49:36 +0000
Automatic commit from picoLisp.tgz, From: Mon, 29 Nov 2010 18:49:36 GMT
Diffstat:
5 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/ersatz/fun.src b/ersatz/fun.src
@@ -1,4 +1,4 @@
-# 28nov10abu
+# 29nov10abu
# (c) Software Lab. Alexander Burger
# Ersatz PicoLisp Functions
@@ -91,6 +91,37 @@ public (x y z s o)
}
catch (Exception e) {return err(ex, null, e.toString());}
+# (interface 'cls|lst 'sym 'fun ..) -> obj
+interface (i x y)
+ y = (x = ex.Cdr).Car.eval();
+ Class[] c = new Class[y instanceof Cell? (int)y.length() : 1];
+ try {
+ if (y instanceof Cell)
+ for (i = 0; i < c.length; ++i, y = y.Cdr)
+ c[i] = java.lang.Class.forName(y.Car.name());
+ else
+ c[0] = java.lang.Class.forName(y.name());
+ }
+ catch (Exception e) {err(ex, null, e.toString());}
+ final HashMap<String,Any> act = new HashMap<String,Any>();
+ while ((x = x.Cdr) instanceof Cell) {
+ y = x.Car.eval();
+ act.put(y.name(), (x = x.Cdr).Car.eval());
+ }
+ InvocationHandler h = new InvocationHandler() {
+ public Object invoke(Object o, Method m, Object[] arg) {
+ Any w;
+ if ((w = act.get(m.getName())) == null)
+ err(null, mkStr(m.getName()), "Can't invoke");
+ Any[] v = new Any[arg.length];
+ v[0] = new Symbol(o);
+ for (int i = 0; i < arg.length; ++i)
+ v[i] = new Symbol(arg[i]);
+ return w.apply(null, false, v, v.length);
+ }
+ };
+ return new Symbol(java.lang.reflect.Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), c, h));
+
# (java 'obj ['cnt]) -> any
# (java 'obj 'msg 'any ..) -> obj
# (java 'cls 'msg 'any ..) -> obj
diff --git a/ersatz/lib.l b/ersatz/lib.l
@@ -1,4 +1,4 @@
-# 19nov10abu
+# 29nov10abu
# (c) Software Lab. Alexander Burger
(on *Dbg)
@@ -1824,4 +1824,21 @@
(in Sock (run Prg 1)) )
(close Sock) ) ) )
+############ Native Java ############
+
+(de javac (Cls Ext Impl . @)
+ (let (J (pack "tmp/" Cls ".java") C (pack "tmp/" Cls ".class"))
+ (call 'mkdir "-p" "tmp/")
+ (out J
+ (while (args)
+ (prinl "import " (next) ";") )
+ (prinl "public class " Cls
+ (and Ext (pack " extends " @))
+ (and Impl (pack " implements " (glue ", " Impl)))
+ " {" )
+ (here "/**/")
+ (prinl "}") )
+ (call "javac" "-O" "-g:none" J)
+ (push1 '*Bye (list 'call "rm" J C)) ) )
+
# vi:et:ts=3:sw=3
diff --git a/ersatz/picolisp b/ersatz/picolisp
@@ -1,5 +1,5 @@
#!/bin/sh
-# 17nov10abu
+# 29nov10abu
# Run Ersatz PicoLisp
-exec java -DPID=$$ -jar ${0%/*}/picolisp.jar ${0%/*}/lib.l "$@"
+exec java -DPID=$$ -cp .:tmp:${0%/*}/picolisp.jar PicoLisp ${0%/*}/lib.l "$@"
diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar
Binary files differ.
diff --git a/src64/version.l b/src64/version.l
@@ -1,6 +1,6 @@
-# 28nov10abu
+# 29nov10abu
# (c) Software Lab. Alexander Burger
-(de *Version 3 0 4 14)
+(de *Version 3 0 4 15)
# vi:et:ts=3:sw=3