From f15dea42171cf7fcd03771c0adf892c4920f2542 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 18 Feb 2004 14:46:25 +0000 Subject: [PATCH] Adapt global seal() function from Rhino 1.5R5 from global shell object in Rhino 1.5R5 to allow sealing of JavaScript objects. --- src/helma/scripting/rhino/GlobalObject.java | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/helma/scripting/rhino/GlobalObject.java b/src/helma/scripting/rhino/GlobalObject.java index e045b7db..5e447fb7 100644 --- a/src/helma/scripting/rhino/GlobalObject.java +++ b/src/helma/scripting/rhino/GlobalObject.java @@ -63,7 +63,7 @@ public class GlobalObject extends ImporterTopLevel { "renderSkin", "renderSkinAsString", "getProperty", "authenticate", "createSkin", "format", "encode", "encodeXml", "encodeForm", "stripTags", "formatParagraphs", - "getXmlDocument", "getHtmlDocument", + "getXmlDocument", "getHtmlDocument", "seal", "getDBConnection", "getURL", "write", "writeln" }; @@ -415,6 +415,30 @@ public class GlobalObject extends ImporterTopLevel { System.out.println(str); } + /** + * The seal function seals all supplied arguments. + */ + public static void seal(Context cx, Scriptable thisObj, Object[] args, + Function funObj) + { + for (int i = 0; i != args.length; ++i) { + Object arg = args[i]; + if (!(arg instanceof ScriptableObject) || arg == Undefined.instance) + { + if (!(arg instanceof Scriptable) || arg == Undefined.instance) + { + throw new EvaluatorException("seal() can only be applied to Objects"); + } else { + throw new EvaluatorException("seal() can only be applied to Objects"); + } + } + } + + for (int i = 0; i != args.length; ++i) { + Object arg = args[i]; + ((ScriptableObject)arg).sealObject(); + } + } /** *