My Project
|
Files | |
file | jsni.h |
Classes | |
struct | JSNIDataPropertyDescriptor |
struct | JSNIAccessorPropertyDescriptor |
struct | JSNIPropertyDescriptor |
struct | JSNIErrorInfo |
struct | _JSNIEnv |
JSNI environment structure. More... | |
Macros | |
#define | JSNI_VERSION_1_0 0x00010000 |
JSNI version 1.0. More... | |
#define | JSNI_VERSION_1_1 0x00010001 |
JSNI version 1.1. More... | |
#define | JSNI_VERSION_2_0 0x00020000 |
JSNI version 2.0. More... | |
#define | JSNI_VERSION_2_1 0x00020001 |
JSNI version 2.1. | |
#define | JSNI_VERSION_2_2 0x00020002 |
JSNI version 2.2. | |
#define | JSNI_VERSION_2_3 0x00020003 |
JSNI version 2.3. | |
Typedefs | |
typedef struct _JSValueRef * | JSValueRef |
Reference type. | |
typedef struct _JSNIEnv | JSNIEnv |
JSNI environment. | |
typedef void(* | JSNIGCCallback) (JSNIEnv *, void *) |
GCCallback helper type. | |
typedef struct _JSNICallbackInfo * | JSNICallbackInfo |
Callback helper type. | |
typedef void(* | JSNICallback) (JSNIEnv *, const JSNICallbackInfo) |
Callback helper type. | |
typedef struct _JSGlobalValueRef * | JSGlobalValueRef |
Global reference type. | |
Enumerations | |
enum | JsTypedArrayType { JsArrayTypeNone, JsArrayTypeInt8, JsArrayTypeUint8, JsArrayTypeUint8Clamped, JsArrayTypeInt16, JsArrayTypeUint16, JsArrayTypeInt32, JsArrayTypeUint32, JsArrayTypeFloat32, JsArrayTypeFloat64 } |
The type of a typed JavaScript array. More... | |
enum | JSNIPropertyAttributes { JSNINone = 0, JSNIReadOnly = 1 << 0, JSNIDontEnum = 1 << 1, JSNIDontDelete = 1 << 2 } |
enum | JSNIErrorCode { JSNIOK, JSNIERR } |
Functions | |
int | JSNIGetVersion (JSNIEnv *env) |
Returns the version of the JSNI. More... | |
bool | JSNIRegisterMethod (JSNIEnv *env, const JSValueRef recv, const char *name, JSNICallback callback) |
Registers a native callback function. More... | |
int | JSNIGetArgsLengthOfCallback (JSNIEnv *env, JSNICallbackInfo info) |
Returns the number of arguments for the callback. More... | |
JSValueRef | JSNIGetArgOfCallback (JSNIEnv *env, JSNICallbackInfo info, int id) |
Returns the argument for the callback. More... | |
JSValueRef | JSNIGetThisOfCallback (JSNIEnv *env, JSNICallbackInfo info) |
Returns "this" JavaScript object of the JavaScript function which current callback associated with. More... | |
void * | JSNIGetDataOfCallback (JSNIEnv *env, JSNICallbackInfo info) |
Get the raw data which is passed to this callback. More... | |
void | JSNISetReturnValue (JSNIEnv *env, JSNICallbackInfo info, JSValueRef val) |
Sets the JavaScript return value for the callback. More... | |
bool | JSNIIsUndefined (JSNIEnv *env, JSValueRef val) |
Tests whether the JavaScript value is undefined. More... | |
JSValueRef | JSNINewUndefined (JSNIEnv *env) |
Constructs a new Undefined JavaScript value. More... | |
bool | JSNIIsNull (JSNIEnv *env, JSValueRef val) |
Tests whether the JavaScript value is Null. More... | |
JSValueRef | JSNINewNull (JSNIEnv *env) |
Constructs a new Null JavaScript value. More... | |
bool | JSNIIsBoolean (JSNIEnv *env, JSValueRef val) |
Tests whether the JavaScript value is Boolean. More... | |
bool | JSNIToCBool (JSNIEnv *env, JSValueRef val) |
Converts the JavaScript value to C bool. More... | |
JSValueRef | JSNINewBoolean (JSNIEnv *env, bool val) |
Constructs a new Boolean JavaScript value. More... | |
bool | JSNIIsNumber (JSNIEnv *env, JSValueRef val) |
Tests whether the JavaScript value is Number. More... | |
JSValueRef | JSNINewNumber (JSNIEnv *env, double val) |
Constructs a new Number JavaScript value. More... | |
double | JSNIToCDouble (JSNIEnv *env, JSValueRef val) |
Converts the JavaScript value to C double. More... | |
int32_t | JSNIToInt32 (JSNIEnv *env, JSValueRef val) |
Converts the JavaScript value to int32. More... | |
uint32_t | JSNIToUint32 (JSNIEnv *env, JSValueRef val) |
Converts the JavaScript value to uint32. More... | |
int64_t | JSNIToInt64 (JSNIEnv *env, JSValueRef val) |
Converts the JavaScript value to int64. More... | |
bool | JSNIIsSymbol (JSNIEnv *env, JSValueRef val) |
Tests whether the JavaScript value is Symbol. More... | |
JSValueRef | JSNINewSymbol (JSNIEnv *env, JSValueRef val) |
Constructs a new Symbol JavaScript value. More... | |
bool | JSNIIsString (JSNIEnv *env, JSValueRef val) |
Tests whether the JavaScript value is String. More... | |
JSValueRef | JSNINewStringFromUtf8 (JSNIEnv *env, const char *src, size_t length) |
Constructs a new String value from an array of characters in UTF-8 encoding. More... | |
size_t | JSNIGetStringUtf8Length (JSNIEnv *env, JSValueRef string) |
Returns the length in bytes of the UTF-8 representation of a string. More... | |
size_t | JSNIGetStringUtf8Chars (JSNIEnv *env, JSValueRef string, char *copy, size_t length) |
Copyies a JavaScript string into a UTF-8 encoding string buffer. More... | |
JSValueRef | JSNINewString (JSNIEnv *env, const uint16_t *src, size_t length) |
Constructs a new String value from an array of characters in two bytes. More... | |
size_t | JSNIGetStringLength (JSNIEnv *env, JSValueRef string) |
size_t | JSNIGetString (JSNIEnv *env, JSValueRef string, uint16_t *copy, size_t length) |
bool | JSNIIsObject (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is a JavaScript object. More... | |
bool | JSNIIsEmpty (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is empty. More... | |
JSValueRef | JSNINewObject (JSNIEnv *env) |
Constructs a JavaScript object. More... | |
bool | JSNIHasProperty (JSNIEnv *env, JSValueRef object, const char *name) |
Tests whether a JavaScript object has a property named name. More... | |
JSValueRef | JSNIGetProperty (JSNIEnv *env, JSValueRef object, const char *name) |
Returns the property of the JavaScript object. More... | |
bool | JSNISetProperty (JSNIEnv *env, JSValueRef object, const char *name, JSValueRef property) |
Sets a property of a JavaScript object. More... | |
bool | JSNIDefineProperty (JSNIEnv *env, JSValueRef object, const char *name, const JSNIPropertyDescriptor descriptor) |
Defines a new property directly on an object, or modifies an existing property on an object. More... | |
bool | JSNIDeleteProperty (JSNIEnv *env, JSValueRef object, const char *name) |
Deletes the property of a JavaScript object. More... | |
JSValueRef | JSNIGetPrototype (JSNIEnv *env, JSValueRef object) |
Returns a prototype of a JavaScript object. More... | |
JSValueRef | JSNINewObjectWithInternalField (JSNIEnv *env, int count) |
Constructs a JavaScript object with internal field. Internal field is a raw C pointer which can not be get in JavaScript. More... | |
int | JSNIInternalFieldCount (JSNIEnv *env, JSValueRef object) |
Gets the number of the internal field fo a JavaScript object. More... | |
void | JSNISetInternalField (JSNIEnv *env, JSValueRef object, int index, void *field) |
Sets an internal field of a JavaScript object. More... | |
void * | JSNIGetInternalField (JSNIEnv *env, JSValueRef object, int index) |
Gets an internal field of a JavaScript object. More... | |
bool | JSNIIsFunction (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is Function. More... | |
JSValueRef | JSNINewFunction (JSNIEnv *env, JSNICallback callback) |
Constructs a JavaScript function with callback. More... | |
JSValueRef | JSNICallFunction (JSNIEnv *env, JSValueRef func, JSValueRef recv, int argc, JSValueRef *argv) |
Calls a JavaScript function. More... | |
bool | JSNIIsArray (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is Array. More... | |
size_t | JSNIGetArrayLength (JSNIEnv *env, JSValueRef array) |
Returns the number of elements in the array. More... | |
JSValueRef | JSNINewArray (JSNIEnv *env, size_t initial_length) |
Constructs a JavaScript array with initial length: initial_length. More... | |
JSValueRef | JSNIGetArrayElement (JSNIEnv *env, JSValueRef array, size_t index) |
Returns an element of a JavaScript array. More... | |
void | JSNISetArrayElement (JSNIEnv *env, JSValueRef array, size_t index, JSValueRef value) |
Sets an element of a JavaScript array. More... | |
bool | JSNIIsTypedArray (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is TypedArray. More... | |
JSValueRef | JSNINewTypedArray (JSNIEnv *env, JsTypedArrayType type, void *data, size_t length) |
Constructs a JavaScript TypedArray object. More... | |
JsTypedArrayType | JSNIGetTypedArrayType (JSNIEnv *env, JSValueRef typed_array) |
Returns the type of the JavaScript TypedArray value. More... | |
void * | JSNIGetTypedArrayData (JSNIEnv *env, JSValueRef typed_array) |
Returns the pointer to the buffer of TypedArray data. More... | |
size_t | JSNIGetTypedArrayLength (JSNIEnv *env, JSValueRef typed_array) |
Returns the number of elements in the TypedArray value. More... | |
void | JSNIPushLocalScope (JSNIEnv *env) |
Creates a local reference scope, and then all local references will be allocated within this reference scope until the reference scope is deleted using PoplocalScope() or another local reference scope is created. More... | |
void | JSNIPopLocalScope (JSNIEnv *env) |
Pops off the current local reference scope, frees all the local references in the local reference scope. More... | |
void | JSNIPushEscapableLocalScope (JSNIEnv *env) |
Creates a local reference scope, and then all local references will be allocated within this reference scope until the reference scope is deleted using PopEscapableLocalScope() or another local reference scope is created. More... | |
JSValueRef | JSNIPopEscapableLocalScope (JSNIEnv *env, JSValueRef val) |
Pops off the current local reference scope, frees all the local references in the local reference scope, and returns a local reference in the previous local scope for the given val JavaScript value. More... | |
JSGlobalValueRef | JSNINewGlobalValue (JSNIEnv *env, JSValueRef val) |
Creates a new global reference to the JavaScript value referred to by the val argument. The global value must be explicitly disposed of by calling JSNIDeleteGlobalValue() or JSNIReleaseGlobalValue(). The global value will be alive untile calling JSNIDeleteGlobalValue() or JSNIReleaseGlobalValue() to dispose it. JSNIDeleteGlobalValue() dispose it immediately, whereas JSNIReleaseGlobalValue() dispose it when decrease the reference count to zero. More... | |
void | JSNIDeleteGlobalValue (JSNIEnv *env, JSGlobalValueRef val) |
Deletes the global reference pointed by val. More... | |
size_t | JSNIAcquireGlobalValue (JSNIEnv *env, JSGlobalValueRef val) |
Acquire the val means to increase the reference count of the val. Once the reference count of the val equals to zero, the val is available to be garbage collected. More... | |
size_t | JSNIReleaseGlobalValue (JSNIEnv *env, JSGlobalValueRef val) |
Release the val means to decrease the reference count of the val. Once the reference count of the val equals to zero, the val is available to be garbage collected. More... | |
JSValueRef | JSNIGetGlobalValue (JSNIEnv *env, JSGlobalValueRef val) |
Returns a local JSValueRef value from a JSGlobalValueRef value. More... | |
void | JSNISetGCCallback (JSNIEnv *env, JSGlobalValueRef val, void *args, JSNIGCCallback callback) |
Sets a callback which will be called when the JavaScript value pointed by val is freed. The developer can pass an argument to callback by args. JSNISetGCCallback() is only valid when reference count is bigger than zero. More... | |
void | JSNIThrowErrorException (JSNIEnv *env, const char *errmsg) |
Constructs an error object with the message specified by errmsg and causes that error to be thrown. It throws a JavaScript Exception. More... | |
void | JSNIThrowTypeErrorException (JSNIEnv *env, const char *errmsg) |
Constructs an type error object with the message specified by errmsg and causes that type error to be thrown. It throws a JavaScript Exception. More... | |
void | JSNIThrowRangeErrorException (JSNIEnv *env, const char *errmsg) |
Constructs an range error object with the message specified by errmsg and causes that type error to be thrown. It throws a JavaScript Exception. More... | |
JSNIErrorInfo | JSNIGetLastErrorInfo (JSNIEnv *env) |
Tests whether there is error occured during pervious JSNI call. After calling JSNIGetLastErrorInfo(), if there is error occured, the error will be cleared. More... | |
bool | JSNIHasException (JSNIEnv *env) |
Tests whether a JavaScript exception is being thrown. It's different with error get from JSNIGetLastErrorInfo. Eorror is defined by JSNI, whereas this is a JavaScript exception. More... | |
void | JSNIClearException (JSNIEnv *env) |
Clear a JavaScript exception that is being thrown. If there is no exception, this routine has no effect. More... | |
JSValueRef | JSNINewError (JSNIEnv *env, const char *errmsg) |
Constructs a JavaScript Error object. More... | |
JSValueRef | JSNINewTypeError (JSNIEnv *env, const char *errmsg) |
Constructs a JavaScript TypeError object. More... | |
JSValueRef | JSNINewRangeError (JSNIEnv *env, const char *errmsg) |
Constructs a JavaScript RangeError object. More... | |
void | JSNIThrowErrorObject (JSNIEnv *env, JSValueRef error) |
Throw JavaScript Error object. More... | |
bool | JSNIIsError (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is Error object. More... | |
JSValueRef | JSNINewInstance (JSNIEnv *env, JSValueRef constructor, int argc, JSValueRef *argv) |
New an instance from a constructor. More... | |
bool | JSNIInstanceOf (JSNIEnv *env, JSValueRef left, JSValueRef right) |
Tests whether left object is an instance of right object. More... | |
JSValueRef | JSNIGetNewTarget (JSNIEnv *env, JSNICallbackInfo info) |
Gets the new.target value of the call. More... | |
bool | JSNIStrictEquals (JSNIEnv *env, JSValueRef left, JSValueRef right) |
Tests whether the left JavaScript value is strict-equal to the right JavaScript value. More... | |
JSValueRef | JSNINewArrayBuffer (JSNIEnv *env, size_t length) |
Constructs a JavaScript ArrayBuffer. More... | |
JSValueRef | JSNINewArrayBufferExternalized (JSNIEnv *env, void *data, size_t length) |
Constructs a JavaScirpt ArrayBuffer with the externalized data. More... | |
bool | JSNIIsArrayBuffer (JSNIEnv *env, JSValueRef val) |
Tests whether a JavaScript value is ArrayBuffer. More... | |
void * | JSNIGetArrayBufferData (JSNIEnv *env, JSValueRef val) |
Gets the pointer to the buffer of ArrayBuffer data. More... | |
size_t | JSNIGetArrayBufferLength (JSNIEnv *env, JSValueRef val) |
Gets the length of ArrayBuffer. More... | |
JSValueRef | JSNIGetPropertyNames (JSNIEnv *env, JSValueRef val) |
Gets the names of the properties of the object. More... | |
int | JSNIInit (JSNIEnv *env, JSValueRef exports) |
This function is called by JSNI, not part of JSNI. | |
#define JSNI_VERSION_1_0 0x00010000 |
JSNI version 1.0.
#define JSNI_VERSION_1_1 0x00010001 |
JSNI version 1.1.
#define JSNI_VERSION_2_0 0x00020000 |
JSNI version 2.0.
2.0 is not compatibale with 1.1. Since 2.0, we should be compatible with old versions.
enum JSNIErrorCode |
enum JsTypedArrayType |
The type of a typed JavaScript array.
size_t JSNIAcquireGlobalValue | ( | JSNIEnv * | env, |
JSGlobalValueRef | val | ||
) |
Acquire the val means to increase the reference count of the val. Once the reference count of the val equals to zero, the val is available to be garbage collected.
env | The JSNI environment pointer. |
val | A JSGlobalValueRef value. |
JSValueRef JSNICallFunction | ( | JSNIEnv * | env, |
JSValueRef | func, | ||
JSValueRef | recv, | ||
int | argc, | ||
JSValueRef * | argv | ||
) |
Calls a JavaScript function.
env | The JSNI environment pointer. |
func | A JavaScript funciton. |
recv | The receiver the func belongs to. |
argc | The arguments number. |
argv | A pointer to an array of JavaScript value. |
void JSNIClearException | ( | JSNIEnv * | env | ) |
Clear a JavaScript exception that is being thrown. If there is no exception, this routine has no effect.
env | The JSNI environment pointer. |
bool JSNIDefineProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name, | ||
const JSNIPropertyDescriptor | descriptor | ||
) |
Defines a new property directly on an object, or modifies an existing property on an object.
env | The JSNI environment pointer. |
object | The object on which to define the property. |
name | The name of the property to be defined or modified. |
descriptor | The descriptor for the property being defined or modified. |
void JSNIDeleteGlobalValue | ( | JSNIEnv * | env, |
JSGlobalValueRef | val | ||
) |
Deletes the global reference pointed by val.
env | The JSNI environment pointer. |
val | A JSGlobalValueRef value. |
bool JSNIDeleteProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name | ||
) |
Deletes the property of a JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
name | A property name. |
JSValueRef JSNIGetArgOfCallback | ( | JSNIEnv * | env, |
JSNICallbackInfo | info, | ||
int | id | ||
) |
Returns the argument for the callback.
env | The JSNI environment pointer. |
info | The callback info. |
id | The index of arguments. |
int JSNIGetArgsLengthOfCallback | ( | JSNIEnv * | env, |
JSNICallbackInfo | info | ||
) |
Returns the number of arguments for the callback.
env | The JSNI environment pointer. |
info | The callback info. |
void* JSNIGetArrayBufferData | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Gets the pointer to the buffer of ArrayBuffer data.
env | The JSNI environment pointer. |
val | A JavaScript ArrayBuffer. |
size_t JSNIGetArrayBufferLength | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Gets the length of ArrayBuffer.
env | The JSNI environment pointer. |
val | A JavaScript ArrayBuffer. |
JSValueRef JSNIGetArrayElement | ( | JSNIEnv * | env, |
JSValueRef | array, | ||
size_t | index | ||
) |
Returns an element of a JavaScript array.
env | The JSNI environment pointer. |
array | A JavaScript array. |
index | Array index. |
size_t JSNIGetArrayLength | ( | JSNIEnv * | env, |
JSValueRef | array | ||
) |
Returns the number of elements in the array.
env | The JSNI environment pointer. |
array | A JavaScript array. |
void* JSNIGetDataOfCallback | ( | JSNIEnv * | env, |
JSNICallbackInfo | info | ||
) |
Get the raw data which is passed to this callback.
env | The JSNI environment pointer. |
info | The callback info. |
JSValueRef JSNIGetGlobalValue | ( | JSNIEnv * | env, |
JSGlobalValueRef | val | ||
) |
Returns a local JSValueRef value from a JSGlobalValueRef value.
env | The JSNI environment pointer. |
val | A JSGlobalValueRef value. |
void* JSNIGetInternalField | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
int | index | ||
) |
Gets an internal field of a JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
index | Index of an internal field. |
JSNIErrorInfo JSNIGetLastErrorInfo | ( | JSNIEnv * | env | ) |
Tests whether there is error occured during pervious JSNI call. After calling JSNIGetLastErrorInfo(), if there is error occured, the error will be cleared.
env | The JSNI environment pointer. |
JSValueRef JSNIGetNewTarget | ( | JSNIEnv * | env, |
JSNICallbackInfo | info | ||
) |
Gets the new.target value of the call.
env | The JSNI environment pointer. |
info | The callback info. |
JSValueRef JSNIGetProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name | ||
) |
Returns the property of the JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
name | A property name. |
JSValueRef JSNIGetPropertyNames | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Gets the names of the properties of the object.
env | The JSNI environment pointer. |
val | The JavaScript object to get properties names from. |
JSValueRef JSNIGetPrototype | ( | JSNIEnv * | env, |
JSValueRef | object | ||
) |
Returns a prototype of a JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
size_t JSNIGetStringUtf8Chars | ( | JSNIEnv * | env, |
JSValueRef | string, | ||
char * | copy, | ||
size_t | length | ||
) |
Copyies a JavaScript string into a UTF-8 encoding string buffer.
env | The JSNI environment pointer. |
string | A JavaScript string value. |
copy | The buffer copied to. |
length | The length copied to copy. It should be greater than the length of the string considering for string null terminator. If length equals -1, it will use the length of string. |
size_t JSNIGetStringUtf8Length | ( | JSNIEnv * | env, |
JSValueRef | string | ||
) |
Returns the length in bytes of the UTF-8 representation of a string.
Returns the number of charaters in this string.
env | The JSNI environment pointer. |
string | A JavaScript string value. |
env | The JSNI environment pointer. |
string | A JavaScript string value. |
JSValueRef JSNIGetThisOfCallback | ( | JSNIEnv * | env, |
JSNICallbackInfo | info | ||
) |
Returns "this" JavaScript object of the JavaScript function which current callback associated with.
env | The JSNI environment pointer. |
info | The callback info. |
void* JSNIGetTypedArrayData | ( | JSNIEnv * | env, |
JSValueRef | typed_array | ||
) |
Returns the pointer to the buffer of TypedArray data.
env | The JSNI environment pointer. |
typed_array | A JavaScript TypedArray value. |
size_t JSNIGetTypedArrayLength | ( | JSNIEnv * | env, |
JSValueRef | typed_array | ||
) |
Returns the number of elements in the TypedArray value.
env | The JSNI environment pointer. |
typed_array | A JavaScript TypedArray value. |
JsTypedArrayType JSNIGetTypedArrayType | ( | JSNIEnv * | env, |
JSValueRef | typed_array | ||
) |
Returns the type of the JavaScript TypedArray value.
env | The JSNI environment pointer. |
typed_array | A JavaScript TypedArray value. |
int JSNIGetVersion | ( | JSNIEnv * | env | ) |
Returns the version of the JSNI.
JSNI functions.
env | The JSNI environment pointer. |
bool JSNIHasException | ( | JSNIEnv * | env | ) |
Tests whether a JavaScript exception is being thrown. It's different with error get from JSNIGetLastErrorInfo. Eorror is defined by JSNI, whereas this is a JavaScript exception.
env | The JSNI environment pointer. |
bool JSNIHasProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name | ||
) |
Tests whether a JavaScript object has a property named name.
env | The JSNI environment pointer. |
object | A JavaScript object. |
name | A property name. |
bool JSNIInstanceOf | ( | JSNIEnv * | env, |
JSValueRef | left, | ||
JSValueRef | right | ||
) |
Tests whether left object is an instance of right object.
env | The JSNI environment pointer. |
left | A JavaScript value to test. |
right | A JavaScript value which represents a function constructor. |
int JSNIInternalFieldCount | ( | JSNIEnv * | env, |
JSValueRef | object | ||
) |
Gets the number of the internal field fo a JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
bool JSNIIsArray | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is Array.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsArrayBuffer | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is ArrayBuffer.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsBoolean | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Boolean.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsEmpty | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is empty.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsError | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is Error object.
env | The JSNI environment pointer. |
val | A JavaScript Value. |
bool JSNIIsFunction | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is Function.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsNull | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Null.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsNumber | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Number.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsObject | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is a JavaScript object.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsString | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is String.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsSymbol | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Symbol.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsTypedArray | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is TypedArray.
env | The JSNI environment pointer. |
val | A JavaScript value. |
bool JSNIIsUndefined | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is undefined.
env | The JSNI environment pointer. |
val | A JavaScript value. |
JSValueRef JSNINewArray | ( | JSNIEnv * | env, |
size_t | initial_length | ||
) |
Constructs a JavaScript array with initial length: initial_length.
env | The JSNI environment pointer. |
initial_length | Initial array size. |
JSValueRef JSNINewArrayBuffer | ( | JSNIEnv * | env, |
size_t | length | ||
) |
Constructs a JavaScript ArrayBuffer.
env | The JSNI environment pointer. |
length | The ArrayBuffer length. |
JSValueRef JSNINewArrayBufferExternalized | ( | JSNIEnv * | env, |
void * | data, | ||
size_t | length | ||
) |
Constructs a JavaScirpt ArrayBuffer with the externalized data.
env | The JSNI environment pointer. |
data | The externalized data. |
length | The ArrayBuffer length. |
JSValueRef JSNINewBoolean | ( | JSNIEnv * | env, |
bool | val | ||
) |
Constructs a new Boolean JavaScript value.
env | The JSNI environment pointer. |
val | A bool value. |
JSValueRef JSNINewError | ( | JSNIEnv * | env, |
const char * | errmsg | ||
) |
Constructs a JavaScript Error object.
env | The JSNI environment pointer. |
errmsg | An error message. |
JSValueRef JSNINewFunction | ( | JSNIEnv * | env, |
JSNICallback | nativeFunc | ||
) |
Constructs a JavaScript function with callback.
env | The JSNI environment pointer. |
callback | A native callback function. |
JSGlobalValueRef JSNINewGlobalValue | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Creates a new global reference to the JavaScript value referred to by the val argument. The global value must be explicitly disposed of by calling JSNIDeleteGlobalValue() or JSNIReleaseGlobalValue(). The global value will be alive untile calling JSNIDeleteGlobalValue() or JSNIReleaseGlobalValue() to dispose it. JSNIDeleteGlobalValue() dispose it immediately, whereas JSNIReleaseGlobalValue() dispose it when decrease the reference count to zero.
env | The JSNI environment pointer. |
val | A JavaScript value. |
JSValueRef JSNINewInstance | ( | JSNIEnv * | env, |
JSValueRef | constructor, | ||
int | argc, | ||
JSValueRef * | argv | ||
) |
New an instance from a constructor.
env | The JSNI environment pointer. |
constructor | The JavaScript function to be invoked as a constructor. |
argc | The argument number to be passed to constructor. |
argv | The argument array pointer to be passed to constructor. |
JSValueRef JSNINewNull | ( | JSNIEnv * | env | ) |
Constructs a new Null JavaScript value.
env | The JSNI environment pointer. |
JSValueRef JSNINewNumber | ( | JSNIEnv * | env, |
double | val | ||
) |
Constructs a new Number JavaScript value.
env | The JSNI environment pointer. |
val | A double value. |
JSValueRef JSNINewObject | ( | JSNIEnv * | env | ) |
Constructs a JavaScript object.
env | The JSNI environment pointer. |
JSValueRef JSNINewObjectWithInternalField | ( | JSNIEnv * | env, |
int | count | ||
) |
Constructs a JavaScript object with internal field. Internal field is a raw C pointer which can not be get in JavaScript.
env | The JSNI environment pointer. |
count | A number of internal fields. |
JSValueRef JSNINewRangeError | ( | JSNIEnv * | env, |
const char * | errmsg | ||
) |
Constructs a JavaScript RangeError object.
env | The JSNI environment pointer. |
errmsg | An error message. |
JSValueRef JSNINewString | ( | JSNIEnv * | env, |
const uint16_t * | src, | ||
size_t | length | ||
) |
Constructs a new String value from an array of characters in two bytes.
env | The JSNI environment pointer. |
src | The pointer to a two bytes string. |
length | The length of string to be created. It should exclude the null terminator. If length equals -1, it will use the length of src. |
JSValueRef JSNINewStringFromUtf8 | ( | JSNIEnv * | env, |
const char * | src, | ||
size_t | length | ||
) |
Constructs a new String value from an array of characters in UTF-8 encoding.
env | The JSNI environment pointer. |
src | The pointer to a UTF-8 string. |
length | The length of string to be created. It should exclude the null terminator. If length equals -1, it will use the length of src. |
JSValueRef JSNINewSymbol | ( | JSNIEnv * | env, |
JSValueRef | name | ||
) |
Constructs a new Symbol JavaScript value.
env | The JSNI environment pointer. |
val | The description of the symbol. |
JSValueRef JSNINewTypedArray | ( | JSNIEnv * | env, |
JsTypedArrayType | type, | ||
void * | data, | ||
size_t | length | ||
) |
Constructs a JavaScript TypedArray object.
env | The JSNI environment pointer. |
type | The type of the array. |
data | The pointer to the data buffer of the array. |
length | The length of the array. |
JSValueRef JSNINewTypeError | ( | JSNIEnv * | env, |
const char * | errmsg | ||
) |
Constructs a JavaScript TypeError object.
env | The JSNI environment pointer. |
errmsg | An error message. |
JSValueRef JSNINewUndefined | ( | JSNIEnv * | env | ) |
Constructs a new Undefined JavaScript value.
env | The JSNI environment pointer. |
JSValueRef JSNIPopEscapableLocalScope | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Pops off the current local reference scope, frees all the local references in the local reference scope, and returns a local reference in the previous local scope for the given val JavaScript value.
env | The JSNI environment pointer. |
val | A JavaScript value. |
void JSNIPopLocalScope | ( | JSNIEnv * | env | ) |
Pops off the current local reference scope, frees all the local references in the local reference scope.
env | The JSNI environment pointer. |
void JSNIPushEscapableLocalScope | ( | JSNIEnv * | env | ) |
Creates a local reference scope, and then all local references will be allocated within this reference scope until the reference scope is deleted using PopEscapableLocalScope() or another local reference scope is created.
env | The JSNI environment pointer. |
void JSNIPushLocalScope | ( | JSNIEnv * | env | ) |
Creates a local reference scope, and then all local references will be allocated within this reference scope until the reference scope is deleted using PoplocalScope() or another local reference scope is created.
env | The JSNI environment pointer. |
bool JSNIRegisterMethod | ( | JSNIEnv * | env, |
JSValueRef | recv, | ||
const char * | name, | ||
JSNICallback | callback | ||
) |
Registers a native callback function.
env | The JSNI environment pointer. registered JS function associated with the callback. |
recv | The method receiver. It is passed through JSNIInit to receive the |
name | A function name. |
callback | A native callback function to be registered. |
size_t JSNIReleaseGlobalValue | ( | JSNIEnv * | env, |
JSGlobalValueRef | val | ||
) |
Release the val means to decrease the reference count of the val. Once the reference count of the val equals to zero, the val is available to be garbage collected.
env | The JSNI environment pointer. |
val | A JSGlobalValueRef value. |
void JSNISetArrayElement | ( | JSNIEnv * | env, |
JSValueRef | array, | ||
size_t | index, | ||
JSValueRef | value | ||
) |
Sets an element of a JavaScript array.
env | The JSNI environment pointer. |
array | A JavaScript array. |
index | A array index. |
value | A new value. |
void JSNISetGCCallback | ( | JSNIEnv * | env, |
JSGlobalValueRef | global, | ||
void * | args, | ||
JSNIGCCallback | callback | ||
) |
Sets a callback which will be called when the JavaScript value pointed by val is freed. The developer can pass an argument to callback by args. JSNISetGCCallback() is only valid when reference count is bigger than zero.
env | The JSNI environment pointer. |
val | A JSGlobalValueRef value. |
args | A pointer to an argument passed to callback. |
callback | A function callback. |
void JSNISetInternalField | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
int | index, | ||
void * | field | ||
) |
Sets an internal field of a JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
index | Index of an internal field. and it will not be freed when object is Garbage Collected. |
field | An internal field. This is a raw C pointer, |
bool JSNISetProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name, | ||
JSValueRef | property | ||
) |
Sets a property of a JavaScript object.
env | The JSNI environment pointer. |
object | A JavaScript object. |
name | A property name. |
property | A JavaScript value. |
void JSNISetReturnValue | ( | JSNIEnv * | env, |
JSNICallbackInfo | info, | ||
JSValueRef | val | ||
) |
Sets the JavaScript return value for the callback.
env | The JSNI environment pointer. |
info | The callback info. |
val | The JavaScript value to return to JavaScript. |
bool JSNIStrictEquals | ( | JSNIEnv * | env, |
JSValueRef | left, | ||
JSValueRef | right | ||
) |
Tests whether the left JavaScript value is strict-equal to the right JavaScript value.
env | The JSNI environment pointer. |
left | The left JavaScript value. |
right | The right JavaScript value. |
void JSNIThrowErrorException | ( | JSNIEnv * | env, |
const char * | errmsg | ||
) |
Constructs an error object with the message specified by errmsg and causes that error to be thrown. It throws a JavaScript Exception.
env | The JSNI environment pointer. |
errmsg | An error message. |
void JSNIThrowErrorObject | ( | JSNIEnv * | env, |
JSValueRef | error | ||
) |
Throw JavaScript Error object.
env | The JSNI environment pointer. |
error | JavaScript Error Object. |
void JSNIThrowRangeErrorException | ( | JSNIEnv * | env, |
const char * | errmsg | ||
) |
Constructs an range error object with the message specified by errmsg and causes that type error to be thrown. It throws a JavaScript Exception.
env | The JSNI environment pointer. |
errmsg | An error message. |
void JSNIThrowTypeErrorException | ( | JSNIEnv * | env, |
const char * | errmsg | ||
) |
Constructs an type error object with the message specified by errmsg and causes that type error to be thrown. It throws a JavaScript Exception.
env | The JSNI environment pointer. |
errmsg | An error message. |
bool JSNIToCBool | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to C bool.
env | The JSNI environment pointer. |
val | A JavaScript value. |
double JSNIToCDouble | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to C double.
env | The JSNI environment pointer. |
val | A JavaScript value. |
int32_t JSNIToInt32 | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to int32.
env | The JSNI environment pointer. |
val | A JavaScript value. |
int64_t JSNIToInt64 | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to int64.
env | The JSNI environment pointer. |
val | A JavaScript value. |
uint32_t JSNIToUint32 | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to uint32.
env | The JSNI environment pointer. |
val | A JavaScript value. |