diff options
Diffstat (limited to 'doc/reference/html/seed-Native-Functions.html')
-rw-r--r-- | doc/reference/html/seed-Native-Functions.html | 137 |
1 files changed, 49 insertions, 88 deletions
diff --git a/doc/reference/html/seed-Native-Functions.html b/doc/reference/html/seed-Native-Functions.html index b252fa6..5c70ddc 100644 --- a/doc/reference/html/seed-Native-Functions.html +++ b/doc/reference/html/seed-Native-Functions.html @@ -3,12 +3,12 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Creating native functions: Seed Reference Manual</title> -<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> <link rel="home" href="index.html" title="Seed Reference Manual"> <link rel="up" href="api.html" title="Part III. Seed API Reference"> <link rel="prev" href="seed-JS-Objects.html" title="Working with JavaScript objects"> <link rel="next" href="seed-JavaScript-Classes.html" title="Creating JavaScript classes"> -<meta name="generator" content="GTK-Doc V1.24 (XML mode)"> +<meta name="generator" content="GTK-Doc V1.25 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> @@ -33,7 +33,7 @@ </tr></table></div> <div class="refsect1"> <a name="seed-Native-Functions.functions"></a><h2>Functions</h2> -<div class="informaltable"><table width="100%" border="0"> +<div class="informaltable"><table class="informaltable" width="100%" border="0"> <colgroup> <col width="150px" class="functions_return"> <col class="functions_name"> @@ -81,79 +81,40 @@ All native C callbacks should have the prototype of <a class="link" href="seed-N </p> <div class="example"> <a name="id-1.4.9.5.4"></a><p class="title"><b>Example 10. Simple C program which embeds Seed with one exposed function</b></p> -<div class="example-contents"> - <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> - <tbody> - <tr> - <td class="listing_lines" align="right"><pre>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</pre></td> - <td class="listing_code"><pre class="programlisting"><span class="preproc">#include</span><span class="normal"> </span><span class="string"><glib.h></span> -<span class="preproc">#include</span><span class="normal"> </span><span class="string"><seed.h></span> -<span class="normal"> </span> -<span class="comment">/* Our function, with the signature of SeedFunctionCallback(); say hello! */</span> -<span class="usertype">SeedValue</span><span class="normal"> </span><span class="function">hello_world</span><span class="symbol">(</span><span class="usertype">SeedContext</span><span class="normal"> ctx</span><span class="symbol">,</span> -<span class="normal"> </span><span class="usertype">SeedObject</span><span class="normal"> function</span><span class="symbol">,</span> -<span class="normal"> </span><span class="usertype">SeedObject</span><span class="normal"> this_object</span><span class="symbol">,</span> -<span class="normal"> </span><span class="usertype">gsize</span><span class="normal"> argument_count</span><span class="symbol">,</span> -<span class="normal"> </span><span class="keyword">const</span><span class="normal"> </span><span class="usertype">SeedValue</span><span class="normal"> arguments</span><span class="symbol">[],</span> -<span class="normal"> </span><span class="usertype">SeedException</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">exception</span><span class="symbol">)</span> -<span class="cbracket">{</span> -<span class="normal"> </span><span class="function"><a href="https://developer.gnome.org/glib/unstable/glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="symbol">(</span><span class="string">"Hello, World!</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">);</span> -<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="function"><a href="seed-Native-Type-Conversion.html#seed-make-null">seed_make_null</a></span><span class="symbol">(</span><span class="normal">ctx</span><span class="symbol">);</span> -<span class="cbracket">}</span> -<span class="normal"> </span> -<span class="type">int</span><span class="normal"> </span><span class="function">main</span><span class="symbol">(</span><span class="usertype">gint</span><span class="normal"> argc</span><span class="symbol">,</span><span class="normal"> <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">**</span><span class="normal"> argv</span><span class="symbol">)</span> -<span class="cbracket">{</span> -<span class="normal"> <a href="seed-Initialization.html#SeedEngine">SeedEngine</a> </span><span class="symbol">*</span><span class="normal"> eng</span><span class="symbol">;</span> -<span class="normal"> </span> -<span class="normal"> </span><span class="comment">/* Initialize the Seed engine */</span> -<span class="normal"> eng </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="seed-Initialization.html#seed-init">seed_init</a></span><span class="symbol">(&</span><span class="normal">argc</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">argv</span><span class="symbol">);</span> -<span class="normal"> </span> -<span class="normal"> </span><span class="comment">/* Expose a C function to JavaScript */</span> -<span class="normal"> </span><span class="function"><a href="seed-Native-Functions.html#seed-create-function">seed_create_function</a></span><span class="symbol">(</span><span class="normal">eng</span><span class="symbol">-></span><span class="normal">context</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"hello_world"</span><span class="symbol">,</span> -<span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="seed-Native-Functions.html#SeedFunctionCallback">SeedFunctionCallback</a></span><span class="symbol">)</span><span class="normal">hello_world</span><span class="symbol">,</span> -<span class="normal"> eng</span><span class="symbol">-></span><span class="normal">global</span><span class="symbol">);</span> -<span class="normal"> </span> -<span class="normal"> </span><span class="comment">/* Call the newly created JavaScript function */</span> -<span class="normal"> </span><span class="function"><a href="seed-Evaluation.html#seed-simple-evaluate">seed_simple_evaluate</a></span><span class="symbol">(</span><span class="normal">eng</span><span class="symbol">-></span><span class="normal">context</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"hello_world()"</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span> -<span class="normal"> </span> -<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span> -<span class="cbracket">}</span></pre></td> - </tr> - </tbody> - </table> -</div> - +<div class="example-contents"><pre class="programlisting"> +#include <glib.h> +#include <seed.h> + +/* Our function, with the signature of SeedFunctionCallback(); say hello! */ +SeedValue hello_world(SeedContext ctx, + SeedObject function, + SeedObject this_object, + gsize argument_count, + const SeedValue arguments[], + SeedException *exception) +{ + g_print("Hello, World!\n"); + return seed_make_null(ctx); +} + +int main(gint argc, gchar ** argv) +{ + SeedEngine * eng; + + /* Initialize the Seed engine */ + eng = seed_init(&argc, &argv); + + /* Expose a C function to JavaScript */ + seed_create_function(eng->context, "hello_world", + (SeedFunctionCallback)hello_world, + eng->global); + + /* Call the newly created JavaScript function */ + seed_simple_evaluate(eng->context, "hello_world()", NULL); + + return 0; +} +</pre></div> </div> <br class="example-break"> </div> @@ -165,14 +126,14 @@ All native C callbacks should have the prototype of <a class="link" href="seed-N <span class="c_punctuation">(</span>*SeedFunctionCallback<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="seed-Contexts.html#SeedContext" title="SeedContext"><span class="type">SeedContext</span></a> ctx</code></em>, <em class="parameter"><code><a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="type">SeedObject</span></a> function</code></em>, <em class="parameter"><code><a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="type">SeedObject</span></a> this_object</code></em>, - <em class="parameter"><code><a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> argument_count</code></em>, + <em class="parameter"><code><span class="type">gsize</span> argument_count</code></em>, <em class="parameter"><code>const <a class="link" href="seed-Native-Type-Conversion.html#SeedValue" title="SeedValue"><span class="type">SeedValue</span></a> arguments[]</code></em>, <em class="parameter"><code><a class="link" href="seed-Exceptions.html#SeedException" title="SeedException"><span class="type">SeedException</span></a> *exception</code></em>);</pre> <p>All native C function callbacks should use the prototype of SeedFunctionCallback.</p> <div class="refsect3"> -<a name="id-1.4.9.6.2.5"></a><h4>Parameters</h4> -<div class="informaltable"><table width="100%" border="0"> +<a name="SeedFunctionCallback.parameters"></a><h4>Parameters</h4> +<div class="informaltable"><table class="informaltable" width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> @@ -215,7 +176,7 @@ to throw a JavaScript exception from the callback.</p></td> </table></div> </div> <div class="refsect3"> -<a name="id-1.4.9.6.2.6"></a><h4>Returns</h4> +<a name="SeedFunctionCallback.returns"></a><h4>Returns</h4> <p> The <a class="link" href="seed-Native-Type-Conversion.html#SeedValue" title="SeedValue"><span class="type">SeedValue</span></a> to return to the caller</p> </div> </div> @@ -225,13 +186,13 @@ to throw a JavaScript exception from the callback.</p></td> <pre class="programlisting"><a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="returnvalue">SeedObject</span></a> seed_make_function (<em class="parameter"><code><a class="link" href="seed-Contexts.html#SeedContext" title="SeedContext"><span class="type">SeedContext</span></a> ctx</code></em>, <em class="parameter"><code><a class="link" href="seed-Native-Functions.html#SeedFunctionCallback" title="SeedFunctionCallback ()"><span class="type">SeedFunctionCallback</span></a> func</code></em>, - <em class="parameter"><code>const <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>);</pre> + <em class="parameter"><code>const <span class="type">gchar</span> *name</code></em>);</pre> <p>Creates a JavaScript object representing a first-class function; when the function is called from JavaScript, <em class="parameter"><code>func</code></em> will be called.</p> <div class="refsect3"> -<a name="id-1.4.9.6.3.5"></a><h4>Parameters</h4> -<div class="informaltable"><table width="100%" border="0"> +<a name="seed-make-function.parameters"></a><h4>Parameters</h4> +<div class="informaltable"><table class="informaltable" width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> @@ -257,7 +218,7 @@ the function is called from JavaScript, <em class="parameter"><code>func</code>< </table></div> </div> <div class="refsect3"> -<a name="id-1.4.9.6.3.6"></a><h4>Returns</h4> +<a name="seed-make-function.returns"></a><h4>Returns</h4> <p> A <a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="type">SeedObject</span></a> representing the function</p> </div> </div> @@ -266,7 +227,7 @@ the function is called from JavaScript, <em class="parameter"><code>func</code>< <a name="seed-create-function"></a><h3>seed_create_function ()</h3> <pre class="programlisting"><span class="returnvalue">void</span> seed_create_function (<em class="parameter"><code><a class="link" href="seed-Contexts.html#SeedContext" title="SeedContext"><span class="type">SeedContext</span></a> ctx</code></em>, - <em class="parameter"><code><a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>, + <em class="parameter"><code><span class="type">gchar</span> *name</code></em>, <em class="parameter"><code><a class="link" href="seed-Native-Functions.html#SeedFunctionCallback" title="SeedFunctionCallback ()"><span class="type">SeedFunctionCallback</span></a> func</code></em>, <em class="parameter"><code><a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="type">SeedObject</span></a> obj</code></em>);</pre> <p>Creates a JavaScript object representing a first-class function; when @@ -276,8 +237,8 @@ the created function as the property <em class="parameter"><code>name</code></em on <em class="parameter"><code>obj</code></em> .</p> <div class="refsect3"> -<a name="id-1.4.9.6.4.5"></a><h4>Parameters</h4> -<div class="informaltable"><table width="100%" border="0"> +<a name="seed-create-function.parameters"></a><h4>Parameters</h4> +<div class="informaltable"><table class="informaltable" width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> @@ -314,6 +275,6 @@ the created function as the property <em class="parameter"><code>name</code></em </div> </div> <div class="footer"> -<hr>Generated by GTK-Doc V1.24</div> +<hr>Generated by GTK-Doc V1.25</div> </body> </html>
\ No newline at end of file |