diff --git a/src/helma/framework/core/HopExtension.java b/src/helma/framework/core/HopExtension.java index dfbfcd5e..63c0643c 100644 --- a/src/helma/framework/core/HopExtension.java +++ b/src/helma/framework/core/HopExtension.java @@ -554,14 +554,22 @@ public class HopExtension { } /** - * Get a parsed Skin from the central skin repository + * Get a parsed Skin from the central skin cache if possible, otherwise create it */ class GlobalGetSkin extends BuiltinFunctionObject { GlobalGetSkin (String name, Evaluator evaluator, FunctionPrototype fp) { super (fp, evaluator, name, 1); } public ESValue callFunction (ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { - throw new EcmaScriptException ("getSkin() is not implemented yet, use createSkin() instead"); + if (arguments.length != 1 || ESNull.theNull.equals (arguments[0])) + throw new EcmaScriptException ("getSkin must be called with one String argument!"); + String str = arguments[0].toString (); + Skin skin = (Skin) app.skincache.get (str); + if (skin == null) { + skin = new Skin (str); + app.skincache.put (str, skin); + } + return new ESWrapper (skin, evaluator); } } @@ -574,7 +582,7 @@ public class HopExtension { } public ESValue callFunction (ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { if (arguments.length != 1 || ESNull.theNull.equals (arguments[0])) - throw new EcmaScriptException ("getSkin must be called with one String argument!"); + throw new EcmaScriptException ("createSkin must be called with one String argument!"); return new ESWrapper (new Skin (arguments[0].toString()), evaluator); } }