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. | |
Typedefs | |
typedef struct _JSValueRef * | JSValueRef |
Reference type. | |
typedef struct _JSNIEnv | JSNIEnv |
JSNI enviroment. | |
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... | |
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 enviroment pointer. |
val | A JSGlobalValueRef value. |
JSValueRef JSNICallFunction | ( | JSNIEnv * | env, |
JSValueRef | func, | ||
JSValueRef | recv, | ||
int | argc, | ||
JSValueRef * | argv | ||
) |
Calls a JavaScript function.
env | The JSNI enviroment 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 enviroment 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 enviroment 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 enviroment pointer. |
val | A JSGlobalValueRef value. |
bool JSNIDeleteProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name | ||
) |
Deletes the property of a JavaScript object.
env | The JSNI enviroment 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 enviroment 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 enviroment pointer. |
info | The callback info. |
JSValueRef JSNIGetArrayElement | ( | JSNIEnv * | env, |
JSValueRef | array, | ||
size_t | index | ||
) |
Returns an element of a JavaScript array.
env | The JSNI enviroment 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 enviroment pointer. |
array | A JavaScript array. |
void * JSNIGetDataOfCallback | ( | JSNIEnv * | env, |
JSNICallbackInfo | info | ||
) |
Get the raw data which is passed to this callback.
env | The JSNI enviroment pointer. |
info | The callback info. |
JSValueRef JSNIGetGlobalValue | ( | JSNIEnv * | env, |
JSGlobalValueRef | val | ||
) |
Returns a local JSValueRef value from a JSGlobalValueRef value.
env | The JSNI enviroment pointer. |
val | A JSGlobalValueRef value. |
void * JSNIGetInternalField | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
int | index | ||
) |
Gets an internal field of a JavaScript object.
env | The JSNI enviroment 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 enviroment pointer. |
JSValueRef JSNIGetProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name | ||
) |
Returns the property of the JavaScript object.
env | The JSNI enviroment pointer. |
object | A JavaScript object. |
name | A property name. |
JSValueRef JSNIGetPrototype | ( | JSNIEnv * | env, |
JSValueRef | object | ||
) |
Returns a prototype of a JavaScript object.
env | The JSNI enviroment 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 enviroment 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 enviroment pointer. |
string | A JavaScript string value. |
env | The JSNI enviroment 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 enviroment pointer. |
info | The callback info. |
void * JSNIGetTypedArrayData | ( | JSNIEnv * | env, |
JSValueRef | typed_array | ||
) |
Returns the pointer to the buffer of TypedArray data.
env | The JSNI enviroment 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 enviroment 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 enviroment pointer. |
typed_array | A JavaScript TypedArray value. |
int JSNIGetVersion | ( | JSNIEnv * | env | ) |
Returns the version of the JSNI.
JSNI functions.
env | The JSNI enviroment 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 enviroment pointer. |
bool JSNIHasProperty | ( | JSNIEnv * | env, |
JSValueRef | object, | ||
const char * | name | ||
) |
Tests whether a JavaScript object has a property named name.
env | The JSNI enviroment pointer. |
object | A JavaScript object. |
name | A property name. |
int JSNIInternalFieldCount | ( | JSNIEnv * | env, |
JSValueRef | object | ||
) |
Gets the number of the internal field fo a JavaScript object.
env | The JSNI enviroment pointer. |
object | A JavaScript object. |
bool JSNIIsArray | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is Array.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsBoolean | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Boolean.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsEmpty | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is empty.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsFunction | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is Function.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsNull | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Null.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsNumber | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Number.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsObject | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is a JavaScript object.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsString | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is String.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsSymbol | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is Symbol.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsTypedArray | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether a JavaScript value is TypedArray.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
bool JSNIIsUndefined | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Tests whether the JavaScript value is undefined.
env | The JSNI enviroment 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 enviroment pointer. |
initial_length | Initial array size. |
JSValueRef JSNINewBoolean | ( | JSNIEnv * | env, |
bool | val | ||
) |
Constructs a new Boolean JavaScript value.
env | The JSNI enviroment pointer. |
val | A bool value. |
JSValueRef JSNINewFunction | ( | JSNIEnv * | env, |
JSNICallback | callback | ||
) |
Constructs a JavaScript function with callback.
env | The JSNI enviroment 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 enviroment pointer. |
val | A JavaScript value. |
JSValueRef JSNINewNull | ( | JSNIEnv * | env | ) |
Constructs a new Null JavaScript value.
env | The JSNI enviroment pointer. |
JSValueRef JSNINewNumber | ( | JSNIEnv * | env, |
double | val | ||
) |
Constructs a new Number JavaScript value.
env | The JSNI enviroment pointer. |
val | A double value. |
JSValueRef JSNINewObject | ( | JSNIEnv * | env | ) |
Constructs a JavaScript object.
env | The JSNI enviroment 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 enviroment pointer. |
count | A number of internal fields. |
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 enviroment 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 enviroment 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 | val | ||
) |
Constructs a new Symbol JavaScript value.
env | The JSNI enviroment 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 enviroment pointer. |
type | The type of the array. |
data | The pointer to the data buffer of the array. |
length | The length of the array. |
JSValueRef JSNINewUndefined | ( | JSNIEnv * | env | ) |
Constructs a new Undefined JavaScript value.
env | The JSNI enviroment 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 enviroment 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 enviroment 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 enviroment 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 enviroment pointer. |
bool JSNIRegisterMethod | ( | JSNIEnv * | env, |
const JSValueRef | recv, | ||
const char * | name, | ||
JSNICallback | callback | ||
) |
Registers a native callback function.
env | The JSNI enviroment 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 enviroment 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 enviroment pointer. |
array | A JavaScript array. |
index | A array index. |
value | A new value. |
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.
env | The JSNI enviroment 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 enviroment 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 enviroment 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 enviroment pointer. |
info | The callback info. |
val | The JavaScript value to return to JavaScript. |
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 enviroment pointer. |
errmsg | An error message. |
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 enviroment 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 enviroment pointer. |
errmsg | An error message. |
bool JSNIToCBool | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to C bool.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
double JSNIToCDouble | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to C double.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
int32_t JSNIToInt32 | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to int32.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
int64_t JSNIToInt64 | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to int64.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |
uint32_t JSNIToUint32 | ( | JSNIEnv * | env, |
JSValueRef | val | ||
) |
Converts the JavaScript value to uint32.
env | The JSNI enviroment pointer. |
val | A JavaScript value. |