use of org.mozilla.javascript.Scriptable in project scriptographer by scriptographer.
the class ExtendedJavaObject method get.
public Object get(String name, Scriptable start) {
// defined in the underlying Java object
if (properties != null && properties.containsKey(name))
return properties.get(name);
if (changeReceiver != null)
fetchChangeReceiver();
Scriptable prototype = getPrototype();
Object result = prototype.get(name, this);
if (result != Scriptable.NOT_FOUND)
return result;
result = members.get(this, name, javaObject, false);
if (result != Scriptable.NOT_FOUND) {
if (javaObject instanceof ChangeReceiver)
handleChangeEmitter(result, name);
return result;
}
if (name.equals("prototype"))
return prototype;
return Scriptable.NOT_FOUND;
}
use of org.mozilla.javascript.Scriptable in project scriptographer by scriptographer.
the class ListWrapper method getDefaultValue.
public Object getDefaultValue(Class hint) {
if (hint == null || hint == ScriptRuntime.StringClass) {
StringBuffer buffer = new StringBuffer();
ReadOnlyList list = (ReadOnlyList) javaObject;
for (int i = 0, l = list.size(); i < l; i++) {
if (i > 0)
buffer.append(",");
Object entry = list.get(i);
if (entry != null) {
Scriptable obj = Context.toObject(entry, this);
buffer.append(obj.getDefaultValue(hint));
} else {
buffer.append("null");
}
}
return buffer.toString();
} else {
return super.getDefaultValue(hint);
}
}
use of org.mozilla.javascript.Scriptable in project scriptographer by scriptographer.
the class RhinoEngine method createScope.
public Scope createScope() {
Scriptable scope = new NativeObject();
// Sharing the top level scope:
// https://developer.mozilla.org/En/Rhino_documentation/Scopes_and_Contexts
scope.setPrototype(topLevel);
scope.setParentScope(null);
return new RhinoScope(this, scope);
}
use of org.mozilla.javascript.Scriptable in project scriptographer by scriptographer.
the class RhinoEngine method handleSignOperator.
public Object handleSignOperator(Context cx, Scriptable scope, int operator, Object rhs) {
switch(operator) {
case Token.NEG:
// Wrap String as Scriptable, so we can access its prototype easily too.
if (rhs instanceof String)
rhs = ScriptRuntime.toObject(cx, scope, rhs);
// Now perform the magic
if (rhs instanceof Scriptable) {
Scriptable scriptable = (Scriptable) rhs;
Object obj = ScriptableObject.getProperty(scriptable, "negate");
if (obj instanceof Callable)
return ((Callable) obj).call(cx, scope, scriptable, new Object[] {});
}
break;
case Token.POS:
// converted top + new Point(1, 2) by the interpreter...
return rhs;
}
return null;
}
use of org.mozilla.javascript.Scriptable in project neo4j by neo4j.
the class JavascriptExecutor method createPrototype.
private Scriptable createPrototype(Context cx) {
Scriptable proto = cx.initStandardObjects();
Scriptable topLevel = new ImporterTopLevel(cx);
proto.setParentScope(topLevel);
return proto;
}
Aggregations