1 | \input texinfo @c -*- mode: texinfo -*- |
---|
2 | @setfilename libIDL2.info |
---|
3 | @settitle libIDL2 |
---|
4 | @setchapternewpage odd |
---|
5 | |
---|
6 | @ifinfo |
---|
7 | @dircategory Libraries |
---|
8 | @direntry |
---|
9 | * libIDL2: (libIDL2). Interface Definition Language parsing library. |
---|
10 | @end direntry |
---|
11 | |
---|
12 | Copyright 1998 Andrew T. Veliath |
---|
13 | @end ifinfo |
---|
14 | |
---|
15 | @titlepage |
---|
16 | @title libIDL2 |
---|
17 | @author Andrew T. Veliath |
---|
18 | |
---|
19 | @page |
---|
20 | @vskip 0pt plus 1filll |
---|
21 | Copyright @copyright{} 1998, 1999 Andrew T. Veliath |
---|
22 | @end titlepage |
---|
23 | |
---|
24 | @node Top, , , (dir) |
---|
25 | @ifinfo |
---|
26 | This file documents the Interface Definition Language (IDL) parsing |
---|
27 | library, libIDL. |
---|
28 | |
---|
29 | This document applies to version 0.6 of libIDL. It is still incomplete. |
---|
30 | @end ifinfo |
---|
31 | |
---|
32 | @menu |
---|
33 | * Overview:: General overview. |
---|
34 | * Example:: Simple example. |
---|
35 | * Reference:: Data structure and function reference. |
---|
36 | |
---|
37 | * Function Index:: Index of available functions. |
---|
38 | @end menu |
---|
39 | |
---|
40 | @node Overview, Example, top, top |
---|
41 | @chapter Overview |
---|
42 | libIDL is a library licensed under the GNU LGPL for creating trees of |
---|
43 | CORBA Interface Definition Language (IDL) files, which is a |
---|
44 | specification for defining portable interfaces. libIDL was initially |
---|
45 | written for ORBit (the ORB from the GNOME project, and the primary |
---|
46 | means of libIDL distribution). However, the functionality was |
---|
47 | designed to be as reusable and portable as possible. |
---|
48 | |
---|
49 | It is written in C, and the aim is to retain the ability to compile it |
---|
50 | on a system with a standard C compiler. Preprocessed parser files are |
---|
51 | included so you are not forced to rebuild the parser, however an |
---|
52 | effort is made to keep the parser and lexer compatible with standard |
---|
53 | Unix yacc and lex (although bison and flex are more efficient, and are |
---|
54 | used for the preprocessed parsers in the distribution). |
---|
55 | |
---|
56 | With libIDL, you can parse an IDL file which will be automatically run |
---|
57 | through the C preprocessor (on systems with one available), and have |
---|
58 | detailed error and warning messages displayed. On a compilation |
---|
59 | without errors, the tree is returned to the custom application. |
---|
60 | libIDL performs compilation phases from lexical analysis to nearly |
---|
61 | full semantic analysis with some optimizations, and will attempt to |
---|
62 | generate meaningful errors and warnings for invalid or deprecated IDL. |
---|
63 | |
---|
64 | libIDL exports functionality used to generate detailed conforming |
---|
65 | error and warning messages in gcc-like format, and also comes with a |
---|
66 | default backend to generate IDL into a file or string (useful for |
---|
67 | customized messages or comments in the output). The IDL backend is |
---|
68 | complete enough that most generated IDL can be reparsed by libIDL |
---|
69 | without errors. libIDL returns separate syntax and namespace trees, |
---|
70 | and includes functionality to hide syntactical information from the |
---|
71 | primary tree, while keeping it accessible through the namespace for |
---|
72 | type information and name lookup. |
---|
73 | |
---|
74 | Optional extensions to standard IDL can be enabled using parse flags. |
---|
75 | These include node properties, embedded code fragments, and XPIDL. |
---|
76 | Nodes can also have declarations tags which assign particular |
---|
77 | attributions to certain IDL constructs to further facilitate custom |
---|
78 | applications. |
---|
79 | |
---|
80 | @node Example, Reference, Overview, top |
---|
81 | @chapter Usage |
---|
82 | The following C program using libIDL will parse an IDL file and print |
---|
83 | the Repository IDs of the interfaces in the IDL module. |
---|
84 | |
---|
85 | @example |
---|
86 | #include <assert.h> |
---|
87 | #include <stdio.h> |
---|
88 | #include <stdlib.h> |
---|
89 | #include <libIDL/IDL.h> |
---|
90 | |
---|
91 | gboolean |
---|
92 | print_repo_id (IDL_tree_func_data *tfd, gpointer user_data) |
---|
93 | @{ |
---|
94 | char *repo_id = NULL; |
---|
95 | |
---|
96 | if (IDL_NODE_TYPE (tfd->tree) == IDLN_INTERFACE) |
---|
97 | repo_id = IDL_IDENT_REPO_ID (IDL_INTERFACE (tfd->tree).ident); |
---|
98 | |
---|
99 | if (repo_id) |
---|
100 | printf ("%s\n", repo_id); |
---|
101 | |
---|
102 | return TRUE; |
---|
103 | @} |
---|
104 | |
---|
105 | int |
---|
106 | main (int argc, char *argv[]) |
---|
107 | @{ |
---|
108 | IDL_tree tree; |
---|
109 | IDL_ns ns; |
---|
110 | char *fn; |
---|
111 | int rv; |
---|
112 | |
---|
113 | if (argc < 2) @{ |
---|
114 | fprintf (stderr, "usage: %s <file>\n", argv[0]); |
---|
115 | exit (1); |
---|
116 | @} |
---|
117 | fn = argv[1]; |
---|
118 | |
---|
119 | rv = IDL_parse_filename (fn, NULL, NULL, &tree, &ns, 0, IDL_WARNING1); |
---|
120 | |
---|
121 | if (rv == IDL_ERROR || rv < 0) @{ |
---|
122 | if (rv < 0) |
---|
123 | perror (fn); |
---|
124 | exit (1); |
---|
125 | @} |
---|
126 | IDL_tree_walk_in_order (tree, print_repo_id, NULL); |
---|
127 | IDL_ns_free (ns); |
---|
128 | IDL_tree_free (tree); |
---|
129 | |
---|
130 | return 0; |
---|
131 | @} |
---|
132 | @end example |
---|
133 | |
---|
134 | @node Reference, Function Index, Example, top |
---|
135 | @chapter Reference |
---|
136 | |
---|
137 | @menu |
---|
138 | * Data Types:: Constructed data types used. |
---|
139 | * Functions:: Functions provided. |
---|
140 | * Extensions:: Extensions provided to standard IDL. |
---|
141 | * Tree Structure:: The C IDL tree representation. |
---|
142 | @end menu |
---|
143 | |
---|
144 | @node Data Types, Functions, , Reference |
---|
145 | @chapter Data Types |
---|
146 | |
---|
147 | @itemize @bullet |
---|
148 | @item |
---|
149 | IDL_tree |
---|
150 | |
---|
151 | A semi-opaque tree which encapsulates an IDL tree node. Must be freed |
---|
152 | with IDL_tree_free (@pxref{Functions}). |
---|
153 | |
---|
154 | @item |
---|
155 | IDL_ns |
---|
156 | |
---|
157 | A semi-opaque structure which encapsulates the IDL module namespace. |
---|
158 | Must be freed with IDL_ns_free (@pxref{Functions}). |
---|
159 | |
---|
160 | @item |
---|
161 | IDL_msg_callback |
---|
162 | |
---|
163 | Defined as typedef int (*IDL_msg_callback)(int LEVEL, int NUM, int LINE, |
---|
164 | const char *NAME, const char *ERR). A function of this type can be |
---|
165 | optionally passed to IDL_parse_filename to be called when a parse |
---|
166 | warning or error occurs. |
---|
167 | |
---|
168 | @item |
---|
169 | IDL_tree_func |
---|
170 | |
---|
171 | Defined as typedef gboolean (*IDL_tree_func) (IDL_tree_func_data |
---|
172 | *TREE_FUNC_DATA, gpointer DATA). A function of this type is passed to |
---|
173 | IDL_tree_walk_in_order to traverse the tree. TREE_FUNC_DATA contains an |
---|
174 | up traversal hierarchy of the current traversal, as well as some state |
---|
175 | information. The current node being processed is given by |
---|
176 | TREE_FUNC_DATA->tree. |
---|
177 | |
---|
178 | @end itemize |
---|
179 | |
---|
180 | @node Functions, Extensions, Data Types, Reference |
---|
181 | @chapter Functions |
---|
182 | |
---|
183 | @itemize @bullet |
---|
184 | @item |
---|
185 | Function: int IDL_parse_filename (const char *NAME, const char *CPP_ARGS, |
---|
186 | IDL_msg_callback CALLBACK, IDL_tree *TREE, IDL_ns *NS, unsigned long FLAGS, |
---|
187 | int MAX_MESSAGE_LEVEL) |
---|
188 | @findex IDL_parse_filename |
---|
189 | |
---|
190 | Parse an file containing an IDL definition into a parse tree. Returns |
---|
191 | IDL_SUCCESS if successful, or IDL_ERROR if there was a parse error. If |
---|
192 | -1 is returned, errno will be set accordingly. Usually, if IDL_ERROR is |
---|
193 | returned, all one needs to do is exit with a non-zero status, since |
---|
194 | libIDL will probably have made the reason for failure explictly known. |
---|
195 | |
---|
196 | @itemize @minus |
---|
197 | @item |
---|
198 | NAME: required, specifies the filename to be parsed. |
---|
199 | |
---|
200 | @item |
---|
201 | CPP_ARGS: optional, if non-NULL, specifies extra arguments to pass to |
---|
202 | the C preprocessor. The most common type of string would be in the form |
---|
203 | of -I<dir> to include additional directories for file inclusion search, |
---|
204 | or defines in the form of -D<define>=<value>. |
---|
205 | |
---|
206 | @item |
---|
207 | CALLBACK: optional, if non-NULL, this function will be called when a |
---|
208 | warning or error is generated (@pxref{Data Types}). If not given, |
---|
209 | warnings and errors will be sent to stderr. All errors and warning, |
---|
210 | including callbacks, are subject to MAX_MESSAGE_LEVEL as described |
---|
211 | below. |
---|
212 | |
---|
213 | @item |
---|
214 | TREE: optional, if non-NULL, points to an IDL_tree * to return the |
---|
215 | generated tree which must be freed with IDL_tree_free. If NULL, the |
---|
216 | tree is freed and not returned. |
---|
217 | |
---|
218 | @item |
---|
219 | NS: optional, if non-NULL, points to an IDL_ns * to return the namespace |
---|
220 | tree which must be freed with IDL_ns_free. If NULL, the tree is freed |
---|
221 | and not returned. If TREE is NULL, then NS must also be NULL, since the |
---|
222 | namespace is created as the AST is generated. |
---|
223 | |
---|
224 | @item |
---|
225 | FLAGS: optional, specifies extra flags for parsing or 0. The various |
---|
226 | flags are described here. |
---|
227 | |
---|
228 | @item |
---|
229 | General Parse Flags |
---|
230 | |
---|
231 | @itemize @minus |
---|
232 | @item |
---|
233 | IDLF_NO_EVAL_CONST: instructs the parser not to evaluate constant expressions. |
---|
234 | |
---|
235 | @item |
---|
236 | IDLF_COMBINE_REOPENED_MODULES: instructs the parser to combine modules |
---|
237 | defined later in the IDL code in the first module node in the tree. |
---|
238 | |
---|
239 | @item |
---|
240 | IDLF_PREFIX_FILENAME: instructs the parser to prefix the filename to the |
---|
241 | namespace. |
---|
242 | |
---|
243 | @item |
---|
244 | IDLF_IGNORE_FORWARDS: instructs the parser to not try to resolve and |
---|
245 | print messages for unresovled forward declarations. |
---|
246 | |
---|
247 | @item |
---|
248 | IDLF_PEDANTIC: instructs the parser to display stricter errors and |
---|
249 | warnings. |
---|
250 | |
---|
251 | @item |
---|
252 | IDLF_INHIBIT_TAG_ONLY: only tag inhibited nodes, do not remove them. |
---|
253 | Use IDL_tree_remove_inhibits to remove them at a later time. |
---|
254 | |
---|
255 | @item |
---|
256 | IDLF_INHIBIT_INCLUDES: causes libIDL to automatically inhibit IDL trees |
---|
257 | in included files. |
---|
258 | @end itemize |
---|
259 | |
---|
260 | @item |
---|
261 | Syntax Extension Flags |
---|
262 | |
---|
263 | @itemize @minus |
---|
264 | @item |
---|
265 | IDLF_TYPECODES: understand the `TypeCode' keyword extension. |
---|
266 | |
---|
267 | @item |
---|
268 | IDLF_XPIDL: enable XPIDL syntax. |
---|
269 | |
---|
270 | @item |
---|
271 | IDLF_PROPERTIES: enable support for node properties. |
---|
272 | |
---|
273 | @item |
---|
274 | IDLF_CODEFRAGS: enable support for embedded code fragments. |
---|
275 | @end itemize |
---|
276 | |
---|
277 | @item |
---|
278 | MAX_MESSAGE_LEVEL: |
---|
279 | |
---|
280 | This specifies the maximum message level to display. Possible values |
---|
281 | are -1 for no messages, IDL_ERROR for errors only, or IDL_WARNING1, |
---|
282 | IDL_WARNING2 and IDL_WARNING3. A typical value is IDL_WARNING1, which |
---|
283 | will limit verbosity. IDL_WARNINGMAX is defined as the value in which |
---|
284 | all messages will be displayed. |
---|
285 | |
---|
286 | @end itemize |
---|
287 | |
---|
288 | @item |
---|
289 | Function: void IDL_tree_walk_in_order (IDL_tree ROOT, IDL_tree_func |
---|
290 | FUNC, gpointer DATA) |
---|
291 | @findex IDL_tree_walk_in_order |
---|
292 | |
---|
293 | Walks an IDL_tree, calling FUNC for every node. If the FUNC returns |
---|
294 | TRUE for a particular node, that particular node will also be traversed, |
---|
295 | if FALSE is returned, that particular node will be skipped, in the |
---|
296 | assumption that the function has taken care of it. |
---|
297 | |
---|
298 | @itemize @minus |
---|
299 | @item |
---|
300 | ROOT: required, specifies the IDL_tree to traverse. |
---|
301 | |
---|
302 | @item |
---|
303 | FUNC: required, specifies the callback function (@pxref{Data Types}). |
---|
304 | |
---|
305 | @item |
---|
306 | DATA: optional, specifies the callback data. |
---|
307 | |
---|
308 | @end itemize |
---|
309 | |
---|
310 | @item |
---|
311 | Function: void IDL_tree_free (IDL_tree TREE) |
---|
312 | @findex IDL_tree_free |
---|
313 | |
---|
314 | Frees the memory associated with TREE. |
---|
315 | |
---|
316 | @item |
---|
317 | Function: void IDL_ns_free (IDL_ns NS) |
---|
318 | @findex IDL_ns_free |
---|
319 | |
---|
320 | Frees the memory associated with NS. |
---|
321 | |
---|
322 | @end itemize |
---|
323 | |
---|
324 | @node Extensions, Tree Structure, Functions, Reference |
---|
325 | @chapter Extensions |
---|
326 | This page documents extensions to standard IDL which libIDL will |
---|
327 | understand. To maintain portability, it is recommended that these |
---|
328 | extensions are only used with some sort of C preprocessor define so they |
---|
329 | can be conditionally omitted. |
---|
330 | |
---|
331 | @itemize @bullet |
---|
332 | @item |
---|
333 | __declspec (<spec>) |
---|
334 | |
---|
335 | This token assigns special attributions to particular IDL constructs. |
---|
336 | |
---|
337 | @itemize @minus |
---|
338 | @item |
---|
339 | inhibit |
---|
340 | |
---|
341 | If __declspec (inhibit) is placed before a definition or export, that |
---|
342 | module or interface definition will be removed from the tree. The tree |
---|
343 | is only deleted when the IDL_ns component is freed, so it can be |
---|
344 | traversed from the namespace component for extended information, but |
---|
345 | will be omitted from the primary tree. |
---|
346 | |
---|
347 | @end itemize |
---|
348 | |
---|
349 | @end itemize |
---|
350 | |
---|
351 | @node Tree Structure, , Extensions, Reference |
---|
352 | @chapter Tree Structure |
---|
353 | |
---|
354 | @node Function Index, , Reference, top |
---|
355 | @chapter Function Index |
---|
356 | @printindex fn |
---|
357 | |
---|
358 | @contents |
---|
359 | @bye |
---|