gebr-gui-js

gebr-gui-js

Synopsis

JSValueRef          gebr_js_eval_with_url               (JSContextRef ctx,
                                                         const gchar *script,
                                                         const gchar *url);
JSValueRef          gebr_js_evaluate                    (JSContextRef ctx,
                                                         const gchar *script);
JSValueRef          gebr_js_evaluate_file               (JSContextRef ctx,
                                                         const gchar *file);
gchar *             gebr_js_value_to_string             (JSContextRef ctx,
                                                         JSValueRef value);
GString *           gebr_js_value_get_string            (JSContextRef ctx,
                                                         JSValueRef val);
gboolean            gebr_js_value_get_boolean           (JSContextRef ctx,
                                                         JSValueRef val);
JSObjectRef         gebr_js_make_function               (JSContextRef ctx,
                                                         const gchar *name,
                                                         JSObjectCallAsFunctionCallback callback);
gboolean            gebr_js_include                     (JSContextRef ctx,
                                                         const gchar *file);

Description

Details

gebr_js_eval_with_url ()

JSValueRef          gebr_js_eval_with_url               (JSContextRef ctx,
                                                         const gchar *script,
                                                         const gchar *url);

Evaluates script at the given url.

ctx :

A JSContextRef, from a WebKitWebView for example.

script :

The JavaScript script to be evaluated.

url :

The address associated with this script evaluation.

Returns :

a JSValueRef containing the return value of the evaluated script.

gebr_js_evaluate ()

JSValueRef          gebr_js_evaluate                    (JSContextRef ctx,
                                                         const gchar *script);

Evaluates the JavaScript given by script.

ctx :

A JSContextRef, from a WebKitWebView for example.

script :

The JavaScript script to be evaluated.

Returns :

a JSValueRef containing the return value of the evaluated script.

gebr_js_evaluate_file ()

JSValueRef          gebr_js_evaluate_file               (JSContextRef ctx,
                                                         const gchar *file);

Evaluates the JavaScript file given by file.

ctx :

A JSContextRef, from a WebKitWebView for example.

file :

A system file path, pointing to the JavaScript file.

Returns :

a JSValueRef containing the return value of the evaluated script.

gebr_js_value_to_string ()

gchar *             gebr_js_value_to_string             (JSContextRef ctx,
                                                         JSValueRef value);

This function returns the string representation of value. It is the same as calling the 'toString' method in JavaScript.

Note

Applying this function into a JSValueRef that is a JavaScript String will return the string itself. But you should not trust this behavior. Use gebr_js_value_get_string() for this purpose instead.

ctx :

A JSContextRef, from a WebKitWebView for example.

value :

The value to get the string representation.

Returns :

A newly allocated string representing value.

gebr_js_value_get_string ()

GString *           gebr_js_value_get_string            (JSContextRef ctx,
                                                         JSValueRef val);

Gets the string value of val and returns it as a GString.

ctx :

A JSContextRef, from a WebKitWebView for example.

val :

The value to get the string value.

Returns :

A GString containing the string value of val.

gebr_js_value_get_boolean ()

gboolean            gebr_js_value_get_boolean           (JSContextRef ctx,
                                                         JSValueRef val);

Gets the boolean value from the JSValueRef, val.

ctx :

A JSContextRef, from a WebKitWebView for example.

val :

The JavaScript value to get the boolean value.

Returns :

A gboolean containing the value of val.

gebr_js_make_function ()

JSObjectRef         gebr_js_make_function               (JSContextRef ctx,
                                                         const gchar *name,
                                                         JSObjectCallAsFunctionCallback callback);

Creates a JavaScript function in context ctx which calls callback.

name :

The JavaScript function name to be created.

callback :

A c-function which will be called upon JavaScript's function call.

Returns :

A JavaScript object representing the function.

gebr_js_include ()

gboolean            gebr_js_include                     (JSContextRef ctx,
                                                         const gchar *file);

Includes a JavaScript file into a context by appending a lt;scriptgt; tag into document.body. You must guarantee body tag exists, otherwise this function may fail silently. This might be done by connecting to "load-finished" signal of WebKitWebView.

ctx :

A JavaScript context to have file included.

file :

The path of the JavaScript file to be included.

Returns :

TRUE if file exists, FALSE otherwise.