getSkin() implements cached skin creation
This commit is contained in:
parent
335931bddb
commit
f49b5eb157
1 changed files with 11 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue