Evaluation

Evaluation

Functions

Types and Values

Includes

#include <seed/seed.h>

Description

Functions

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.

Note: seed_make_script() does not handle the shebang line, and will return a parse error if one is included in js .

Parameters

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

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

Parameters

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,
                      SeedException *exception);

Evaluates a string of JavaScript in ctx ; if an exception is raised in the context of the script, it will be placed in exception .

Parameters

ctx

A SeedContext.

 

source

A string representing the JavaScript to evaluate.

 

exception

A SeedException pointer to store an exception in.

 

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 .

Parameters

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

Retrieves the exception (if any) raised during the evaluation of s .

Parameters

s

A SeedScript.

 

Returns

A SeedException representing the exception of s .


seed_script_destroy ()

void
seed_script_destroy (SeedScript *s);

Types and Values

SeedScript

typedef struct {
  JSStringRef script;
  JSValueRef exception;

  JSStringRef source_url;
  gint line_number;
} SeedScript;