3 <title>Mk-Src Script - Aspell Developer's Manual</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta name="description" content="Aspell spell checker developer's manual.">
6 <meta name="generator" content="makeinfo 4.8">
7 <link title="Top" rel="start" href="index.html#Top">
8 <link rel="prev" href="Data-Structures.html#Data-Structures" title="Data Structures">
9 <link rel="next" href="How-It-All-Works.html#How-It-All-Works" title="How It All Works">
10 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12 This is the developer's manual for Aspell.
14 Copyright (C) 2002, 2003, 2004, 2006 Kevin Atkinson.
16 Permission is granted to copy, distribute and/or modify this
17 document under the terms of the GNU Free Documentation License,
18 Version 1.1 or any later version published by the Free Software
19 Foundation; with no Invariant Sections, no Front-Cover Texts and
20 no Back-Cover Texts. A copy of the license is included in the
21 section entitled "GNU Free Documentation License".
23 <meta http-equiv="Content-Style-Type" content="text/css">
24 <style type="text/css"><!--
25 pre.display { font-family:inherit }
26 pre.format { font-family:inherit }
27 pre.smalldisplay { font-family:inherit; font-size:smaller }
28 pre.smallformat { font-family:inherit; font-size:smaller }
29 pre.smallexample { font-size:smaller }
30 pre.smalllisp { font-size:smaller }
31 span.sc { font-variant:small-caps }
32 span.roman { font-family:serif; font-weight:normal; }
33 span.sansserif { font-family:sans-serif; font-weight:normal; }
39 <a name="Mk-Src-Script"></a>
40 <a name="Mk_002dSrc-Script"></a>
41 Next: <a rel="next" accesskey="n" href="How-It-All-Works.html#How-It-All-Works">How It All Works</a>,
42 Previous: <a rel="previous" accesskey="p" href="Data-Structures.html#Data-Structures">Data Structures</a>,
43 Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
47 <h2 class="chapter">14 Mk-Src Script</h2>
49 <p>A good deal of interface code is automatically generated by the
50 <samp><span class="file">mk-src.pl</span></samp> Perl script. I am doing it this way to avoid having
51 to write a lot of relative code for the C++ interface. This should
52 also make adding interface for other languages a lot less tedious and
53 will allow the interface to automatically take advantage of new Aspell
54 functionality as it is made available. The <samp><span class="file">mk-src.pl</span></samp> script
55 uses <samp><span class="file">mk-src.in</span></samp> as its input.
57 <h3 class="section">14.1 mk-src.in</h3>
59 <p>NOTE: This section may not always be up to date since it is manually
60 converted from the pod source.
62 <p>The format of <samp><span class="file">mk-src.in</span></samp> is as follows:
64 <pre class="verbatim">
65 The following characters are literals: { } / '\ ' \n = >
68 <items> := (<item>\n)+
69 <items> := <category>:\ <name> {\n<details>\n} | <<tab>><details>
70 <details> := <options>\n /\n <items>
71 <options> := (<option>\n)*
72 <option> := <key> [=> <value>]
74 <<tab>> means everything should be indented by one tab
77 <p>See MkSrc::Info for a description of the categories and options
79 <h3 class="section">14.2 MkSrc::Info</h3>
83 <p>The info array contains information on how to process the info in
84 <samp><span class="file">mk-src.pl</span></samp>. It has the following layout
86 <pre class="verbatim">
87 <catagory> => options => []
88 groups => [] # if undef than anything is accepted
89 creates_type => "" # the object will create a new type
91 proc => <impl type> => sub {}
93 where <impl type> is one of:
94 <pre class="verbatim">
95 cc: for "aspell.h" header file
96 cxx: for C++ interface implemented on top of cc interface
97 native: for creation of header files used internally by aspell
98 impl: for defination of functions declared in cc interface.
99 the definations use the native hedaer files
100 native_impl: for implementations of stuff declared in the native
103 each proc sub should take the following argv
104 <pre class="verbatim">
105 $data: a subtree of $master_data
108 <options> is one of:
109 <pre class="verbatim">
110 desc: description of the object
112 posib err: the method may return an error condition
114 const: the method is a const member
115 c only: only include in the external interface
116 c impl headers: extra headers that need to be included in the C impl
117 c impl: use this as the c impl instead of the default
118 cxx impl: use this as the cxx impl instead of the default
119 returns alt type: the constructor returns some type other than
120 the object from which it is a member of
121 no native: do not attemt to create a native implementation
122 treat as object: treat as a object rather than a pointer
124 The <code>%info</code> structure is initialized as follows:
125 <pre class="verbatim">
130 groups => ['methods', 'group']},
132 # methods is a collection of methods which will be inserted into
133 # a class after some simple substation rules. A $ will be
134 # replaced with name of the class.
135 options => ['strip', 'prefix', 'c impl headers'],
138 # a group is a colection of objects which should be grouped together
139 # this generally means they will be in the same source file
140 options => ['no native'],
141 groups => ['enum', 'struct', 'union', 'func', 'class', 'errors']},
144 options => ['desc', 'prefix'],
145 creates_type => 'enum'},
148 options => ['desc', 'treat as object'],
150 creates_type => 'struct',},
153 options => ['desc', 'treat as object'],
155 creates_type => 'union'},
158 options => ['c impl headers'],
160 creates_type => 'class'},
161 errors => {}, # possible errors
164 options => ['desc', 'posib err', 'c func', 'const',
165 'c only', 'c impl', 'cxx impl'],
168 # A class constructor
169 options => ['returns alt type', 'c impl', 'desc'],
177 In addition to the categories listed above a “methods” category by be
178 specified in under the class category. A “methods” category is created
179 for each methods group under the name “<methods name> methods”. When
180 groups is undefined a type name may be specified in place of a category.
182 <p><code>%types</code>
184 <p>types contains a master list of all types. This includes basic types and
185 ones created in <samp><span class="file">mk-src.in</span></samp>. The basic types include:
186 <pre class="verbatim">
187 'void', 'bool', 'pointer', 'double',
188 'string', 'encoded string', 'string obj',
189 'char', 'unsigned char',
190 'short', 'unsigned short',
191 'int', 'unsigned int',
192 'long', 'unsigned long'
196 <p><code>%methods</code> is used for holding the “methods” information
198 <h3 class="section">14.3 MkSrc::Util</h3>
200 <p>This module contains various useful utility functions:
202 <dt><code>false</code><dd> Returns 0.
204 <br><dt><code>true</code><dd> Returns 1.
206 <br><dt><code>cmap EXPR LIST</code><dd> Apply EXPR to each item in LIST and than concatenate the result into
209 <br><dt><code>one_of STR LIST</code><dd> Returns true if LIST contains at least one of STR.
211 <br><dt><code>to_upper STR</code><dd> Convert STR to all uppercase and substitute spaces with underscores.
213 <br><dt><code>to_lower STR</code><dd> Convert STR to all lowercase and substitute spaces with underscores.
215 <br><dt><code>to_mixed STR</code><dd> Convert STR to mixed case where each new word startes with a
216 uppercase letter. For example "feed me" would become "FeedMe".
219 <h3 class="section">14.4 MkSrc::Read</h3>
222 Read in <samp><span class="file">mk-src.in</span></samp> and return a data structure which has the
224 <pre class="verbatim">
226 <tree> := <options>
228 where each tree represents an entry in mk-src.in.
229 The following two options are always provided:
230 name: the name of the entry
231 type: the catagory or type name
232 Additional options are the same as specified in %info
235 <h3 class="section">14.5 MKSrc::Create</h3>
238 <dt><code>create_cc_file PARMS</code><dd> Create a source file.
239 <pre class="example"> Required Parms: type, dir, name, data
240 Boolean Parms: header, cxx
241 Optional Parms: namespace (required if cxx), pre_ext,
244 <br><dt><code>create_file FILENAME DATA</code><dd> Writes DATA to FILENAME but only if DATA differs from the content of
245 the file and the string:
246 <pre class="example"> Automatically generated file.
248 <p>is present in the existing file if it already exists.
251 <h3 class="section">14.6 Code Generation Modes</h3>
253 <p>The code generation modes are currently one of the following:
254 <pre class="example"> cc: Mode used to create types suitable for C interface
255 cc_cxx: Like cc but typenames don't have a leading Aspell prefix
256 cxx: Mode used to create types suitable for CXX interface
257 native: Mode in which types are suitable for the internal
259 native_no_err: Like Native but with out PosibErr return types
261 <h3 class="section">14.7 MkSrc::CcHelper</h3>
263 <p>Helper functions used by interface generation code:
264 <pre class="example"> to_c_return_type ITEM
271 <dt><code>make_func NAME @TYPES PARMS ; %ACCUM</code><dd> Creates a function prototype
273 <p>Parms can be any of:
274 <pre class="example"> mode: code generation mode
276 <br><dt><code>call_func NAME @TYPES PARMS ; %ACCUM</code><dd> Return a string to call a func. Will prefix the function with return
277 if the functions returns a non-void type;
279 <p>Parms can be any of:
280 <pre class="example"> mode: code generation mode
282 <br><dt><code>to_type_name ITEM PARMS ; %ACCUM</code><dd> Converts item into a type name.
284 <p>Parms can be any of:
285 <pre class="example"> mode: code generation mode
286 use_type: include the actual type
287 use_name: include the name on the type
288 pos: either "return" or "other"
290 <br><dt><code>make_desc DESC ; LEVEL</code><dd> Make a C comment out of DESC optionally indenting it LEVEL spaces.
292 <br><dt><code>make_c_method CLASS ITEM PARMS ; %ACCUM</code><dd> Create the phototype for a C method which is really a function.
295 <pre class="example"> mode: code generation mode
296 no_aspell: if true do not include aspell in the name
297 this_name: name for the parameter representing the
300 <br><dt><code>call_c_method CLASS ITEM PARMS ; %ACCUM</code><dd> Like make_c_method but instead returns the appropriate string to
301 call the function. If the function returns a non-void type the
302 string will be prefixed with a return statement.
304 <br><dt><code>form_c_method CLASS ITEM PARMS ; %ACCUM</code><dd> Like make_c_method except that it returns the array:
305 <pre class="example"> ($func, $data, $parms, $accum)
307 <p>which is suitable for passing into make_func. It will return an
308 empty array if it can not make a method from ITEM.
310 <br><dt><code>make_cxx_method ITEM PARMS ; %ACCUM</code><dd> Create the phototype for a C++ method.
313 <pre class="example"> mode: code generation mode