seed

seed

Synopsis

typedef             SeedClass;
enum                SeedType;
enum                SeedPropertyAttributes;
enum                SeedClassAttributes;

SeedEngine *        seed_init                           (gint *argc,
                                                         gchar ***argv);
void                seed_engine_set_search_path         (SeedEngine *eng,
                                                         const gchar *path);
gchar **            seed_engine_get_search_path         (SeedEngine *eng);

typedef             SeedContext;
typedef             SeedGlobalContext;
typedef             SeedContextGroup;
SeedGlobalContext   seed_context_create                 (SeedContextGroup group,
                                                         SeedClass global_class);
SeedGlobalContext   seed_context_ref                    (SeedGlobalContext ctx);
void                seed_context_unref                  (SeedGlobalContext ctx);

                    SeedScript;
SeedScript *        seed_make_script                    (SeedContext ctx,
                                                         const gchar *js,
                                                         const gchar *source_url,
                                                         gint line_number);
SeedValue           seed_evaluate                       (SeedContext ctx,
                                                         SeedScript *s,
                                                         SeedObject this);
SeedValue           seed_simple_evaluate                (SeedContext ctx,
                                                         gchar *source);
SeedScript *        seed_script_new_from_file           (SeedContext ctx,
                                                         gchar *file);
SeedException       seed_script_exception               (SeedScript *s);

void                seed_create_function                (SeedContext ctx,
                                                         gchar *name,
                                                         SeedFunctionCallback callback,
                                                         SeedObject object);
SeedClass           seed_create_class                   (seed_class_definition *def);
SeedObject          seed_make_constructor               (SeedContext ctx,
                                                         SeedClass class,
                                                         SeedObjectCallAsConstructorCallbackconstructor );

typedef             SeedObject;
SeedValue           seed_object_call                    (SeedContext ctx,
                                                         SeedObject object,
                                                         SeedObject this,
                                                         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);
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);

SeedValue           seed_make_null                      (SeedContext ctx);
SeedObject          seed_make_object                    (SeedContext ctx,
                                                         SeedClass class,
                                                         gpointer private);

gpointer            seed_pointer_get_pointer            (SeedContext ctx,
                                                         SeedValue pointer);

void                (*SeedFunctionCallback)             (SeedContext ctx,
                                                         SeedObject function,
                                                         SeedObject this_object,
                                                         gsize argument_count,
                                                         const SeedValue arguments[],
                                                         SeedException *exception);
SeedObject          (*SeedModuleInitCallback)           (SeedEngine *eng);
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,
                                                         SeedValue value,
                                                         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);

void                seed_signal_connect                 (SeedContext ctx,
                                                         GObject *object,
                                                         const gchar *signal,
                                                         const gchar *script);

Description

Details

SeedClass

typedef gpointer SeedClass;


enum SeedType

typedef enum
{
  SEED_TYPE_UNDEFINED,
  SEED_TYPE_NULL,
  SEED_TYPE_BOOLEAN,
  SEED_TYPE_NUMBER,
  SEED_TYPE_STRING,
  SEED_TYPE_OBJECT
} SeedType;


enum SeedPropertyAttributes

typedef enum
{
  SEED_PROPERTY_ATTRIBUTE_NONE = 0,
  SEED_PROPERTY_ATTRIBUTE_READ_ONLY = 1 << 1,
  SEED_PROPERTY_ATTRIBUTE_DONT_ENUM = 1 << 2,
  SEED_PROPERTY_ATTRIBUTE_DONT_DELETE = 1 << 3
} SeedPropertyAttributes;


enum SeedClassAttributes

typedef enum
{
  SEED_CLASS_ATTRIBUTE_NONE = 0,
  SEED_CLASS_ATTRIBUTE_NO_SHARED_PROTOTYPE = 1 << 1
} SeedClassAttributes;


seed_init ()

SeedEngine *        seed_init                           (gint *argc,
                                                         gchar ***argv);

Initializes a new SeedEngine.

argc :

A reference to the number of arguments remaining to parse.

argv :

A reference to an array of string arguments remaining to parse.

Returns :

The newly created and initialized SeedEngine.

seed_engine_set_search_path ()

void                seed_engine_set_search_path         (SeedEngine *eng,
                                                         const gchar *path);

Sets the default search path for Seed.include.

eng :

A SeedEngine, on which to set the path.

path :

A const gchar*, a colon separated string containing the path to set

seed_engine_get_search_path ()

gchar **            seed_engine_get_search_path         (SeedEngine *eng);

eng :

A SeedEngine, to get the currently set search path.

Returns :

A null-terminated array of strings containing the paths.

SeedContext

typedef gpointer SeedContext;


SeedGlobalContext

typedef gpointer SeedGlobalContext;


SeedContextGroup

typedef gpointer SeedContextGroup;


seed_context_create ()

SeedGlobalContext   seed_context_create                 (SeedContextGroup group,
                                                         SeedClass global_class);

group :

A SeedContextGroup in which to create the new context, or NULL to create it in the default context group.

global_class :

The SeedClass to use to create the global object, or NULL to create it with the default class.

Returns :

A new SeedContext.

seed_context_ref ()

SeedGlobalContext   seed_context_ref                    (SeedGlobalContext ctx);

Increments the reference count of ctx.

ctx :

