This file is indexed.

/usr/share/gtk-doc/html/seed/seed-Modules.html is in seed-doc 3.2.0-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Seed Modules</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<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-SeedClosure.html" title="Using JavaScript closures">
<link rel="next" href="modules.html" title="Part IV. Seed Module Reference">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="seed-SeedClosure.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="api.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Seed Reference Manual</th>
<td><a accesskey="n" href="modules.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#seed-Modules.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#seed-Modules.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="seed-Modules"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="seed-Modules.top_of_page"></a>Seed Modules</span></h2>
<p>Seed Modules — Native C modules for Seed</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="seed-Modules.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;seed/seed.h&gt;

#define             <a class="link" href="seed-Modules.html#CHECK-ARG-COUNT:CAPS" title="CHECK_ARG_COUNT()">CHECK_ARG_COUNT</a>                     (name,
                                                         argnum)
#define             <a class="link" href="seed-Modules.html#DEFINE-ENUM-MEMBER:CAPS" title="DEFINE_ENUM_MEMBER()">DEFINE_ENUM_MEMBER</a>                  (holder,
                                                         member)
#define             <a class="link" href="seed-Modules.html#DEFINE-ENUM-MEMBER-EXT:CAPS" title="DEFINE_ENUM_MEMBER_EXT()">DEFINE_ENUM_MEMBER_EXT</a>              (holder,
                                                         name,
                                                         val)
