My Project
Classes | Macros | Typedefs | Enumerations | Functions
jsni.h File Reference
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

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.