Context.javaToJS( ScriptValuesAddedFunctions.class, jsscope ); ( (ScriptableObject) jsscope ) .defineFunctionProperties( ScriptValuesAddedFunctions.jsFunctionList, ScriptValuesAddedFunctions.class, ScriptableObject.DONTENUM );
( (ScriptableObject) jsscope ).defineFunctionProperties( jsFunctionList, ScriptAddedFunctions.class, ScriptableObject.DONTENUM ); } catch ( Exception ex ) {
( (ScriptableObject) jsscope ).defineFunctionProperties( jsFunctionList, ScriptValuesAddedFunctions.class, ScriptableObject.DONTENUM ); } catch ( Exception ex ) {
( (ScriptableObject) data.scope ).defineFunctionProperties( ScriptValuesAddedFunctions.jsFunctionList, ScriptValuesAddedFunctions.class, ScriptableObject.DONTENUM );
public class RJsDemo { @Test public void simpleRhinoTest() throws FileNotFoundException, IOException { Context cx = Context.enter(); final JsRuntimeSupport browserSupport = new JsRuntimeSupport(); final ScriptableObject sharedScope = cx.initStandardObjects(browserSupport, true); String[] names = { "print", "load" }; sharedScope.defineFunctionProperties(names, sharedScope.getClass(), ScriptableObject.DONTENUM); Scriptable argsObj = cx.newArray(sharedScope, new Object[] {}); sharedScope.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM); cx.evaluateReader(sharedScope, new FileReader("./r.js"), "require", 1, null); cx.evaluateReader(sharedScope, new FileReader("./loader.js"), "loader", 1, null); Context.exit(); } }
@Override public void initStandardObjects(Context cx, boolean sealed) { super.initStandardObjects(cx, sealed); final String[] names = { "print", "load"}; defineFunctionProperties(names, getClass(), ScriptableObject.DONTENUM); final ScriptableObject objProto = (ScriptableObject) getObjectPrototype(this); objProto.defineFunctionProperties(names, getClass(), DONTENUM); }
final Context context = Context.enter(); try { final ScriptableObject scope = context.initStandardObjects(); scope.defineFunctionProperties( new String[] {"defineClass"}, Global.class, ScriptableObject.DONTENUM); context.evaluateString(scope, script, "script", 1, null); // etc. } finally { Context.exit(); }
protected void addRequire(Context context, ScriptableObject scope, AbstractJsRequireHelper jsRequireHelper) throws Exception { scope.defineProperty(JsRequireHelper.VAR_NAME, jsRequireHelper, ScriptableObject.CONST); scope.defineFunctionProperties(new String[] { "load", "print" }, AbstractJsRequireHelper.class, ScriptableObject.DONTENUM); Scriptable argsObj = context.newArray(scope, new Object[] {}); scope.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM); evaluate(context, scope, rjsScript, "r.js"); }
topLevel.defineFunctionProperties(names, RhinoScriptEngine.class, ScriptableObject.DONTENUM);
topLevel.defineFunctionProperties(names, RhinoScriptEngine.class, ScriptableObject.DONTENUM);