<a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="returnvalue">SeedObject</span></a>          (<a class="link" href="seed-Modules.html#SeedModuleInitCallback" title="SeedModuleInitCallback ()">*SeedModuleInitCallback</a>)           (<em class="parameter"><code><a class="link" href="seed-Initialization.html#SeedEngine" title="struct SeedEngine"><span class="type">SeedEngine</span></a> *eng</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="seed-Modules.description"></a><h2>Description</h2>
<p>
Seed includes a simple system for creating C modules which can be loaded and manipulated from JavaScript. This is used for implementing performance-critical code closer to the silicon, as well as binding non-introspectable libraries in an attractive way.
</p>
<p>Numerous binding modules are included in the Seed repository; when writing a new native module, it would be wise to look over these before beginning, as they have many tidbits of useful knowledge for writing modules.</p>
<div class="example">
<a name="idp5111200"></a><p class="title"><b>Example 11. Very simple example C module</b></p>
<div class="example-contents"><pre class="programlisting">
#include &lt;glib.h&gt;
#include &lt;seed-module.h&gt;
SeedObject seed_module_init(SeedEngine * eng)
{
    /* Say hello! */
    g_print("Hello, Seed Module World!\n");
 
    /* Return an empty object as the module's namespace */
    return seed_make_object (eng-&gt;context, NULL, NULL);
}
</pre></div>
</div>
<br class="example-break"><p>Above is a C module which does absolutely nothing useful. When a module is loaded, <code class="function">seed_module_init()</code> is called, which should have the signature of <a class="link" href="seed-Modules.html#SeedModuleInitCallback" title="SeedModuleInitCallback ()"><code class="function">SeedModuleInitCallback()</code></a>. You're passed the global <a class="link" href="seed-Initialization.html#SeedEngine" title="struct SeedEngine"><span class="type">SeedEngine</span></a>, and the value you return is the namespace for your module. Say, for example, you place a static function on that object:</p>
<div class="example">
<a name="idp8733520"></a><p class="title"><b>Example 12. C module with a function</b></p>
<div class="example-contents"><pre class="programlisting">
#include &lt;glib.h&gt;
#include &lt;seed-module.h&gt;
/* Our function, with the signature of SeedFunctionCallback(); say hello! */
SeedValue say_hello_to(SeedContext ctx,
                       SeedObject function,
                       SeedObject this_object,
                       gsize argument_count,
                       const SeedValue arguments[],
                       SeedException *exception)
{
    guchar * name;
 
    /* Check that only one argument was passed into the function.
       CHECK_ARG_COUNT() is from seed-module.h, which you might find useful. */
    CHECK_ARG_COUNT("hello.say_hello_to", 1);
 
    /* Convert the first argument, a <a class="link" href="seed-Native-Type-Conversion.html#SeedValue" title="SeedValue">SeedValue</a>, to a C string */
    name = seed_value_to_string(ctx, arguments[0], exception);
 
    g_print("Hello, %s!\n", name);
 
    g_free(name);
 
    return seed_make_null(ctx);
}
 
/* Define an array of seed_static_function */
seed_static_function gettext_funcs[] = {
    {"say_hello_to", say_hello_to, 0}
};
 
SeedObject seed_module_init(SeedEngine * eng)
{
    SeedGlobalContext ctx = eng-&gt;context;
 
    /* Create a new class definition with our array of static functions */
    seed_class_definition ns_class_def = seed_empty_class;
    ns_class_def.static_functions = example_funcs;
 
    /* Create a class from the class definition we just created */
    SeedClass ns_class = seed_create_class(&amp;ns_class_def);
 
    /* Instantiate the class; this instance will be the namespace we return */
    ns_ref = seed_make_object (ctx, ns_class, NULL);
    seed_value_protect (ctx, ns_ref);
 
    return ns_ref;
}
</pre></div>
</div>
<br class="example-break"><p>After building and installing this module (look in the Seed build system for examples of how to get this to work, as well as a copy of seed-module.h, which will be very useful), it will be loadable with the normal Seed import system. Assuming it's installed as libseed_hello.so:</p>
<div class="example">
<a name="idp10669232"></a><p class="title"><b>Example 13. Utilize our second example C module from JavaScript</b></p>
<div class="example-contents"><pre class="programlisting">
hello = imports.hello;
hello.say_hello_to("Tim");
</pre></div>
</div>
<br class="example-break">
</div>
<div class="refsect1">
<a name="seed-Modules.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="CHECK-ARG-COUNT:CAPS"></a><h3>CHECK_ARG_COUNT()</h3>
<pre class="programlisting">#define             CHECK_ARG_COUNT(name, argnum)</pre>
<p>
Check that the required number of arguments were passed into a
<a class="link" href="seed-Native-Functions.html#SeedFunctionCallback" title="SeedFunctionCallback ()"><span class="type">SeedFunctionCallback</span></a>. If this is not true, raise an exception and
return <code class="literal">NULL</code>. This requires the callback to use "argument_count",
"ctx", and "exception" as the names of the various function arguments.
</p>
<p>
<em class="parameter"><code>name</code></em> should be of form "namespace.function_name"
</p>
<p>
At the moment, there is no way to specify more than one acceptable
argument count.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
<td>The name of the function being called from, pretty-printed</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>argnum</code></em> :</span></p></td>
<td>The number of arguments which should be passed into the function</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="DEFINE-ENUM-MEMBER:CAPS"></a><h3>DEFINE_ENUM_MEMBER()</h3>
<pre class="programlisting">#define             DEFINE_ENUM_MEMBER(holder, member)</pre>
<p>
Defines a property on <em class="parameter"><code>holder</code></em> which is named the same as <em class="parameter"><code>member</code></em>, and
is assigned the value that <em class="parameter"><code>member</code></em> has in C.
</p>
<p>
This macro works for defining properties from constants and
#defines as well.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>holder</code></em> :</span></p></td>
<td>The object on which to define the enum member</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>member</code></em> :</span></p></td>
<td>The enum member, as it is named in C</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="DEFINE-ENUM-MEMBER-EXT:CAPS"></a><h3>DEFINE_ENUM_MEMBER_EXT()</h3>
<pre class="programlisting">#define             DEFINE_ENUM_MEMBER_EXT(holder, name, val)</pre>
<p>
Defines a property on <em class="parameter"><code>holder</code></em> which is named <em class="parameter"><code>name</code></em>, and is assigned the
value that <em class="parameter"><code>member</code></em> has in C. This allows for an override of the enum
member's name, most often to remove a common prefix. For example, to declare
a property named VERSION_MAJOR on the namespace from mfpr's version
constant MPFR_VERSION_MAJOR:
</p>
<p>
</p>
<pre class="programlisting">
DEFINE_ENUM_MEMBER_EXT(ns, "VERSION_MAJOR", MPFR_VERSION_MAJOR);
</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>holder</code></em> :</span></p></td>
<td>The object on which to define the enum member</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
<td>The enum member, as it should be named in JavaScript</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>val</code></em> :</span></p></td>
<td>The enum member, as it is named in C</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="SeedModuleInitCallback"></a><h3>SeedModuleInitCallback ()</h3>
<pre class="programlisting"><a class="link" href="seed-JS-Objects.html#SeedObject" title="SeedObject"><span class="returnvalue">SeedObject</span></a>          (*SeedModuleInitCallback)           (<em class="parameter"><code><a class="link" href="seed-Initialization.html#SeedEngine" title="struct SeedEngine"><span class="type">SeedEngine</span></a> *eng</code></em>);</pre>
<p>
</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18</div>
</body>
</html>