1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- This is the developer's manual for Aspell.
5 Copyright © 2002, 2003, 2004, 2006 Kevin Atkinson.
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.1 or
9 any later version published by the Free Software Foundation; with no
10 Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A
11 copy of the license is included in the section entitled "GNU Free
12 Documentation License". -->
13 <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
15 <title>Aspell Developer’s Manual: Mk-Src Script</title>
17 <meta name="description" content="Aspell spell checker developer’s manual.">
18 <meta name="keywords" content="Aspell Developer’s Manual: Mk-Src Script">
19 <meta name="resource-type" content="document">
20 <meta name="distribution" content="global">
21 <meta name="Generator" content="makeinfo">
22 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23 <link href="index.html#Top" rel="start" title="Top">
24 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
25 <link href="index.html#Top" rel="up" title="Top">
26 <link href="How-It-All-Works.html#How-It-All-Works" rel="next" title="How It All Works">
27 <link href="Data-Structures.html#Data-Structures" rel="prev" title="Data Structures">
28 <style type="text/css">
30 a.summary-letter {text-decoration: none}
31 blockquote.smallquotation {font-size: smaller}
32 div.display {margin-left: 3.2em}
33 div.example {margin-left: 3.2em}
34 div.indentedblock {margin-left: 3.2em}
35 div.lisp {margin-left: 3.2em}
36 div.smalldisplay {margin-left: 3.2em}
37 div.smallexample {margin-left: 3.2em}
38 div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
39 div.smalllisp {margin-left: 3.2em}
40 kbd {font-style:oblique}
41 pre.display {font-family: inherit}
42 pre.format {font-family: inherit}
43 pre.menu-comment {font-family: serif}
44 pre.menu-preformatted {font-family: serif}
45 pre.smalldisplay {font-family: inherit; font-size: smaller}
46 pre.smallexample {font-size: smaller}
47 pre.smallformat {font-family: inherit; font-size: smaller}
48 pre.smalllisp {font-size: smaller}
49 span.nocodebreak {white-space:nowrap}
50 span.nolinebreak {white-space:nowrap}
51 span.roman {font-family:serif; font-weight:normal}
52 span.sansserif {font-family:sans-serif; font-weight:normal}
53 ul.no-bullet {list-style: none}
60 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
61 <a name="Mk_002dSrc-Script"></a>
64 Next: <a href="How-It-All-Works.html#How-It-All-Works" accesskey="n" rel="next">How It All Works</a>, Previous: <a href="Data-Structures.html#Data-Structures" accesskey="p" rel="prev">Data Structures</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
67 <a name="Mk_002dSrc-Script-1"></a>
68 <h2 class="chapter">14 Mk-Src Script</h2>
70 <p>A good deal of interface code is automatically generated by the
71 <samp>mk-src.pl</samp> Perl script. I am doing it this way to avoid having
72 to write a lot of relative code for the C++ interface. This should
73 also make adding interface for other languages a lot less tedious and
74 will allow the interface to automatically take advantage of new Aspell
75 functionality as it is made available. The <samp>mk-src.pl</samp> script
76 uses <samp>mk-src.in</samp> as its input.
78 <a name="mk_002dsrc_002ein"></a>
79 <h3 class="section">14.1 mk-src.in</h3>
81 <p>NOTE: This section may not always be up to date since it is manually
82 converted from the pod source.
84 <p>The format of <samp>mk-src.in</samp> is as follows:
86 <pre class="verbatim"> The following characters are literals: { } / '\ ' \n = >
89 <items> := (<item>\n)+
90 <items> := <category>:\ <name> {\n<details>\n} | <<tab>><details>
91 <details> := <options>\n /\n <items>
92 <options> := (<option>\n)*
93 <option> := <key> [=> <value>]
95 <<tab>> means everything should be indented by one tab
97 <p>See MkSrc::Info for a description of the categories and options
99 <a name="MkSrc_003a_003aInfo"></a>
100 <h3 class="section">14.2 MkSrc::Info</h3>
102 <p><code>%info</code>
104 <p>The info array contains information on how to process the info in
105 <samp>mk-src.pl</samp>. It has the following layout
107 <pre class="verbatim"> <catagory> => options => []
108 groups => [] # if undef than anything is accepted
109 creates_type => "" # the object will create a new type
111 proc => <impl type> => sub {}
112 </pre><p>where <impl type> is one of:
113 </p><pre class="verbatim"> cc: for "aspell.h" header file
114 cxx: for C++ interface implemented on top of cc interface
115 native: for creation of header files used internally by aspell
116 impl: for defination of functions declared in cc interface.
117 the definations use the native hedaer files
118 native_impl: for implementations of stuff declared in the native
120 </pre><p>each proc sub should take the following argv
121 </p><pre class="verbatim"> $data: a subtree of $master_data
123 </pre><p><options> is one of:
124 </p><pre class="verbatim"> desc: description of the object
126 posib err: the method may return an error condition
128 const: the method is a const member
129 c only: only include in the external interface
130 c impl headers: extra headers that need to be included in the C impl
131 c impl: use this as the c impl instead of the default
132 cxx impl: use this as the cxx impl instead of the default
133 returns alt type: the constructor returns some type other than
134 the object from which it is a member of
135 no native: do not attempt to create a native implementation
136 treat as object: treat as a object rather than a pointer
137 </pre><p>The <code>%info</code> structure is initialized as follows:
138 </p><pre class="verbatim"> our %info =
142 groups => ['methods', 'group']},
144 # methods is a collection of methods which will be inserted into
145 # a class after some simple substation rules. A $ will be
146 # replaced with name of the class.
147 options => ['strip', 'prefix', 'c impl headers'],
150 # a group is a colection of objects which should be grouped together
151 # this generally means they will be in the same source file
152 options => ['no native'],
153 groups => ['enum', 'struct', 'union', 'func', 'class', 'errors']},
156 options => ['desc', 'prefix'],
157 creates_type => 'enum'},
160 options => ['desc', 'treat as object'],
162 creates_type => 'struct',},
165 options => ['desc', 'treat as object'],
167 creates_type => 'union'},
170 options => ['c impl headers'],
172 creates_type => 'class'},
173 errors => {}, # possible errors
176 options => ['desc', 'posib err', 'c func', 'const',
177 'c only', 'c impl', 'cxx impl'],
180 # A class constructor
181 options => ['returns alt type', 'c impl', 'desc'],
182 groups => 'types'},
188 </pre><p>In addition to the categories listed above a “methods” category by be
189 specified in under the class category. A “methods” category is created
190 for each methods group under the name “<methods name> methods”. When
191 groups is undefined a type name may be specified in place of a category.
193 <p><code>%types</code>
195 <p>types contains a master list of all types. This includes basic types and
196 ones created in <samp>mk-src.in</samp>. The basic types include:
197 </p><pre class="verbatim"> 'void', 'bool', 'pointer', 'double',
198 'string', 'encoded string', 'string obj',
199 'char', 'unsigned char',
200 'short', 'unsigned short',
201 'int', 'unsigned int',
202 'long', 'unsigned long'
205 <p><code>%methods</code> is used for holding the “methods” information
207 <a name="MkSrc_003a_003aUtil"></a>
208 <h3 class="section">14.3 MkSrc::Util</h3>
210 <p>This module contains various useful utility functions:
211 </p><dl compact="compact">
212 <dt><code>false</code></dt>
216 <dt><code>true</code></dt>
220 <dt><code>cmap EXPR LIST</code></dt>
221 <dd><p>Apply EXPR to each item in LIST and than concatenate the result into
225 <dt><code>one_of STR LIST</code></dt>
226 <dd><p>Returns true if LIST contains at least one of STR.
229 <dt><code>to_upper STR</code></dt>
230 <dd><p>Convert STR to all uppercase and substitute spaces with underscores.
233 <dt><code>to_lower STR</code></dt>
234 <dd><p>Convert STR to all lowercase and substitute spaces with underscores.
237 <dt><code>to_mixed STR</code></dt>
238 <dd><p>Convert STR to mixed case where each new word startes with a
239 uppercase letter. For example "feed me" would become "FeedMe".
243 <a name="MkSrc_003a_003aRead"></a>
244 <h3 class="section">14.4 MkSrc::Read</h3>
247 Read in <samp>mk-src.in</samp> and return a data structure which has the
249 </p><pre class="verbatim"> <tree>
250 <tree> := <options>
251 data => <tree>
252 where each tree represents an entry in mk-src.in.
253 The following two options are always provided:
254 name: the name of the entry
255 type: the catagory or type name
256 Additional options are the same as specified in %info
258 <a name="MKSrc_003a_003aCreate"></a>
259 <h3 class="section">14.5 MKSrc::Create</h3>
261 <dl compact="compact">
262 <dt><code>create_cc_file PARMS</code></dt>
263 <dd><p>Create a source file.
264 </p><div class="example">
265 <pre class="example"> Required Parms: type, dir, name, data
266 Boolean Parms: header, cxx
267 Optional Parms: namespace (required if cxx), pre_ext,
272 <dt><code>create_file FILENAME DATA</code></dt>
273 <dd><p>Writes DATA to FILENAME but only if DATA differs from the content of
274 the file and the string:
275 </p><div class="example">
276 <pre class="example"> Automatically generated file.
279 <p>is present in the existing file if it already exists.
283 <a name="Code-Generation-Modes"></a>
284 <h3 class="section">14.6 Code Generation Modes</h3>
286 <p>The code generation modes are currently one of the following:
287 </p><div class="example">
288 <pre class="example"> cc: Mode used to create types suitable for C interface
289 cc_cxx: Like cc but typenames don't have a leading Aspell prefix
290 cxx: Mode used to create types suitable for CXX interface
291 native: Mode in which types are suitable for the internal
293 native_no_err: Like Native but with out PosibErr return types
296 <a name="MkSrc_003a_003aCcHelper"></a>
297 <h3 class="section">14.7 MkSrc::CcHelper</h3>
299 <p>Helper functions used by interface generation code:
300 </p><div class="example">
301 <pre class="example"> to_c_return_type ITEM
308 <dl compact="compact">
309 <dt><code>make_func NAME @TYPES PARMS ; %ACCUM</code></dt>
310 <dd><p>Creates a function prototype
312 <p>Parms can be any of:
313 </p><div class="example">
314 <pre class="example"> mode: code generation mode
318 <dt><code>call_func NAME @TYPES PARMS ; %ACCUM</code></dt>
319 <dd><p>Return a string to call a func. Will prefix the function with return
320 if the functions returns a non-void type;
322 <p>Parms can be any of:
323 </p><div class="example">
324 <pre class="example"> mode: code generation mode
328 <dt><code>to_type_name ITEM PARMS ; %ACCUM</code></dt>
329 <dd><p>Converts item into a type name.
331 <p>Parms can be any of:
332 </p><div class="example">
333 <pre class="example"> mode: code generation mode
334 use_type: include the actual type
335 use_name: include the name on the type
336 pos: either "return" or "other"
340 <dt><code>make_desc DESC ; LEVEL</code></dt>
341 <dd><p>Make a C comment out of DESC optionally indenting it LEVEL spaces.
344 <dt><code>make_c_method CLASS ITEM PARMS ; %ACCUM</code></dt>
345 <dd><p>Create the phototype for a C method which is really a function.
348 </p><div class="example">
349 <pre class="example"> mode: code generation mode
350 no_aspell: if true do not include aspell in the name
351 this_name: name for the parameter representing the
356 <dt><code>call_c_method CLASS ITEM PARMS ; %ACCUM</code></dt>
357 <dd><p>Like make_c_method but instead returns the appropriate string to
358 call the function. If the function returns a non-void type the
359 string will be prefixed with a return statement.
362 <dt><code>form_c_method CLASS ITEM PARMS ; %ACCUM</code></dt>
363 <dd><p>Like make_c_method except that it returns the array:
364 </p><div class="example">
365 <pre class="example"> ($func, $data, $parms, $accum)
368 <p>which is suitable for passing into make_func. It will return an
369 empty array if it can not make a method from ITEM.
372 <dt><code>make_cxx_method ITEM PARMS ; %ACCUM</code></dt>
373 <dd><p>Create the phototype for a C++ method.
376 </p><div class="example">
377 <pre class="example"> mode: code generation mode
387 Next: <a href="How-It-All-Works.html#How-It-All-Works" accesskey="n" rel="next">How It All Works</a>, Previous: <a href="Data-Structures.html#Data-Structures" accesskey="p" rel="prev">Data Structures</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>