summaryrefslogtreecommitdiff
path: root/libIDL2.info
blob: 1cca01b1cf2cb3c1de9118695b37a7dff8105c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
This is libIDL2.info, produced by makeinfo version 4.12 from
libIDL2.texi.

INFO-DIR-SECTION Libraries
START-INFO-DIR-ENTRY
* libIDL2: (libIDL2).     Interface Definition Language parsing library.
END-INFO-DIR-ENTRY

   Copyright 1998 Andrew T. Veliath


File: libIDL2.info,  Node: Top,  Up: (dir)

   This file documents the Interface Definition Language (IDL) parsing
library, libIDL.

   This document applies to version 0.6 of libIDL.  It is still
incomplete.

* Menu:

* Overview::                  General overview.
* Example::                   Simple example.
* Reference::                 Data structure and function reference.

* Function Index::            Index of available functions.


File: libIDL2.info,  Node: Overview,  Next: Example,  Prev: Top,  Up: Top

1 Overview
**********

libIDL is a library licensed under the GNU LGPL for creating trees of
CORBA Interface Definition Language (IDL) files, which is a
specification for defining portable interfaces.  libIDL was initially
written for ORBit (the ORB from the GNOME project, and the primary
means of libIDL distribution).  However, the functionality was designed
to be as reusable and portable as possible.

   It is written in C, and the aim is to retain the ability to compile
it on a system with a standard C compiler.  Preprocessed parser files
are included so you are not forced to rebuild the parser, however an
effort is made to keep the parser and lexer compatible with standard
Unix yacc and lex (although bison and flex are more efficient, and are
used for the preprocessed parsers in the distribution).

   With libIDL, you can parse an IDL file which will be automatically
run through the C preprocessor (on systems with one available), and have
detailed error and warning messages displayed.  On a compilation
without errors, the tree is returned to the custom application.  libIDL
performs compilation phases from lexical analysis to nearly full
semantic analysis with some optimizations, and will attempt to generate
meaningful errors and warnings for invalid or deprecated IDL.

   libIDL exports functionality used to generate detailed conforming
error and warning messages in gcc-like format, and also comes with a
default backend to generate IDL into a file or string (useful for
customized messages or comments in the output).  The IDL backend is
complete enough that most generated IDL can be reparsed by libIDL
without errors. libIDL returns separate syntax and namespace trees, and
includes functionality to hide syntactical information from the primary
tree, while keeping it accessible through the namespace for type
information and name lookup.

   Optional extensions to standard IDL can be enabled using parse flags.
These include node properties, embedded code fragments, and XPIDL.
Nodes can also have declarations tags which assign particular
attributions to certain IDL constructs to further facilitate custom
applications.


File: libIDL2.info,  Node: Example,  Next: Reference,  Prev: Overview,  Up: Top

2 Usage
*******

The following C program using libIDL will parse an IDL file and print
the Repository IDs of the interfaces in the IDL module.

     #include <assert.h>
     #include <stdio.h>
     #include <stdlib.h>
     #include <libIDL/IDL.h>

     gboolean
     print_repo_id (IDL_tree_func_data *tfd, gpointer user_data)
     {
     	char *repo_id = NULL;

     	if (IDL_NODE_TYPE (tfd->tree) == IDLN_INTERFACE)
     		repo_id = IDL_IDENT_REPO_ID (IDL_INTERFACE (tfd->tree).ident);

     	if (repo_id)
     		printf ("%s\n", repo_id);

     	return TRUE;
     }

     int
     main (int argc, char *argv[])
     {
     	IDL_tree tree;
     	IDL_ns ns;
     	char *fn;
     	int rv;

     	if (argc < 2) {
     		fprintf (stderr, "usage: %s <file>\n", argv[0]);
     		exit (1);
     	}
     	fn = argv[1];

     	rv = IDL_parse_filename (fn, NULL, NULL, &tree, &ns, 0, IDL_WARNING1);

     	if (rv == IDL_ERROR || rv < 0) {
     		if (rv < 0)
     			perror (fn);
     		exit (1);
     	}
     	IDL_tree_walk_in_order (tree, print_repo_id, NULL);
     	IDL_ns_free (ns);
     	IDL_tree_free (tree);

     	return 0;
     }


File: libIDL2.info,  Node: Reference,  Next: Function Index,  Prev: Example,  Up: Top

3 Reference
***********

* Menu:

* Data Types::                Constructed data types used.
* Functions::                 Functions provided.
* Extensions::                Extensions provided to standard IDL.
* Tree Structure::            The C IDL tree representation.


File: libIDL2.info,  Node: Data Types,  Next: Functions,  Up: Reference

4 Data Types
************

   * IDL_tree

     A semi-opaque tree which encapsulates an IDL tree node.  Must be
     freed with IDL_tree_free (*note Functions::).

   * IDL_ns

     A semi-opaque structure which encapsulates the IDL module
     namespace.  Must be freed with IDL_ns_free (*note Functions::).

   * IDL_msg_callback

     Defined as typedef int (*IDL_msg_callback)(int LEVEL, int NUM, int
     LINE, const char *NAME, const char *ERR).  A function of this type
     can be optionally passed to IDL_parse_filename to be called when a
     parse warning or error occurs.

   * IDL_tree_func

     Defined as typedef gboolean (*IDL_tree_func) (IDL_tree_func_data
     *TREE_FUNC_DATA, gpointer DATA).  A function of this type is
     passed to IDL_tree_walk_in_order to traverse the tree.
     TREE_FUNC_DATA contains an up traversal hierarchy of the current
     traversal, as well as some state information.  The current node
     being processed is given by TREE_FUNC_DATA->tree.



