From 2558a118a94303dc8ab180223024202b15b95114 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 17 Jun 2003 14:44:59 +0000 Subject: [PATCH] Invoke scripted constructor function. --- src/helma/scripting/rhino/HopObject.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/helma/scripting/rhino/HopObject.java b/src/helma/scripting/rhino/HopObject.java index 4e129401..ed139daf 100644 --- a/src/helma/scripting/rhino/HopObject.java +++ b/src/helma/scripting/rhino/HopObject.java @@ -16,6 +16,7 @@ package helma.scripting.rhino; +import helma.scripting.ScriptingException; import helma.framework.*; import helma.framework.core.*; import helma.objectmodel.*; @@ -71,7 +72,8 @@ public class HopObject extends ScriptableObject { * This method is used as HopObject constructor from JavaScript. */ public static Object hopObjectConstructor(Context cx, Object[] args, - Function ctorObj, boolean inNewExpr) { + Function ctorObj, boolean inNewExpr) + throws ScriptingException { RhinoEngine engine = (RhinoEngine) cx.getThreadLocal("engine"); RhinoCore c = engine.core; String prototype = ((FunctionObject) ctorObj).getFunctionName(); @@ -80,6 +82,11 @@ public class HopObject extends ScriptableObject { HopObject hobj = new HopObject(prototype); hobj.init(c, n); + Scriptable p = c.getPrototype(prototype); + if (p != null) { + hobj.setPrototype(p); + engine.invoke(hobj, "constructor", args, false); + } return hobj; }