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