[snow-cvs] r34 - in trunk: . lib src/java/snow src/lisp/snow/showcase
Alessio Stalla
astalla at common-lisp.net
Tue Dec 8 22:05:26 UTC 2009
Author: astalla
Date: Tue Dec 8 17:05:26 2009
New Revision: 34
Log:
Updated abcl
Added sample jnlp file
Added:
trunk/snow.jnlp
Modified:
trunk/lib/abcl.jar
trunk/src/java/snow/Snow.java
trunk/src/lisp/snow/showcase/showcase.lisp
Modified: trunk/lib/abcl.jar
==============================================================================
Binary files. No diff available.
Added: trunk/snow.jnlp
==============================================================================
--- (empty file)
+++ trunk/snow.jnlp Tue Dec 8 17:05:26 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jnlp spec="1.0+" codebase="http://localhost/">
+
+ <information>
+ <title>Snow Example</title>
+ <vendor>Alessio Stalla</vendor>
+ <offline-allowed/>
+ </information>
+
+ <application-desc main-class="snow.Snow">
+ </application-desc>
+
+ <resources>
+ <java version="1.6+" />
+ <jar href="abcl.jar" />
+ <jar href="snow.jar" main="true"/>
+ <jar href="commons-logging.jar" />
+ <jar href="binding-2.0.6.jar" />
+ <jar href="miglayout-3.6.2.jar"/>
+ </resources>
+
+ <security>
+ <all-permissions />
+ </security>
+
+ <update check="background" policy="prompt-update">
+
+</jnlp>
Modified: trunk/src/java/snow/Snow.java
==============================================================================
--- trunk/src/java/snow/Snow.java (original)
+++ trunk/src/java/snow/Snow.java Tue Dec 8 17:05:26 2009
@@ -49,8 +49,12 @@
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
+import java.security.*;
+
import org.armedbear.lisp.Interpreter;
+import java.io.*;
+
public abstract class Snow {
private static boolean init = false;
@@ -63,7 +67,10 @@
*/
public static synchronized void initAux() throws ScriptException {
if(!init) {
- lispEngine = new ScriptEngineManager(Snow.class.getClassLoader()).getEngineByExtension("lisp");
+ try {
+ lispEngine = new ScriptEngineManager(Snow.class.getClassLoader()).getEngineByExtension("lisp");
+ } catch(final Throwable t) {
+ }
URL url = Snow.class.getResource("/snow/snow.asd");
if(url == null) {
throw new RuntimeException("snow.asd not found in classpath: have you installed Snow correctly?");
@@ -101,20 +108,18 @@
extracted.mkdirs();
} else {
extracted.getParentFile().mkdirs();
- byte[] buf = new byte[(int)entry.getSize()]; //probably inefficient
- int read = 0;
+ FileOutputStream fos = new FileOutputStream(extracted);
+ byte[] buf = new byte[4096];
while(true) {
- int justRead = extractor.read(buf, read, buf.length - read);
- if(justRead >= 0 && read < buf.length) {
- read += justRead;
+ int read = extractor.read(buf);
+ if(read != -1) {
+ fos.write(buf, 0, read);
} else {
+ fos.flush();
+ fos.close();
break;
}
}
- FileOutputStream fos = new FileOutputStream(extracted);
- fos.write(buf);
- fos.flush();
- fos.close();
}
extracted.setLastModified(entry.getTime());
System.out.println("Extracted " + extracted.getAbsolutePath());
@@ -255,7 +260,19 @@
try {
if(args.length == 0) { //Launch GUI REPL
evalResource(Snow.class, "/snow/start.lisp", false);
- } else { //Launch regular ABCL
+ } else if("--showcase".equals(args[0])) {
+ //Needed for Java WebStart
+ Policy.setPolicy
+ (new Policy() {
+ public PermissionCollection getPermissions(CodeSource codesource) {
+ Permissions perms = new Permissions();
+ perms.add(new AllPermission());
+ return (perms);
+ }
+ });
+ evalResource(Snow.class, "/snow/showcase/showcase.lisp", false);
+ getInvocable().invokeFunction("snow-showcase::showcase", true);
+ } else {//Launch regular ABCL
//Copied from org.armedbear.lisp.Main.main()
Runnable r = new Runnable() {
public void run() {
@@ -271,7 +288,9 @@
}
}
};
- new Thread(null, r, "interpreter", 4194304L).start();
+ Thread t = new Thread(null, r, "interpreter", 4194304L);
+ t.setDaemon(true);
+ t.start();
}
} catch (Exception e) {
e.printStackTrace();
Modified: trunk/src/lisp/snow/showcase/showcase.lisp
==============================================================================
--- trunk/src/lisp/snow/showcase/showcase.lisp (original)
+++ trunk/src/lisp/snow/showcase/showcase.lisp Tue Dec 8 17:05:26 2009
@@ -112,10 +112,11 @@
(princ "Thanks for pushing me! ")
(finish-output))))
-(defun showcase ()
- (with-gui (:swing)
- (frame (:id frame :title "Sample JFrame" :visible-p t :size #C(800 600)
- :layout-manager '(:mig "fill"))
+(defun showcase (&optional exit-on-close-p)
+ (with-gui ()
+ (frame (:id frame :title "Snow Showcase" :visible-p t :size #C(800 600)
+ :layout-manager '(:mig "fill")
+ :on-close (when exit-on-close-p :exit))
(tabs (:layout "grow")
(dolist (x (reverse *examples*))
(tab (car x) (funcall (cadr x))))))))
More information about the snow-cvs
mailing list