Invoke scripted constructor function.
This commit is contained in:
parent
85a6afe857
commit
2558a118a9
1 changed files with 8 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package helma.scripting.rhino;
|
package helma.scripting.rhino;
|
||||||
|
|
||||||
|
import helma.scripting.ScriptingException;
|
||||||
import helma.framework.*;
|
import helma.framework.*;
|
||||||
import helma.framework.core.*;
|
import helma.framework.core.*;
|
||||||
import helma.objectmodel.*;
|
import helma.objectmodel.*;
|
||||||
|
@ -71,7 +72,8 @@ public class HopObject extends ScriptableObject {
|
||||||
* This method is used as HopObject constructor from JavaScript.
|
* This method is used as HopObject constructor from JavaScript.
|
||||||
*/
|
*/
|
||||||
public static Object hopObjectConstructor(Context cx, Object[] args,
|
public static Object hopObjectConstructor(Context cx, Object[] args,
|
||||||
Function ctorObj, boolean inNewExpr) {
|
Function ctorObj, boolean inNewExpr)
|
||||||
|
throws ScriptingException {
|
||||||
RhinoEngine engine = (RhinoEngine) cx.getThreadLocal("engine");
|
RhinoEngine engine = (RhinoEngine) cx.getThreadLocal("engine");
|
||||||
RhinoCore c = engine.core;
|
RhinoCore c = engine.core;
|
||||||
String prototype = ((FunctionObject) ctorObj).getFunctionName();
|
String prototype = ((FunctionObject) ctorObj).getFunctionName();
|
||||||
|
@ -80,6 +82,11 @@ public class HopObject extends ScriptableObject {
|
||||||
HopObject hobj = new HopObject(prototype);
|
HopObject hobj = new HopObject(prototype);
|
||||||
|
|
||||||
hobj.init(c, n);
|
hobj.init(c, n);
|
||||||
|
Scriptable p = c.getPrototype(prototype);
|
||||||
|
if (p != null) {
|
||||||
|
hobj.setPrototype(p);
|
||||||
|
engine.invoke(hobj, "constructor", args, false);
|
||||||
|
}
|
||||||
|
|
||||||
return hobj;
|
return hobj;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue