node-addon-layer
C API For writing Node modules
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
Object methods

Functions

shim_val_tshim_obj_new (shim_ctx_t *context, shim_val_t *klass, shim_val_t *proto)
 
shim_val_tshim_obj_new_instance (shim_ctx_t *context, shim_val_t *klass, size_t argc, shim_val_t **argv)
 
shim_val_tshim_obj_clone (shim_ctx_t *ctx, shim_val_t *src)
 
shim_bool_t shim_obj_has_name (shim_ctx_t *ctx, shim_val_t *obj, const char *name)
 
shim_bool_t shim_obj_has_id (shim_ctx_t *ctx, shim_val_t *obj, uint32_t id)
 
shim_bool_t shim_obj_has_sym (shim_ctx_t *ctx, shim_val_t *obj, shim_val_t *sym)
 
shim_bool_t shim_obj_set_prop_name (shim_ctx_t *ctx, shim_val_t *recv, const char *name, shim_val_t *val)
 
shim_bool_t shim_obj_set_prop_id (shim_ctx_t *ctx, shim_val_t *recv, uint32_t id, shim_val_t *val)
 
shim_bool_t shim_obj_set_prop_sym (shim_ctx_t *ctx, shim_val_t *recv, shim_val_t *sym, shim_val_t *val)
 
shim_bool_t shim_obj_set_private (shim_ctx_t *ctx, shim_val_t *obj, void *data)
 
shim_bool_t shim_obj_set_funcs (shim_ctx_t *ctx, shim_val_t *recv, const shim_fspec_t *funcs)
 
shim_bool_t shim_obj_get_prop_name (shim_ctx_t *ctx, shim_val_t *obj, const char *name, shim_val_t *rval)
 
shim_bool_t shim_obj_get_prop_id (shim_ctx_t *ctx, shim_val_t *obj, uint32_t id, shim_val_t *rval)
 
shim_bool_t shim_obj_get_prop_sym (shim_ctx_t *ctx, shim_val_t *obj, shim_val_t *sym, shim_val_t *rval)
 
shim_bool_t shim_obj_get_private (shim_ctx_t *ctx, shim_val_t *obj, void **data)
 

Detailed Description

Methods for creating and manipulation javascript objects

Function Documentation

shim_val_t* shim_obj_clone ( shim_ctx_t ctx,
shim_val_t src 
)

Create a second wrapper of the given object

Parameters
ctxThe currently executing context
srcThe given value
Returns
The new Local value representing the previous value

Use this when you might want to create a Local of a persistent

See Also
Persistent methods
shim_bool_t shim_obj_get_private ( shim_ctx_t ctx,
shim_val_t obj,
void **  data 
)

Get the arbitrary data associated with the object

Parameters
ctxThe currently executing context
objThe the given object
dataThe actual data
Returns
TRUE if the object had hidden data, otherwise FALSE
shim_bool_t shim_obj_get_prop_id ( shim_ctx_t ctx,
shim_val_t obj,
uint32_t  idx,
shim_val_t rval 
)

Get the value for the given id

Parameters
ctxThe currently executing context
objThe the given object
idxThe id of the property
rvalThe actual value returned
Returns
TRUE if object had the propert, otherwise FALSE
shim_bool_t shim_obj_get_prop_name ( shim_ctx_t ctx,
shim_val_t obj,
const char *  name,
shim_val_t rval 
)

Get the value for the property name

Parameters
ctxThe currently executing context
objThe the given object
nameThe name of the property
rvalThe actual value returned
Returns
TRUE if object had the propert, otherwise FALSE
shim_bool_t shim_obj_get_prop_sym ( shim_ctx_t ctx,
shim_val_t obj,
shim_val_t sym,
shim_val_t rval 
)

Get the value for the given symbol

Parameters
ctxThe currently executing context
objThe the given object
symThe symbol of the property
rvalThe actual value returned
Returns
TRUE if object had the propert, otherwise FALSE
shim_bool_t shim_obj_has_id ( shim_ctx_t ctx,
shim_val_t val,
uint32_t  id 
)

Check the object has the given id

Parameters
ctxThe currently executing context
valThe given object
idThe id of the property
Returns
TRUE if the object has the indexed property, otherwise FALSE

Object can have ordered properties, or may be an array, use this to check if either exist.

shim_bool_t shim_obj_has_name ( shim_ctx_t ctx,
shim_val_t val,
const char *  name 
)

Check the object has the given name

Parameters
ctxThe currently executing context
valThe given object
nameThe name of the property
Returns
TRUE if the object has the named property, otherwise FALSE

Has the name

shim_bool_t shim_obj_has_sym ( shim_ctx_t ctx,
shim_val_t val,
shim_val_t sym 
)

Check the object has the given symbol

Parameters
ctxThe currently executing context
valThe given object
symThe symbol of the property
Returns
TRUE if the object has the property, otherwise FALSE

Use this if you are keeping a reference to a commonly used symbol name or are passed a value to lookup

shim_val_t* shim_obj_new ( shim_ctx_t ctx,
shim_val_t klass,
shim_val_t proto 
)

Create a new object

Parameters
ctxThe currently executing context
klassThe constructor to be used (may be NULL)
protoThe prototype that should be used (may be NULL)
Returns
A pointer to the created object
See Also
shim_value_release()
shim_val_t* shim_obj_new_instance ( shim_ctx_t ctx,
shim_val_t klass,
size_t  argc,
shim_val_t **  argv 
)

Create a new object by calling the given constructor with arguments

Parameters
ctxThe currently executing context
klassThe given constructor
argcThe amount of arguments being passed
argvThe array of arguments to be passed
Returns
The returned object

Use this to instantiate an object with the given arguments

shim_bool_t shim_obj_set_funcs ( shim_ctx_t ctx,
shim_val_t recv,
const shim_fspec_t funcs 
)

Adds a set of functions to an object

Parameters
ctxThe currently executing context
recvThe object to add the functions to
funcsThe null terminated array of functions
Returns
TRUE if all functions were able to be added, otherwise FALSE
shim_bool_t shim_obj_set_private ( shim_ctx_t ctx,
shim_val_t obj,
void *  data 
)

Add arbitrary data to given object

Parameters
ctxThe currently executing context
objThe given object
dataThe data to be associated with the object
Returns
TRUE if the data was able to be associated, otherwise FALSE

Use this to associate C memory with a given object, which can be recalled at a later time with shim_obj_get_private()

See Also
shim_obj_make_weak()
shim_bool_t shim_obj_set_prop_id ( shim_ctx_t ctx,
shim_val_t obj,
uint32_t  id,
shim_val_t val 
)

Set the value for the given id

Parameters
ctxThe currently executing context
objThe given object
idThe id of the property
valThe value to be stored
Returns
TRUE if the property was set, otherwise FALSE
shim_bool_t shim_obj_set_prop_name ( shim_ctx_t ctx,
shim_val_t obj,
const char *  name,
shim_val_t val 
)

Set the value for the named property

Parameters
ctxThe currently executing context
objThe given object
nameThe name of the property
valThe value to be stored
Returns
TRUE if the property was set, otherwise FALSE
shim_bool_t shim_obj_set_prop_sym ( shim_ctx_t ctx,
shim_val_t obj,
shim_val_t sym,
shim_val_t val 
)

Set the value for the given symbol

Parameters
ctxThe currently executing context
objThe given object
symThe symbol of the property
valThe value to be stored
Returns
TRUE if the property was set, otherwise FALSE