private void importConsole(@NonNull ScriptableObject scope) throws StethoJsException { // Set the `console` object try { ScriptableObject.defineClass(scope, JsConsole.class); JsConsole console = new JsConsole(scope); scope.defineProperty("console", console, ScriptableObject.DONTENUM); } catch (Exception e) { throw new StethoJsException(e, "Failed to setup javascript console"); } }
public DocumentConverter(final Context context, final View view) throws IOException, JSONException { this.context = context; scope = context.initStandardObjects(); context.setLanguageVersion(Context.VERSION_1_8); // Allow custom document helper class. try { ScriptableObject.defineClass(scope, RhinoDocument.class); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } // Add a log object ScriptableObject.putProperty(scope, "log", new JSLog()); // Compile user-specified function try { viewFun = view.compileFunction(context, scope); } catch (final RhinoException e) { LOG.error("View code for " + view + " does not compile."); throw e; } }
/** * Defines the class for the global object. */ protected void defineGlobalWrapperClass(Scriptable global) { try { ScriptableObject.defineClass(global, GlobalWrapper.class); } catch (Exception ex) { // cannot happen } }
/** * Defines the class for the global object. */ protected void defineGlobalWrapperClass(Scriptable global) { try { ScriptableObject.defineClass(global, WindowWrapper.class); } catch (Exception ex) { // cannot happen } }
/** * Defines the class for the global object. */ protected void defineGlobalWrapperClass(Scriptable global) { try { ScriptableObject.defineClass(global, WindowWrapper.class); } catch (Exception ex) { // cannot happen } }
/** * Defines the class for the global object. */ protected void defineGlobalWrapperClass(Scriptable global) { try { ScriptableObject.defineClass(global, WindowWrapper.class); } catch (Exception ex) { // cannot happen } }
/** * Defines the class for the global object. */ protected void defineGlobalWrapperClass(Scriptable global) { try { ScriptableObject.defineClass(global, GlobalWrapper.class); } catch (Exception ex) { // cannot happen } }
public static <T extends Scriptable> void defineClass(Scriptable scope, Class<T> clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException { ScriptableObject.defineClass(scope, clazz, sealed); }
/** * Defines the class for the global object. */ protected void defineGlobalWrapperClass(Scriptable global) { try { ScriptableObject.defineClass(global, GlobalWrapper.class); } catch (Exception ex) { // cannot happen } }
public static <T extends Scriptable> String defineClass(Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { return ScriptableObject.defineClass(scope, clazz, sealed, mapInheritance); }
public static <T extends Scriptable> void defineClass(Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { ScriptableObject.defineClass(scope, clazz); }
private static void initHTMLObjects( Scriptable scope ) throws IllegalAccessException, InstantiationException, InvocationTargetException, ClassDefinitionException, PropertyException { ScriptableObject.defineClass( scope, Window.class ); ScriptableObject.defineClass( scope, Document.class ); ScriptableObject.defineClass( scope, Style.class ); ScriptableObject.defineClass( scope, Location.class ); ScriptableObject.defineClass( scope, Navigator.class ); ScriptableObject.defineClass( scope, Screen.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Form.class ); ScriptableObject.defineClass( scope, Control.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Image.class ); ScriptableObject.defineClass( scope, Options.class ); ScriptableObject.defineClass( scope, Option.class ); ScriptableObject.defineClass( scope, ElementArray.class ); ScriptableObject.defineClass( scope, HTMLElement.class ); }
private static void initHTMLObjects( Scriptable scope ) throws IllegalAccessException, InstantiationException, InvocationTargetException, ClassDefinitionException, PropertyException { ScriptableObject.defineClass( scope, Window.class ); ScriptableObject.defineClass( scope, Document.class ); ScriptableObject.defineClass( scope, Style.class ); ScriptableObject.defineClass( scope, Location.class ); ScriptableObject.defineClass( scope, Navigator.class ); ScriptableObject.defineClass( scope, Screen.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Form.class ); ScriptableObject.defineClass( scope, Control.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Image.class ); ScriptableObject.defineClass( scope, Options.class ); ScriptableObject.defineClass( scope, Option.class ); ScriptableObject.defineClass( scope, ElementArray.class ); ScriptableObject.defineClass( scope, HTMLElement.class ); }
private static void initHTMLObjects( Scriptable scope ) throws IllegalAccessException, InstantiationException, InvocationTargetException, ClassDefinitionException, PropertyException { ScriptableObject.defineClass( scope, Window.class ); ScriptableObject.defineClass( scope, Document.class ); ScriptableObject.defineClass( scope, Style.class ); ScriptableObject.defineClass( scope, Location.class ); ScriptableObject.defineClass( scope, Navigator.class ); ScriptableObject.defineClass( scope, Screen.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Form.class ); ScriptableObject.defineClass( scope, Control.class ); ScriptableObject.defineClass( scope, Link.class ); ScriptableObject.defineClass( scope, Image.class ); ScriptableObject.defineClass( scope, Options.class ); ScriptableObject.defineClass( scope, Option.class ); ScriptableObject.defineClass( scope, ElementArray.class ); ScriptableObject.defineClass( scope, HTMLElement.class ); }
@Override public Scriptable registerExports(Context cx, Scriptable global, NodeRuntime runtime) throws InvocationTargetException, IllegalAccessException, InstantiationException { ScriptableObject.defineClass(global, Referenceable.class); ScriptableObject.defineClass(global, JdbcImpl.class); ScriptableObject.defineClass(global, JdbcConnection.class, false, true); ScriptableObject.defineClass(global, JdbcResultHandle.class); JdbcImpl impl = (JdbcImpl)cx.newObject(global, JdbcImpl.CLASS_NAME); impl.init(runtime); return impl; }
@Override public Scriptable registerExports(Context cx, Scriptable global, NodeRuntime runtime) throws InvocationTargetException, IllegalAccessException, InstantiationException { ScriptableObject.defineClass(global, IconvModuleImpl.class); Scriptable exports = cx.newObject(global, IconvModuleImpl.CLASS_NAME); ScriptableObject.defineClass(exports, IconvImpl.class); return exports; }
public static void defineClass(ScriptableObject scope) { try { ScriptableObject.defineClass(scope, Environment.class); } catch (Exception e) { throw new Error(e.getMessage()); } }
public static void defineClass(ScriptableObject scope) { try { ScriptableObject.defineClass(scope, Environment.class); } catch (Exception e) { throw new Error(e.getMessage()); } }
@Override public Scriptable registerExports(Context cx, Scriptable global, NodeRuntime runtime) throws InvocationTargetException, IllegalAccessException, InstantiationException { Scriptable exp = cx.newObject(global); exp.setPrototype(global); exp.setParentScope(null); ScriptableObject.defineClass(exp, ContextImpl.class); ScriptableObject.defineClass(exp, ScriptImpl.class); return exp; }
@Override public Scriptable registerExports(Context cx, Scriptable global, NodeRuntime runtime) throws InvocationTargetException, IllegalAccessException, InstantiationException { ScriptableObject.defineClass(global, XmlWrapImpl.class); XmlWrapImpl wrap = (XmlWrapImpl)cx.newObject(global, XmlWrapImpl.CLASS_NAME); wrap.initTransformer(cx, runtime); return wrap; }