diff options
Diffstat (limited to 'doc/reference/tmpl/seed-eval.sgml')
-rw-r--r-- | doc/reference/tmpl/seed-eval.sgml | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/doc/reference/tmpl/seed-eval.sgml b/doc/reference/tmpl/seed-eval.sgml new file mode 100644 index 0000000..f3fbecd --- /dev/null +++ b/doc/reference/tmpl/seed-eval.sgml @@ -0,0 +1,125 @@ +<!-- ##### SECTION Title ##### --> +Evaluating JavaScript + +<!-- ##### SECTION Short_Description ##### --> +Creating and interpreting scripts + +<!-- ##### SECTION Long_Description ##### --> +<para> +Seed relies on WebKit's JavaScriptCore interpreter to actually evaluate snippets of JavaScript; however, it provides a handful of useful wrapper functions to quickly create and evaluate scripts. seed_make_script() and seed_evaluate() are the workhorse functions; these allow you to control every detail of the created script and its evaluation environment (including customizing the "this" object during evaluation, and setting a starting line number and filename from which the script originates). seed_simple_evaluate() provides an interface to execute a string of JavaScript without previously creating a #SeedScript, and, while requiring less supporting code, is less flexible. +</para> + +<example> +<title>Create and evaluate a string of JavaScript with seed_make_script()</title> +<programlisting> +SeedEngine * eng; + +... + +SeedScript * script; +/* Create a simple #SeedScript */ +script = seed_make_script(eng->context, "print('Hello, world!')", NULL, 0); + +/* Evaluate the #SeedScript in the default context */ +seed_evaluate(eng->context, script, 0); + +... +</programlisting> +</example> + +<example> +<title>Create and evaluate a string of JavaScript with seed_simple_evaluate()</title> +<programlisting> +SeedEngine * eng; + +... + +/* Evaluate a simple JavaScript snippet in the default context */ +seed_simple_evaluate(eng->context, "print('Hello, world!')", NULL); + +... +</programlisting> +</example> + +<!-- ##### SECTION See_Also ##### --> +<para> + +</para> + +<!-- ##### SECTION Stability_Level ##### --> + + +<!-- ##### SECTION Image ##### --> + + +<!-- ##### STRUCT SeedScript ##### --> +<para> + +</para> + +@script: +@exception: +@source_url: +@line_number: + +<!-- ##### FUNCTION seed_make_script ##### --> +<para> + +</para> + +@ctx: +@js: +@source_url: +@line_number: +@Returns: + + +<!-- ##### FUNCTION seed_evaluate ##### --> +<para> + +</para> + +@ctx: +@s: +@this_object: +@Returns: + + +<!-- ##### FUNCTION seed_simple_evaluate ##### --> +<para> + +</para> + +@ctx: +@source: +@exception: +@Returns: + + +<!-- ##### FUNCTION seed_script_new_from_file ##### --> +<para> + +</para> + +@ctx: +@file: +@Returns: + + +<!-- ##### FUNCTION seed_script_exception ##### --> +<para> + +</para> + +@s: +@Returns: + + +<!-- ##### FUNCTION seed_script_destroy ##### --> +<para> + +</para> + +@s: + + |