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

## Synopsis

    #include <seed/seed.h>

    typedef             SeedObject;
    SeedObject          seed_make_object                    (SeedContext ctx,
                                                             SeedClass klass,
                                                             gpointer private_object);
    SeedObject          seed_make_array                     (SeedContext ctx,
                                                             const SeedValue elements,
                                                             gsize num_elements,
                                                             SeedException *exception);
    SeedValue           seed_object_call                    (SeedContext ctx,
                                                             SeedObject object,
                                                             SeedObject this_object,
                                                             gsize argument_count,
                                                             const SeedValue arguments[],
                                                             SeedException *exception);
    void                seed_object_set_property_at_index   (SeedContext ctx,
                                                             SeedObject object,
                                                             gint index,
                                                             SeedValue value,
                                                             SeedException *exception);
    SeedValue           seed_object_get_property_at_index   (SeedContext ctx,
                                                             SeedObject object,
                                                             gint index,
                                                             SeedException *exception);
    gboolean            seed_object_is_of_class             (SeedContext ctx,
                                                             SeedObject obj,
                                                             SeedClass klass);
    gpointer            seed_object_get_private             (SeedObject object);
    void                seed_object_set_private             (SeedObject object,
                                                             gpointer value);
    SeedValue           seed_object_get_property            (SeedContext ctx,
                                                             SeedObject object,
                                                             const gchar *name);
    gboolean            seed_object_set_property            (SeedContext ctx,
                                                             SeedObject object,
                                                             const gchar *name,
                                                             SeedValue value);
    SeedObject          seed_object_get_prototype           (SeedContext ctx,
                                                             SeedObject obj);
    gchar **            seed_object_copy_property_names     (SeedContext ctx,
                                                             SeedObject object);
    void                (*SeedObjectInitializeCallback)     (SeedContext ctx,
                                                             SeedObject object);
    void                (*SeedObjectFinalizeCallback)       (SeedObject object);
    gboolean            (*SeedObjectHasPropertyCallback)    (SeedContext ctx,
                                                             SeedObject object,
                                                             SeedString string);
    SeedValue           (*SeedObjectGetPropertyCallback)    (SeedContext ctx,
                                                             SeedObject object,
                                                             SeedString property_name,
                                                             SeedException *e);
    gboolean            (*SeedObjectSetPropertyCallback)    (SeedContext ctx,
                                                             SeedObject object,
                                                             SeedString property_name,
                                                             SeedValue value,
                                                             SeedException *e);
    gboolean            (*SeedObjectDeletePropertyCallback) (SeedContext ctx,
                                                             SeedObject object,
                                                             SeedString property_name,
                                                             SeedException *e);
    void                (*SeedObjectGetPropertyNamesCallback)
                                                            (void);
    SeedValue           (*SeedObjectCallAsFunctionCallback) (SeedContext ctx,
                                                             SeedObject function,
                                                             SeedObject this_object,
                                                             gsize argument_count,
                                                             const SeedValue arguments[],
                                                             SeedException *exception);
    gboolean            (*SeedObjectHasInstanceCallback)    (SeedContext ctx,
                                                             SeedObject constructor,
                                                             SeedObject instance_p,
                                                             SeedException *exception);
    SeedValue           (*SeedObjectConvertToTypeCallback)  (SeedContext ctx,
                                                             SeedObject object,
                                                             SeedType type,
                                                             SeedException *exception);
    SeedValue           (*SeedObjectCallAsConstructorCallback)
                                                            (SeedContext ctx,
                                                             SeedObject constructor,
                                                             gsize argument_count,
                                                             const SeedValue arguments[],
                                                             SeedException *exception);

## Description

Long description

## Details

### SeedObject

    typedef gpointer SeedObject;

### seed_make_object ()

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

`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.

`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.

`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`.

`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);

### seed_object_is_of_class ()

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

### seed_object_get_private ()

    gpointer            seed_object_get_private             (SeedObject object);

Retrieves the private data of `object`.

`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`.

`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);

`ctx` : | A SeedContext
`object` : | A SeedObject
`name` : | The property to get, should be a valid JavaScript identifier
Returns : | The value of the property or the undefined value

### seed_object_set_property ()

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

`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);

`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);

`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);

### SeedObjectGetPropertyCallback ()

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

### SeedObjectSetPropertyCallback ()

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

### SeedObjectDeletePropertyCallback ()

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

### SeedObjectGetPropertyNamesCallback ()

    void                (*SeedObjectGetPropertyNamesCallback)
                                                            (void);

### SeedObjectCallAsFunctionCallback ()

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

### SeedObjectHasInstanceCallback ()

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

### SeedObjectConvertToTypeCallback ()

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

### SeedObjectCallAsConstructorCallback ()

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