File: libIDL2.info,  Node: Functions,  Next: Extensions,  Prev: Data Types,  Up: Reference

5 Functions
***********

   * Function: int IDL_parse_filename (const char *NAME, const char
     *CPP_ARGS, IDL_msg_callback CALLBACK, IDL_tree *TREE, IDL_ns *NS,
     unsigned long FLAGS, int MAX_MESSAGE_LEVEL) 

     Parse an file containing an IDL definition into a parse tree.
     Returns IDL_SUCCESS if successful, or IDL_ERROR if there was a
     parse error.  If -1 is returned, errno will be set accordingly.
     Usually, if IDL_ERROR is returned, all one needs to do is exit
     with a non-zero status, since libIDL will probably have made the
     reason for failure explictly known.

        - NAME: required, specifies the filename to be parsed.

        - CPP_ARGS: optional, if non-NULL, specifies extra arguments to
          pass to the C preprocessor.  The most common type of string
          would be in the form of -I<dir> to include additional
          directories for file inclusion search, or defines in the form
          of -D<define>=<value>.

        - CALLBACK: optional, if non-NULL, this function will be called
          when a warning or error is generated (*note Data Types::).
          If not given, warnings and errors will be sent to stderr.
          All errors and warning, including callbacks, are subject to
          MAX_MESSAGE_LEVEL as described below.

        - TREE: optional, if non-NULL, points to an IDL_tree * to
          return the generated tree which must be freed with
          IDL_tree_free.  If NULL, the tree is freed and not returned.

        - NS: optional, if non-NULL, points to an IDL_ns * to return
          the namespace tree which must be freed with IDL_ns_free.  If
          NULL, the tree is freed and not returned.  If TREE is NULL,
          then NS must also be NULL, since the namespace is created as
          the AST is generated.

        - FLAGS: optional, specifies extra flags for parsing or 0.  The
          various flags are described here.

        - General Parse Flags

             - IDLF_NO_EVAL_CONST: instructs the parser not to evaluate
               constant expressions.

             - IDLF_COMBINE_REOPENED_MODULES: instructs the parser to
               combine modules defined later in the IDL code in the
               first module node in the tree.

             - IDLF_PREFIX_FILENAME: instructs the parser to prefix the
               filename to the namespace.

             - IDLF_IGNORE_FORWARDS: instructs the parser to not try to
               resolve and print messages for unresovled forward
               declarations.

             - IDLF_PEDANTIC: instructs the parser to display stricter
               errors and warnings.

             - IDLF_INHIBIT_TAG_ONLY: only tag inhibited nodes, do not
               remove them.  Use IDL_tree_remove_inhibits to remove
               them at a later time.

             - IDLF_INHIBIT_INCLUDES: causes libIDL to automatically
               inhibit IDL trees in included files.

        - Syntax Extension Flags

             - IDLF_TYPECODES: understand the `TypeCode' keyword
               extension.

             - IDLF_XPIDL: enable XPIDL syntax.

             - IDLF_PROPERTIES: enable support for node properties.

             - IDLF_CODEFRAGS: enable support for embedded code
               fragments.

        - MAX_MESSAGE_LEVEL:

          This specifies the maximum message level to display.
          Possible values are -1 for no messages, IDL_ERROR for errors
          only, or IDL_WARNING1, IDL_WARNING2 and IDL_WARNING3.  A
          typical value is IDL_WARNING1, which will limit verbosity.
          IDL_WARNINGMAX is defined as the value in which all messages
          will be displayed.


   * Function: void IDL_tree_walk_in_order (IDL_tree ROOT, IDL_tree_func
     FUNC, gpointer DATA) 

     Walks an IDL_tree, calling FUNC for every node.  If the FUNC
     returns TRUE for a particular node, that particular node will also
     be traversed, if FALSE is returned, that particular node will be
     skipped, in the assumption that the function has taken care of it.

        - ROOT: required, specifies the IDL_tree to traverse.

        - FUNC: required, specifies the callback function (*note Data
          Types::).

        - DATA: optional, specifies the callback data.


   * Function: void IDL_tree_free (IDL_tree TREE) 

     Frees the memory associated with TREE.

   * Function: void IDL_ns_free (IDL_ns NS) 

     Frees the memory associated with NS.



File: libIDL2.info,  Node: Extensions,  Next: Tree Structure,  Prev: Functions,  Up: Reference

6 Extensions
************

This page documents extensions to standard IDL which libIDL will
understand.  To maintain portability, it is recommended that these
extensions are only used with some sort of C preprocessor define so they
can be conditionally omitted.

   * __declspec (<spec>)

     This token assigns special attributions to particular IDL
     constructs.

        - inhibit

          If __declspec (inhibit) is placed before a definition or
          export, that module or interface definition will be removed
          from the tree.  The tree is only deleted when the IDL_ns
          component is freed, so it can be traversed from the namespace
          component for extended information, but will be omitted from
          the primary tree.




File: libIDL2.info,  Node: Tree Structure,  Prev: Extensions,  Up: Reference

7 Tree Structure
****************


File: libIDL2.info,  Node: Function Index,  Prev: Reference,  Up: Top

8 Function Index
****************