source: trunk/third/libIDL/libIDL2.texi @ 18251

Revision 18251, 10.2 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18250, which included commits to RCS files with non-trunk default branches.
Line 
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
12Copyright 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
21Copyright @copyright{} 1998, 1999 Andrew T. Veliath
22@end titlepage
23
24@node Top, , , (dir)
25@ifinfo
26This file documents the Interface Definition Language (IDL) parsing
27library, libIDL.
28
29This 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
42libIDL is a library licensed under the GNU LGPL for creating trees of
43CORBA Interface Definition Language (IDL) files, which is a
44specification for defining portable interfaces.  libIDL was initially
45written for ORBit (the ORB from the GNOME project, and the primary
46means of libIDL distribution).  However, the functionality was
47designed to be as reusable and portable as possible.
48
49It is written in C, and the aim is to retain the ability to compile it
50on a system with a standard C compiler.  Preprocessed parser files are
51included so you are not forced to rebuild the parser, however an
52effort is made to keep the parser and lexer compatible with standard
53Unix yacc and lex (although bison and flex are more efficient, and are
54used for the preprocessed parsers in the distribution).
55
56With libIDL, you can parse an IDL file which will be automatically run
57through the C preprocessor (on systems with one available), and have
58detailed error and warning messages displayed.  On a compilation
59without errors, the tree is returned to the custom application.
60libIDL performs compilation phases from lexical analysis to nearly
61full semantic analysis with some optimizations, and will attempt to
62generate meaningful errors and warnings for invalid or deprecated IDL.
63
64libIDL exports functionality used to generate detailed conforming
65error and warning messages in gcc-like format, and also comes with a
66default backend to generate IDL into a file or string (useful for
67customized messages or comments in the output).  The IDL backend is
68complete enough that most generated IDL can be reparsed by libIDL
69without errors. libIDL returns separate syntax and namespace trees,
70and includes functionality to hide syntactical information from the
71primary tree, while keeping it accessible through the namespace for
72type information and name lookup.
73
74Optional extensions to standard IDL can be enabled using parse flags.
75These include node properties, embedded code fragments, and XPIDL.
76Nodes can also have declarations tags which assign particular
77attributions to certain IDL constructs to further facilitate custom
78applications.
79
80@node Example, Reference, Overview, top
81@chapter Usage
82The following C program using libIDL will parse an IDL file and print
83the 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
91gboolean
92print_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
105int
106main (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
149IDL_tree
150
151A semi-opaque tree which encapsulates an IDL tree node.  Must be freed
152with IDL_tree_free (@pxref{Functions}).
153
154@item
155IDL_ns
156
157A semi-opaque structure which encapsulates the IDL module namespace.
158Must be freed with IDL_ns_free (@pxref{Functions}).
159
160@item
161IDL_msg_callback
162
163Defined as typedef int (*IDL_msg_callback)(int LEVEL, int NUM, int LINE,
164const char *NAME, const char *ERR).  A function of this type can be
165optionally passed to IDL_parse_filename to be called when a parse
166warning or error occurs.
167
168@item
169IDL_tree_func
170
171Defined as typedef gboolean (*IDL_tree_func) (IDL_tree_func_data
172*TREE_FUNC_DATA, gpointer DATA).  A function of this type is passed to
173IDL_tree_walk_in_order to traverse the tree.  TREE_FUNC_DATA contains an
174up traversal hierarchy of the current traversal, as well as some state
175information.  The current node being processed is given by
176TREE_FUNC_DATA->tree.
177
178@end itemize
179
180@node Functions, Extensions, Data Types, Reference
181@chapter Functions
182
183@itemize @bullet
184@item
185Function: int IDL_parse_filename (const char *NAME, const char *CPP_ARGS,
186IDL_msg_callback CALLBACK, IDL_tree *TREE, IDL_ns *NS, unsigned long FLAGS,
187int MAX_MESSAGE_LEVEL)
188@findex IDL_parse_filename
189
190Parse an file containing an IDL definition into a parse tree.  Returns
191IDL_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
193returned, all one needs to do is exit with a non-zero status, since
194libIDL will probably have made the reason for failure explictly known.
195
196@itemize @minus
197@item
198NAME: required, specifies the filename to be parsed.
199
200@item
201CPP_ARGS: optional, if non-NULL, specifies extra arguments to pass to
202the C preprocessor.  The most common type of string would be in the form
203of -I<dir> to include additional directories for file inclusion search,
204or defines in the form of -D<define>=<value>.
205
206@item
207CALLBACK: optional, if non-NULL, this function will be called when a
208warning or error is generated (@pxref{Data Types}).  If not given,
209warnings and errors will be sent to stderr.  All errors and warning,
210including callbacks, are subject to MAX_MESSAGE_LEVEL as described
211below.
212
213@item
214TREE: optional, if non-NULL, points to an IDL_tree * to return the
215generated tree which must be freed with IDL_tree_free.  If NULL, the
216tree is freed and not returned.
217
218@item
219NS: optional, if non-NULL, points to an IDL_ns * to return the namespace
220tree which must be freed with IDL_ns_free.  If NULL, the tree is freed
221and not returned.  If TREE is NULL, then NS must also be NULL, since the
222namespace is created as the AST is generated.
223
224@item
225FLAGS: optional, specifies extra flags for parsing or 0.  The various
226flags are described here.
227
228@item
229General Parse Flags
230
231@itemize @minus
232@item
233IDLF_NO_EVAL_CONST: instructs the parser not to evaluate constant expressions.
234
235@item
236IDLF_COMBINE_REOPENED_MODULES: instructs the parser to combine modules
237defined later in the IDL code in the first module node in the tree.
238
239@item
240IDLF_PREFIX_FILENAME: instructs the parser to prefix the filename to the
241namespace.
242
243@item
244IDLF_IGNORE_FORWARDS: instructs the parser to not try to resolve and
245print messages for unresovled forward declarations.
246
247@item
248IDLF_PEDANTIC: instructs the parser to display stricter errors and
249warnings.
250
251@item
252IDLF_INHIBIT_TAG_ONLY: only tag inhibited nodes, do not remove them.
253Use IDL_tree_remove_inhibits to remove them at a later time.
254
255@item
256IDLF_INHIBIT_INCLUDES: causes libIDL to automatically inhibit IDL trees
257in included files.
258@end itemize
259
260@item
261Syntax Extension Flags
262
263@itemize @minus
264@item
265IDLF_TYPECODES: understand the `TypeCode' keyword extension.
266
267@item
268IDLF_XPIDL: enable XPIDL syntax.
269
270@item
271IDLF_PROPERTIES: enable support for node properties.
272
273@item
274IDLF_CODEFRAGS: enable support for embedded code fragments.
275@end itemize
276
277@item
278MAX_MESSAGE_LEVEL:
279
280This specifies the maximum message level to display.  Possible values
281are -1 for no messages, IDL_ERROR for errors only, or IDL_WARNING1,
282IDL_WARNING2 and IDL_WARNING3.  A typical value is IDL_WARNING1, which
283will limit verbosity.  IDL_WARNINGMAX is defined as the value in which
284all messages will be displayed.
285
286@end itemize
287
288@item
289Function: void IDL_tree_walk_in_order (IDL_tree ROOT, IDL_tree_func
290FUNC, gpointer DATA)
291@findex IDL_tree_walk_in_order
292
293Walks an IDL_tree, calling FUNC for every node.  If the FUNC returns
294TRUE for a particular node, that particular node will also be traversed,
295if FALSE is returned, that particular node will be skipped, in the
296assumption that the function has taken care of it.
297
298@itemize @minus
299@item
300ROOT: required, specifies the IDL_tree to traverse.
301
302@item
303FUNC: required, specifies the callback function (@pxref{Data Types}).
304
305@item
306DATA: optional, specifies the callback data.
307
308@end itemize
309
310@item
311Function: void IDL_tree_free (IDL_tree TREE)
312@findex IDL_tree_free
313
314Frees the memory associated with TREE.
315
316@item
317Function: void IDL_ns_free (IDL_ns NS)
318@findex IDL_ns_free
319
320Frees the memory associated with NS.
321
322@end itemize
323
324@node Extensions, Tree Structure, Functions, Reference
325@chapter Extensions
326This page documents extensions to standard IDL which libIDL will
327understand.  To maintain portability, it is recommended that these
328extensions are only used with some sort of C preprocessor define so they
329can be conditionally omitted.
330
331@itemize @bullet
332@item
333__declspec (<spec>)
334
335This token assigns special attributions to particular IDL constructs.
336
337@itemize @minus
338@item
339inhibit
340
341If __declspec (inhibit) is placed before a definition or export, that
342module or interface definition will be removed from the tree.  The tree
343is only deleted when the IDL_ns component is freed, so it can be
344traversed from the namespace component for extended information, but
345will 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
Note: See TracBrowser for help on using the repository browser.