summaryrefslogtreecommitdiff
path: root/doc/reference/tmpl/seed-eval.sgml
blob: f3fbecda0fa416da66ee126dd16d98ae21382cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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;
&nbsp;
...
&nbsp;    
SeedScript * script;
/* Create a simple #SeedScript */
script = seed_make_script(eng->context, "print('Hello, world!')", NULL, 0);
&nbsp;
/* Evaluate the #SeedScript in the default context */
seed_evaluate(eng->context, script, 0);
&nbsp;
...
</programlisting>
</example>

<example>
<title>Create and evaluate a string of JavaScript with seed_simple_evaluate()</title>
<programlisting>
SeedEngine * eng;
&nbsp;
...
&nbsp;
/* Evaluate a simple JavaScript snippet in the default context */
seed_simple_evaluate(eng->context, "print('Hello, world!')", NULL);
&nbsp;
...
</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: