allow the scope to be passed in, so we can support narwhal more easily
[rhinodom.git] / com / metaweb / util / javascript / JSObject.java
blob8df9e87a0c314543a2f0abf679ed60bb3de6fc48
1 package com.metaweb.util.javascript;
3 import org.mozilla.javascript.Context;
4 import org.mozilla.javascript.Function;
5 import org.mozilla.javascript.Scriptable;
6 import org.mozilla.javascript.ScriptableObject;
8 public class JSObject extends ScriptableObject {
10 private static final long serialVersionUID = 3218033841430800117L;
12 protected Scriptable _scope;
14 public Scriptable makeJSInstance() {
15 Object jsobj = _scope.get(getClassName(), _scope);
16 Object[] args = { _scope, this };
17 return ((Function)jsobj).construct(Context.getCurrentContext(), _scope, args);
20 public Scriptable makeJSInstance(Scriptable scope) {
21 _scope = scope;
22 Object jsobj = scope.get(getClassName(), scope);
23 Object[] args = { scope, this };
24 return ((Function)jsobj).construct(Context.getCurrentContext(), scope, args);
27 public Scriptable getScope() {
28 return _scope;
31 public String getClassName() {
32 return "JSObject";