Working with JavaScript objects

Working with JavaScript objects — Using properties, constructing objects, etc.

Functions

Types and Values

typedef SeedObject

Includes

#include <seed/seed.h>

Description

Long description

Functions

seed_make_object ()

SeedObject
seed_make_object (SeedContext ctx,
                  SeedClass klass,
                  gpointer private_object);

Parameters

ctx

The SeedContext in which to create the new object.

 

Returns

A new SeedObject.


seed_make_array ()

SeedObject
seed_make_array (SeedContext ctx,
                 const SeedValue elements,
                 gsize num_elements,
                 SeedException *exception);

Creates a JavaScript Array object from elements , a C-style array of SeedValues.

Parameters

ctx

A valid SeedContext

 

elements

An array of SeedValue's with which to populate the array.

 

num_elements

The number of values, in elements

 

exception

A SeedException in which to store an exception. Pass NULL to ignore exceptions.

 

Returns

A new array object, populated with elements .


seed_object_call ()

SeedValue
seed_object_call (SeedContext ctx,
                  SeedObject object,
                  SeedObject this_object,
                  gsize argument_count,
                  const SeedValue arguments[],
                  SeedException *exception);

Calls object as a function.

Parameters

ctx

A SeedContext.

 

object

A SeedObject to call.

 

argument_count

The number of arguments in the arguments array.

 

arguments

An array (argument_count long) of SeedValues to pass in as the function's arguments.

 

exception

A reference to a SeedValue in which to store any exceptions. Pass NULL to ignore exceptions.

 

Returns

The SeedValue returned by the called function, or NULL if an exception occurs or the object is not a function.


seed_object_set_property_at_index ()

void
seed_object_set_property_at_index (SeedContext ctx,
                                   SeedObject object,
                                   gint index,
                                   SeedValue value,
                                   SeedException *exception);

Sets the property index on object to value .

Parameters

ctx

A SeedContext.

 

object

A SeedObject on which to set the property.

 

index

The index of the property to set.

 

value

The SeedValue to use as the property's value.

 

exception

A reference to a SeedValue in which to store any exceptions. Pass NULL to ignore exceptions.

 

seed_object_get_property_at_index ()

SeedValue
seed_object_get_property_at_index (SeedContext ctx,
                                   SeedObject object,
                                   gint index,
                                   SeedException *exception);

Returns


seed_object_is_of_class ()

gboolean
seed_object_is_of_class (SeedContext ctx,
                         SeedObject obj,
                         SeedClass klass);

Returns


seed_object_get_private ()

gpointer
seed_object_get_private (SeedObject object);

Retrieves the private data of object .

Parameters

object

A SeedObject.

 

Returns

A pointer to the private data of object .


seed_object_set_private ()

void
seed_object_set_private (SeedObject object,
                         gpointer value);

Sets the private data of object to value .

Parameters

object

A SeedObject.

 

value

A gpointer to set the private data of object to.

 

seed_object_get_property ()

SeedValue
seed_object_get_property (SeedContext ctx,
                          SeedObject object,
                          const gchar *name);

Parameters

ctx

A SeedContext

 

object

A SeedObject

 

name

The property to get, should be a valid JavaScript identifier

 

Returns

The value of the property or NULL


seed_object_set_property ()

gboolean
seed_object_set_property (SeedContext ctx,
                          SeedObject object,
                          const gchar *name,
                          SeedValue value);

Parameters

ctx

A SeedContext

 

object

A SeedObject

 

name

The property to set, should be a valid JavaScript identifier

 

value

The value to set the property to.

 

Returns

TRUE on success, FALSE otherwise.


seed_object_get_prototype ()

SeedObject
seed_object_get_prototype (SeedContext ctx,
                           SeedObject obj);

Parameters

ctx

A valid SeedContext

 

obj

A SeedObject

 

Returns

The prototype of obj .


seed_object_copy_property_names ()

gchar **
seed_object_copy_property_names (SeedContext ctx,
                                 SeedObject object);

Parameters

ctx

A valid SeedContext

 

object

An object from which to copy property names.

 

Returns

A NULL terminated array containing the property names of object


SeedObjectInitializeCallback ()

void
(*SeedObjectInitializeCallback) (SeedContext ctx,
                                 SeedObject object);


SeedObjectFinalizeCallback ()

void
(*SeedObjectFinalizeCallback) (SeedObject object);


SeedObjectHasPropertyCallback ()

gboolean
(*SeedObjectHasPropertyCallback) (SeedContext ctx,
                                  SeedObject object,
                                  SeedString string);

Returns


SeedObjectGetPropertyCallback ()

SeedValue
(*SeedObjectGetPropertyCallback) (SeedContext ctx,
                                  SeedObject object,
                                  SeedString property_name,
                                  SeedException *e);

Returns


SeedObjectSetPropertyCallback ()

gboolean
(*SeedObjectSetPropertyCallback) (SeedContext ctx,
                                  SeedObject object,
                                  SeedString property_name,
                                  SeedValue value,
                                  SeedException *e);

Returns


SeedObjectDeletePropertyCallback ()

gboolean
(*SeedObjectDeletePropertyCallback) (SeedContext ctx,
                                     SeedObject object,
                                     SeedString property_name,
                                     SeedException *e);

Returns


SeedObjectGetPropertyNamesCallback ()

void
(*SeedObjectGetPropertyNamesCallback) (void);


SeedObjectCallAsFunctionCallback ()

SeedValue
(*SeedObjectCallAsFunctionCallback) (SeedContext ctx,
                                     SeedObject function,
                                     SeedObject this_object,
                                     gsize argument_count,
                                     const SeedValue arguments[],
                                     SeedException *exception);

Returns


SeedObjectHasInstanceCallback ()

gboolean
(*SeedObjectHasInstanceCallback) (SeedContext ctx,
                                  SeedObject constructor,
                                  SeedObject instance_p,
                                  SeedException *exception);

Returns


SeedObjectConvertToTypeCallback ()

SeedValue
(*SeedObjectConvertToTypeCallback) (SeedContext ctx,
                                    SeedObject object,
                                    SeedType type,
                                    SeedException *exception);

Returns


SeedObjectCallAsConstructorCallback ()

SeedValue
(*SeedObjectCallAsConstructorCallback)
                               (SeedContext ctx,
                                SeedObject constructor,
                                gsize argument_count,
                                const SeedValue arguments[],
                                SeedException *exception);

Returns

Types and Values

SeedObject

typedef gpointer SeedObject;