3 NOTE: This section may not always be up to date since it is manually
4 converted from the pod source.
6 The format of @file{mk-src.in} is as follows:
9 The following characters are literals: { } / '\ ' \n = >
12 <items> := (<item>\n)+
13 <items> := <category>:\ <name> {\n<details>\n} | <<tab>><details>
14 <details> := <options>\n /\n <items>
15 <options> := (<option>\n)*
16 <option> := <key> [=> <value>]
18 <<tab>> means everything should be indented by one tab
21 See MkSrc::Info for a description of the categories and options
27 The info array contains information on how to process the info in
28 @file{mk-src.pl}. It has the following layout
31 <catagory> => options => []
32 groups => [] # if undef than anything is accepted
33 creates_type => "" # the object will create a new type
35 proc => <impl type> => sub {}
37 where <impl type> is one of:
39 cc: for "aspell.h" header file
40 cxx: for C++ interface implemented on top of cc interface
41 native: for creation of header files used internally by aspell
42 impl: for defination of functions declared in cc interface.
43 the definations use the native hedaer files
44 native_impl: for implementations of stuff declared in the native
47 each proc sub should take the following argv
49 $data: a subtree of $master_data
54 desc: description of the object
56 posib err: the method may return an error condition
58 const: the method is a const member
59 c only: only include in the external interface
60 c impl headers: extra headers that need to be included in the C impl
61 c impl: use this as the c impl instead of the default
62 cxx impl: use this as the cxx impl instead of the default
63 returns alt type: the constructor returns some type other than
64 the object from which it is a member of
65 no native: do not attemt to create a native implementation
66 treat as object: treat as a object rather than a pointer
68 The @code{%info} structure is initialized as follows:
74 groups => ['methods', 'group']},
76 # methods is a collection of methods which will be inserted into
77 # a class after some simple substation rules. A $ will be
78 # replaced with name of the class.
79 options => ['strip', 'prefix', 'c impl headers'],
82 # a group is a colection of objects which should be grouped together
83 # this generally means they will be in the same source file
84 options => ['no native'],
85 groups => ['enum', 'struct', 'union', 'func', 'class', 'errors']},
88 options => ['desc', 'prefix'],
89 creates_type => 'enum'},
92 options => ['desc', 'treat as object'],
94 creates_type => 'struct',},
97 options => ['desc', 'treat as object'],
99 creates_type => 'union'},
102 options => ['c impl headers'],
104 creates_type => 'class'},
105 errors => {}, # possible errors
108 options => ['desc', 'posib err', 'c func', 'const',
109 'c only', 'c impl', 'cxx impl'],
112 # A class constructor
113 options => ['returns alt type', 'c impl', 'desc'],
121 In addition to the categories listed above a ``methods'' category by be
122 specified in under the class category. A ``methods'' category is created
123 for each methods group under the name ``<methods name> methods''. When
124 groups is undefined a type name may be specified in place of a category.
128 types contains a master list of all types. This includes basic types and
129 ones created in @file{mk-src.in}. The basic types include:
131 'void', 'bool', 'pointer', 'double',
132 'string', 'encoded string', 'string obj',
133 'char', 'unsigned char',
134 'short', 'unsigned short',
135 'int', 'unsigned int',
136 'long', 'unsigned long'
140 @code{%methods} is used for holding the ``methods'' information
144 This module contains various useful utility functions:
153 Apply EXPR to each item in LIST and than concatenate the result into
156 @item one_of STR LIST
157 Returns true if LIST contains at least one of STR.
160 Convert STR to all uppercase and substitute spaces with underscores.
163 Convert STR to all lowercase and substitute spaces with underscores.
166 Convert STR to mixed case where each new word startes with a
167 uppercase letter. For example "feed me" would become "FeedMe".
173 Read in @file{mk-src.in} and return a data structure which has the
179 where each tree represents an entry in mk-src.in.
180 The following two options are always provided:
181 name: the name of the entry
182 type: the catagory or type name
183 Additional options are the same as specified in %info
186 @section MKSrc::Create
189 @item create_cc_file PARMS
190 Create a source file.
192 Required Parms: type, dir, name, data
193 Boolean Parms: header, cxx
194 Optional Parms: namespace (required if cxx), pre_ext,
198 @item create_file FILENAME DATA
199 Writes DATA to FILENAME but only if DATA differs from the content of
200 the file and the string:
202 Automatically generated file.
205 is present in the existing file if it already exists.
208 @section Code Generation Modes
210 The code generation modes are currently one of the following:
212 cc: Mode used to create types suitable for C interface
213 cc_cxx: Like cc but typenames don't have a leading Aspell prefix
214 cxx: Mode used to create types suitable for CXX interface
215 native: Mode in which types are suitable for the internal
217 native_no_err: Like Native but with out PosibErr return types
220 @section MkSrc::CcHelper
222 Helper functions used by interface generation code:
224 to_c_return_type ITEM
232 @item make_func NAME @@TYPES PARMS ; %ACCUM
233 Creates a function prototype
237 mode: code generation mode
240 @item call_func NAME @@TYPES PARMS ; %ACCUM
241 Return a string to call a func. Will prefix the function with return
242 if the functions returns a non-void type;
246 mode: code generation mode
249 @item to_type_name ITEM PARMS ; %ACCUM
250 Converts item into a type name.
254 mode: code generation mode
255 use_type: include the actual type
256 use_name: include the name on the type
257 pos: either "return" or "other"
260 @item make_desc DESC ; LEVEL
261 Make a C comment out of DESC optionally indenting it LEVEL spaces.
263 @item make_c_method CLASS ITEM PARMS ; %ACCUM
264 Create the phototype for a C method which is really a function.
268 mode: code generation mode
269 no_aspell: if true do not include aspell in the name
270 this_name: name for the parameter representing the
274 @item call_c_method CLASS ITEM PARMS ; %ACCUM
275 Like make_c_method but instead returns the appropriate string to
276 call the function. If the function returns a non-void type the
277 string will be prefixed with a return statement.
279 @item form_c_method CLASS ITEM PARMS ; %ACCUM
280 Like make_c_method except that it returns the array:
282 ($func, $data, $parms, $accum)
285 which is suitable for passing into make_func. It will return an
286 empty array if it can not make a method from ITEM.
288 @item make_cxx_method ITEM PARMS ; %ACCUM
289 Create the phototype for a C++ method.
293 mode: code generation mode