X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FResources.java;h=615ef97ab8394e5c99048f8638f6ec85c0377f70;hb=93224727752b3da9a70bacd473c5f961efb3a297;hp=52e098034dfb5ce38f2d9275f7dfd0bdb66b8627;hpb=76be7193753c49a850a236623444afbe993193ea;p=org.ibex.core.git diff --git a/src/org/xwt/Resources.java b/src/org/xwt/Resources.java index 52e0980..615ef97 100644 --- a/src/org/xwt/Resources.java +++ b/src/org/xwt/Resources.java @@ -6,8 +6,7 @@ import java.net.*; import java.util.*; import java.util.zip.*; import java.lang.*; -import java.applet.*; -import org.mozilla.javascript.*; +import org.xwt.js.*; import org.xwt.util.*; /** @@ -39,9 +38,8 @@ public class Resources { char c = name.charAt(i); if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || - c == '_' || - (c >= '0' && c <= '9') || - (c == '.' && i == name.length() - 4))) return false; + c == '_' || c == '.' || + (c >= '0' && c <= '9'))) return false; } return true; } @@ -49,7 +47,9 @@ public class Resources { /** Load a directory as if it were an archive */ public static synchronized void loadDirectory(File dir) throws IOException { loadDirectory(dir, ""); } private static synchronized void loadDirectory(File dir, String prefix) throws IOException { - new Static(prefix.replace(File.separatorChar, '.')); + String n = prefix.replace(File.separatorChar, '.'); + if (n.endsWith(".")) n = n.substring(0, n.length() - 1); + new Static(n); String[] subfiles = dir.list(); for(int i=0; i 0) { - int read = super.read(b, off, len); - if (read == -1) break; - ret += read; - len -= read; - off += read; - } - + int ret = super.read(b, off, len); if (clear && callback != null) { clear = false; - ThreadMessage.newthread(new JSObject.JSFunction() { - public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) throws JavaScriptException { + ThreadMessage.newthread(new JS.Callable() { + public Object call(JS.Array args_) throws JS.Exn { try { - callback.call(cx, null, null, new Object[] { new Double(bytesDownloaded), new Double(length) }); + JS.Array args = new JS.Array(); + args.addElement(new Double(bytesDownloaded)); + args.addElement(new Double(length)); + callback.call(args); } finally { clear = true; } @@ -107,15 +99,15 @@ public class Resources { } }); } - bytesDownloaded += ret; return ret; } }); + Template.TemplateHelper t = new Template.TemplateHelper(); + for(ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry()) { String name = ze.getName(); - if (Log.on) Log.log(Resources.class, name); if (!validResourceName(name.substring(name.lastIndexOf('/') + 1))) { if (Log.on) Log.log(Resources.class, "WARNING: ignoring xwar entry with invalid name: " + name); continue; @@ -125,16 +117,8 @@ public class Resources { // placeholder so resolveResource() works properly bytes.put(name.replace('/', '.'), new byte[] { }); name = name.substring(0, name.length() - 4); - - String packageName = JSObject.nodeNameToPackageName(name.replace('/', '.')); - Object user = usedPackages.get(packageName); - if (user != null && user != thisArchive) { - if (Log.on) Log.log(Resources.class, "templates have already been loaded into " + packageName + "; refusing to load " + name); - } else { - usedPackages.put(packageName, thisArchive); - Static.createStatic(name.replace('/', '.'), false); - Template.buildTemplate(zis, name.replace('/', '.')); - } + Static.createStatic(name.replace('/', '.'), false); + Template.buildTemplate(zis, name.replace('/', '.'), t); } else { bytes.put(name.replace('/', '.'), isToByteArray(zis));