public class V8ValueFunction extends V8ValueObject implements IV8ValueFunction
IV8ValueFunction.GetScopeInfosOptions, IV8ValueFunction.ScopeInfo, IV8ValueFunction.ScopeInfos, IV8ValueFunction.ScriptSource, IV8ValueFunction.SetSourceCodeOptions
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ERROR_THE_SOURCE_FUNCTION_CANNOT_BE_IN_ANOTHER_V8_RUNTIME
The constant ERROR_THE_SOURCE_FUNCTION_CANNOT_BE_IN_ANOTHER_V8_RUNTIME.
|
protected static java.lang.String |
ERROR_THE_SOURCE_FUNCTION_CANNOT_BE_THE_CALLER
The constant ERROR_THE_SOURCE_FUNCTION_CANNOT_BE_THE_CALLER.
|
protected static java.lang.String |
ERROR_V8_CONTEXT_CANNOT_BE_NULL
The constant ERROR_V8_CONTEXT_CANNOT_BE_NULL.
|
protected JSFunctionType |
jsFunctionType
The JS function type.
|
ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH, FUNCTION_ADD, FUNCTION_DELETE, FUNCTION_GET, FUNCTION_HAS, FUNCTION_SET, METHOD_PREFIX_GET, METHOD_PREFIX_IS, METHOD_PREFIX_SET, PROPERTY_PROTOTYPE
handle, INVALID_HANDLE, weak
OBJECT_CONVERTER, v8Runtime
DEFAULT_BATCH_SIZE, MIN_BATCH_SIZE
Modifier | Constructor and Description |
---|---|
protected |
V8ValueFunction(V8Runtime v8Runtime,
long handle)
Instantiates a new V8 value function.
|
Modifier and Type | Method and Description |
---|---|
<T extends V8Value> |
callAsConstructor(java.lang.Object... objects)
Call a function as constructor by objects.
|
<T extends V8Value> |
callAsConstructor(V8Value... v8Values)
Call a function as constructor by V8 values.
|
<T extends V8Value> |
callExtended(V8Value receiver,
boolean returnResult,
java.lang.Object... objects)
Call a function by objects and return V8 value.
|
<T extends V8Value> |
callExtended(V8Value receiver,
boolean returnResult,
V8Value... v8Values)
Call a function by V8 values and return V8 value.
|
boolean |
canDiscardCompiled()
Can discard compiled byte code.
|
boolean |
copyScopeInfoFrom(IV8ValueFunction sourceIV8ValueFunction)
Copy the scope info from the source V8 value function.
|
boolean |
discardCompiled()
Discard compiled byte code.
|
java.lang.String[] |
getArguments()
Gets arguments.
|
byte[] |
getCachedData()
Gets cached data.
|
V8Context |
getContext()
Gets the V8 context.
|
IV8ValueArray |
getInternalProperties()
Gets internal properties.
|
JSFunctionType |
getJSFunctionType()
Gets JS function type.
|
JSScopeType |
getJSScopeType()
Gets JS scope type.
|
IV8ValueFunction.ScopeInfos |
getScopeInfos(IV8ValueFunction.GetScopeInfosOptions options)
Gets scope infos.
|
IV8ValueFunction.ScriptSource |
getScriptSource()
Gets script source.
|
java.lang.String |
getSourceCode()
Gets source code.
|
V8ValueReferenceType |
getType() |
boolean |
isCompiled()
Is this function compiled.
|
boolean |
isWrapped()
Is wrapped function.
|
boolean |
setContext(V8Context v8Context)
Sets the V8 context.
|
boolean |
setScriptSource(IV8ValueFunction.ScriptSource scriptSource,
boolean cloneScript)
Sets script source.
|
boolean |
setSourceCode(java.lang.String sourceCodeString,
IV8ValueFunction.SetSourceCodeOptions options)
Sets source code with options.
|
batchGet, bind, bindFunction, bindProperty, delete, deletePrivateProperty, forEach, forEach, get, getBoolean, getDouble, getIdentityHash, getInteger, getLong, getOwnPropertyNames, getPrivateProperty, getProperty, getPropertyNames, getPrototype, getString, has, hasInternalType, hasOwnProperty, hasPrivateProperty, invokeExtended, invokeExtended, sameValue, set, set, setBoolean, setDouble, setInteger, setLong, setNull, setPrivateProperty, setProperty, setPrototype, setString, setUndefined, strictEquals, toJsonString, toProtoString, unbind, unbindFunction, unbindProperty, unbindProperty, unbindProperty, unbindProperty
addReference, checkV8Runtime, clearWeak, close, close, equals, getHandle, isClosed, isWeak, isWeak, removeReference, setWeak, toClone, toString
getV8Runtime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
call, call, callBigInteger, callBoolean, callDouble, callFloat, callInteger, callLong, callObject, callString, callVoid, callVoid, callZonedDateTime, copyContextFrom, getScopeInfos, isAsyncFunction, isGeneratorFunction, setScriptSource, setSourceCode
batchGet, bind, bindFunction, bindFunction, bindFunction, bindProperty, bindProperty, delete, deleteNull, deletePrivateProperty, deleteUndefined, forEach, forEach, forEach, forEach, forEach, forEach, forEach, forEach, get, getBigInteger, getBoolean, getDouble, getFloat, getIdentityHash, getInteger, getLong, getNull, getObject, getOwnPropertyNames, getOwnPropertyNameStrings, getPrivateProperty, getPrivatePropertyBoolean, getPrivatePropertyDouble, getPrivatePropertyFloat, getPrivatePropertyInteger, getPrivatePropertyLong, getPrivatePropertyNull, getPrivatePropertyObject, getPrivatePropertyPrimitive, getPrivatePropertyString, getPrivatePropertyUndefined, getPrivatePropertyZonedDateTime, getProperty, getPropertyBoolean, getPropertyDouble, getPropertyFloat, getPropertyInteger, getPropertyLong, getPropertyNames, getPropertyObject, getPropertyPrimitive, getPropertyString, getPropertyZonedDateTime, getPrototype, getString, getUndefined, getZonedDateTime, has, hasInternalType, hasNull, hasOwnProperty, hasPrivateProperty, hasUndefined, invoke, invoke, invokeBigInteger, invokeBoolean, invokeDouble, invokeExtended, invokeExtended, invokeFloat, invokeInteger, invokeLong, invokeObject, invokeString, invokeVoid, invokeVoid, invokeZonedDateTime, isGeneratorObject, set, set, setBoolean, setDouble, setInteger, setLong, setNull, setPrivateProperty, setPrivatePropertyNull, setPrivatePropertyUndefined, setProperty, setPropertyNull, setPropertyUndefined, setPrototype, setString, setUndefined, toJsonString, toProtoString, unbind, unbindFunction, unbindFunction, unbindFunction, unbindProperty, unbindProperty, unbindProperty, unbindProperty
clearWeak, close, getHandle, isClosed, isWeak, isWeak, setWeak
asBoolean, asDouble, asInt, asLong, asString, equals, getV8Runtime, isNull, isNullOrUndefined, isUndefined, sameValue, strictEquals
close
toClone, toClone
protected static final java.lang.String ERROR_THE_SOURCE_FUNCTION_CANNOT_BE_IN_ANOTHER_V8_RUNTIME
protected static final java.lang.String ERROR_THE_SOURCE_FUNCTION_CANNOT_BE_THE_CALLER
protected static final java.lang.String ERROR_V8_CONTEXT_CANNOT_BE_NULL
protected JSFunctionType jsFunctionType
protected V8ValueFunction(V8Runtime v8Runtime, long handle) throws JavetException
v8Runtime
- the V8 runtimehandle
- the handleJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T callAsConstructor(java.lang.Object... objects) throws JavetException
IV8ValueFunction
callAsConstructor
in interface IV8ValueFunction
T
- the type parameterobjects
- the objectsJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T callAsConstructor(V8Value... v8Values) throws JavetException
IV8ValueFunction
callAsConstructor
in interface IV8ValueFunction
T
- the type parameterv8Values
- the V8 valuesJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T callExtended(V8Value receiver, boolean returnResult, java.lang.Object... objects) throws JavetException
IV8ValueFunction
callExtended
in interface IV8ValueFunction
T
- the type parameterreceiver
- the receiverreturnResult
- the return resultobjects
- the objectsJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T callExtended(V8Value receiver, boolean returnResult, V8Value... v8Values) throws JavetException
IV8ValueFunction
callExtended
in interface IV8ValueFunction
T
- the type parameterreceiver
- the receiverreturnResult
- the return resultv8Values
- the V8 valuesJavetException
- the javet exceptionpublic boolean canDiscardCompiled() throws JavetException
IV8ValueFunction
canDiscardCompiled
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic boolean copyScopeInfoFrom(IV8ValueFunction sourceIV8ValueFunction) throws JavetException
IV8ValueFunction
This allows changing the existing function scope info on the fly. It is similar to the live edit in a JavaScript debug tool.
copyScopeInfoFrom
in interface IV8ValueFunction
sourceIV8ValueFunction
- the source V8 value functionJavetException
- the javet exceptionpublic boolean discardCompiled() throws JavetException
IV8ValueFunction
discardCompiled
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic java.lang.String[] getArguments() throws JavetException
IV8ValueFunction
getArguments
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic byte[] getCachedData() throws JavetException
IV8Cacheable
getCachedData
in interface IV8Cacheable
JavetException
- the javet exceptionpublic V8Context getContext() throws JavetException
IV8ValueFunction
getContext
in interface IV8ValueFunction
JavetException
- the javet exception@CheckReturnValue public IV8ValueArray getInternalProperties() throws JavetException
IV8ValueFunction
getInternalProperties
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic JSFunctionType getJSFunctionType() throws JavetException
IV8ValueFunction
getJSFunctionType
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic JSScopeType getJSScopeType() throws JavetException
IV8ValueFunction
getJSScopeType
in interface IV8ValueFunction
JavetException
- the javet exception@CheckReturnValue public IV8ValueFunction.ScopeInfos getScopeInfos(IV8ValueFunction.GetScopeInfosOptions options) throws JavetException
IV8ValueFunction
getScopeInfos
in interface IV8ValueFunction
options
- the optionsJavetException
- the javet exceptionpublic IV8ValueFunction.ScriptSource getScriptSource() throws JavetException
IV8ValueFunction
A user-defined JavaScript function is part of a script from start position to end position. This method returns the source code of the whole script with the start position and end position. If it is not a user-defined JavaScript function, the return value is null.
getScriptSource
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic java.lang.String getSourceCode() throws JavetException
IV8ValueFunction
getSourceCode
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic V8ValueReferenceType getType()
getType
in interface IV8ValueReference
getType
in class V8ValueObject
public boolean isCompiled() throws JavetException
IV8ValueFunction
isCompiled
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic boolean isWrapped() throws JavetException
IV8ValueFunction
Wrapped function means the source code is wrapped in the function.
isWrapped
in interface IV8ValueFunction
JavetException
- the javet exceptionpublic boolean setContext(V8Context v8Context) throws JavetException
IV8ValueFunction
setContext
in interface IV8ValueFunction
v8Context
- the V8 contextJavetException
- the javet exceptionpublic boolean setScriptSource(IV8ValueFunction.ScriptSource scriptSource, boolean cloneScript) throws JavetException
IV8ValueFunction
setScriptSource
in interface IV8ValueFunction
scriptSource
- the script sourcecloneScript
- the clone scriptJavetException
- the javet exceptionpublic boolean setSourceCode(java.lang.String sourceCodeString, IV8ValueFunction.SetSourceCodeOptions options) throws JavetException
IV8ValueFunction
Note 1: The source code is shared among all function objects. So the caller is responsible for restoring the original source code, otherwise the next function call will likely fail because the source code of the next function call is incorrect. Note 2: The source code must be verified by compile(). Malformed source code will crash V8. Note 3: Sometimes the source code must not end with any of ' ', ';', '\n', though technically the source code is valid. Otherwise, V8 will crash.
setSourceCode
in interface IV8ValueFunction
sourceCodeString
- the source code stringoptions
- the optionsJavetException
- the javet exception