public abstract class ModuleSpace extends Object implements ShellJavaScriptHost
Modifier and Type | Field and Description |
---|---|
protected ModuleSpaceHost |
host |
Modifier | Constructor and Description |
---|---|
protected |
ModuleSpace(TreeLogger logger,
ModuleSpaceHost host,
String moduleName) |
Modifier and Type | Method and Description |
---|---|
protected static RuntimeException |
createJavaScriptException(ClassLoader cl,
Object exception)
Equivalent to
createJavaScriptException(cl, exception, "") . |
protected static RuntimeException |
createJavaScriptException(ClassLoader cl,
Object exception,
String message)
Create a JavaScriptException object.
|
protected String |
createNativeMethodInjector(String jsniSignature,
String[] paramNames,
String js) |
protected abstract void |
createStaticDispatcher(TreeLogger logger)
Create the __defineStatic method.
|
void |
dispose() |
protected abstract JsValue |
doInvoke(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invokes a native JavaScript function.
|
void |
exceptionCaught(Object exception)
Call this when a JavaScript exception is caught.
|
protected CompilingClassLoader |
getIsolatedClassLoader() |
protected static TreeLogger |
getLogger() |
String |
getModuleName()
Get the module name.
|
protected abstract Object |
getStaticDispatcher()
Injects the magic needed to resolve JSNI references from module-space.
|
protected JsValue |
invokeNative(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invokes a native JavaScript function.
|
boolean |
invokeNativeBoolean(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a boolean value.
|
byte |
invokeNativeByte(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a byte value.
|
char |
invokeNativeChar(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a character value.
|
double |
invokeNativeDouble(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a double value.
|
float |
invokeNativeFloat(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a float value.
|
int |
invokeNativeInt(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns an integer value.
|
long |
invokeNativeLong(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a long value.
|
Object |
invokeNativeObject(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns an object value.
|
short |
invokeNativeShort(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns a short value.
|
void |
invokeNativeVoid(String name,
Object jthis,
Class<?>[] types,
Object[] args)
Invoke a native JavaScript function that returns no value.
|
protected boolean |
isExceptionSame(Throwable original,
Object exception) |
void |
log(String message,
Throwable e)
Allows client-side code to log to the tree logger.
|
void |
onLoad(TreeLogger logger)
Runs the module's user startup code.
|
protected String |
rebind(String sourceName) |
<T> T |
rebindAndCreate(String requestedClassName)
Resolves a deferred binding request and create the requested object.
|
static void |
setThrownJavaException(Throwable t) |
createNativeMethods
protected final ModuleSpaceHost host
protected ModuleSpace(TreeLogger logger, ModuleSpaceHost host, String moduleName)
public static void setThrownJavaException(Throwable t)
protected static RuntimeException createJavaScriptException(ClassLoader cl, Object exception)
createJavaScriptException(cl, exception, "")
.protected static RuntimeException createJavaScriptException(ClassLoader cl, Object exception, String message)
protected static TreeLogger getLogger()
public void dispose()
public void exceptionCaught(Object exception)
ShellJavaScriptHost
exceptionCaught
in interface ShellJavaScriptHost
public String getModuleName()
public boolean invokeNativeBoolean(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeBoolean
in interface ShellJavaScriptHost
Throwable
public byte invokeNativeByte(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeByte
in interface ShellJavaScriptHost
Throwable
public char invokeNativeChar(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeChar
in interface ShellJavaScriptHost
Throwable
public double invokeNativeDouble(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeDouble
in interface ShellJavaScriptHost
Throwable
public float invokeNativeFloat(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeFloat
in interface ShellJavaScriptHost
Throwable
public int invokeNativeInt(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeInt
in interface ShellJavaScriptHost
Throwable
public long invokeNativeLong(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeLong
in interface ShellJavaScriptHost
Throwable
public Object invokeNativeObject(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeObject
in interface ShellJavaScriptHost
Throwable
public short invokeNativeShort(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeShort
in interface ShellJavaScriptHost
Throwable
public void invokeNativeVoid(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
ShellJavaScriptHost
invokeNativeVoid
in interface ShellJavaScriptHost
Throwable
public void log(String message, Throwable e)
log
in interface ShellJavaScriptHost
public final void onLoad(TreeLogger logger) throws UnableToCompleteException
UnableToCompleteException
public <T> T rebindAndCreate(String requestedClassName) throws UnableToCompleteException
ShellJavaScriptHost
rebindAndCreate
in interface ShellJavaScriptHost
UnableToCompleteException
protected String createNativeMethodInjector(String jsniSignature, String[] paramNames, String js)
protected abstract void createStaticDispatcher(TreeLogger logger)
logger
- protected abstract JsValue doInvoke(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
name
- the name of the function to invokejthis
- the function's 'this' contexttypes
- the type of each argumentargs
- the arguments to be passedThrowable
protected CompilingClassLoader getIsolatedClassLoader()
protected abstract Object getStaticDispatcher()
protected final JsValue invokeNative(String name, Object jthis, Class<?>[] types, Object[] args) throws Throwable
name
- the name of the function to invokejthis
- the function's 'this' contexttypes
- the type of each argumentargs
- the arguments to be passedThrowable
protected boolean isExceptionSame(Throwable original, Object exception)
original
- the thrown exceptionexception
- the caught exceptionprotected String rebind(String sourceName) throws UnableToCompleteException
UnableToCompleteException
Copyright © 2018. All rights reserved.