A SeedContext.

Returns :

ctx

seed_context_unref ()

void                seed_context_unref                  (SeedGlobalContext ctx);

Decrements the reference count of ctx.

ctx :

A SeedContext.

SeedScript

typedef struct _SeedScript SeedScript;


seed_make_script ()

SeedScript *        seed_make_script                    (SeedContext ctx,
                                                         const gchar *js,
                                                         const gchar *source_url,
                                                         gint line_number);

Creates a new SeedScript instance with js as the contents, then checks for proper syntax.

ctx :

A SeedContext.

js :

A string representing the contents of the script.

source_url :

The filename of the script, for reference in errors, or NULL.

line_number :

The line number of the beginning of the script, for reference in error messages, or NULL.

Returns :

The newly created SeedScript.

seed_evaluate ()

SeedValue           seed_evaluate                       (SeedContext ctx,
                                                         SeedScript *s,
                                                         SeedObject this);

Evaluates a SeedScript with this as the global "this" object.

ctx :

A SeedContext.

s :

A SeedScript to evaluate.

this :

The object which should be assigned to the "this" global.

Returns :

The SeedValue returned by evaluating the script.

seed_simple_evaluate ()

SeedValue           seed_simple_evaluate                (SeedContext ctx,
                                                         gchar *source);

Evaluates a string of JavaScript.

ctx :

A SeedContext.

source :

A string representing the JavaScript to evaluate.

Returns :

The SeedValue returned by evaluating the script.

seed_script_new_from_file ()

SeedScript *        seed_script_new_from_file           (SeedContext ctx,
                                                         gchar *file);

Uses seed_make_script() to create a SeedScript from the contents of file.

ctx :

A SeedContext.

file :

The filename of the script to load.

Returns :

The newly created SeedScript.

seed_script_exception ()

SeedException       seed_script_exception               (SeedScript *s);

s :

A SeedScript.

Returns :

A JSValueRef representing the exception of s.

seed_create_function ()

void                seed_create_function                (SeedContext ctx,
                                                         gchar *name,
                                                         SeedFunctionCallback callback,
                                                         SeedObject object);

ctx :

name :

callback :

object :


seed_create_class ()

SeedClass           seed_create_class                   (seed_class_definition *def);

def :

A JSClassDefinition.

Returns :

A SeedClass, described by def.

seed_make_constructor ()

SeedObject          seed_make_constructor               (SeedContext ctx,
                                                         SeedClass class,
                                                         SeedObjectCallAsConstructorCallbackconstructor );

ctx :

A SeedContext.

class :

A SeedClass to use as the default for constructed objects.

Param3 :

Returns :

A SeedObject, which is a constructor function.

SeedObject

typedef gpointer SeedObject;


seed_object_call ()

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

Calls object as a function.

ctx :

A SeedContext.

object :

A SeedObject to call.

this :

The SeedObject to use as the 'this' object inside the called function.

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_private ()

gpointer            seed_object_get_private             (SeedObject 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 NULL

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_make_null ()

SeedValue           seed_make_null                      (SeedContext ctx);

ctx :

A SeedContext.

Returns :

A SeedValue representing NULL.

seed_make_object ()

SeedObject          seed_make_object                    (SeedContext ctx,
                                                         SeedClass class,
                                                         gpointer private);

ctx :

The SeedContext in which to create the new object.

class :

The SeedClass to use to create the new object, or NULL to use the default object class.

private :

The initial private data of the new object.

Returns :

A new SeedObject.

seed_pointer_get_pointer ()

gpointer            seed_pointer_get_pointer            (SeedContext ctx,
                                                         SeedValue pointer);

ctx :

pointer :

Returns :


SeedFunctionCallback ()

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

ctx :

function :

this_object :

argument_count :

arguments :

exception :


SeedModuleInitCallback ()

SeedObject          (*SeedModuleInitCallback)           (SeedEngine *eng);

eng :

Returns :


SeedObjectInitializeCallback ()

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

ctx :

object :


SeedObjectFinalizeCallback ()

void                (*SeedObjectFinalizeCallback)       (SeedObject object);

object :


SeedObjectHasPropertyCallback ()

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

ctx :

object :

string :

Returns :


SeedObjectGetPropertyCallback ()

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

ctx :

object :

property_name :

e :

Returns :


SeedObjectSetPropertyCallback ()

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

ctx :

object :

property_name :

value :

e :

Returns :


SeedObjectDeletePropertyCallback ()

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

ctx :

object :

property_name :

value :

e :

Returns :


SeedObjectGetPropertyNamesCallback ()

void                (*SeedObjectGetPropertyNamesCallback)
                                                        (void);


SeedObjectCallAsFunctionCallback ()

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

ctx :

function :

this_object :

argument_count :

arguments :

exception :

Returns :


SeedObjectHasInstanceCallback ()

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

ctx :

constructor :

instance_p :

exception :

Returns :


SeedObjectConvertToTypeCallback ()

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

ctx :

object :

type :

exception :

Returns :


SeedObjectCallAsConstructorCallback ()

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

ctx :

constructor :

argument_count :

arguments :

exception :

Returns :


seed_signal_connect ()

void                seed_signal_connect                 (SeedContext ctx,
                                                         GObject *object,
                                                         const gchar *signal,
                                                         const gchar *script);