Blame libIDL2.texi

Packit 4a5d52
\input texinfo @c -*- mode: texinfo -*-
Packit 4a5d52
@setfilename libIDL2.info
Packit 4a5d52
@settitle libIDL2
Packit 4a5d52
@setchapternewpage odd
Packit 4a5d52
Packit 4a5d52
@ifinfo
Packit 4a5d52
@dircategory Libraries
Packit 4a5d52
@direntry
Packit 4a5d52
* libIDL2: (libIDL2).     Interface Definition Language parsing library.
Packit 4a5d52
@end direntry
Packit 4a5d52
Packit 4a5d52
Copyright 1998 Andrew T. Veliath
Packit 4a5d52
@end ifinfo
Packit 4a5d52
Packit 4a5d52
@titlepage
Packit 4a5d52
@title libIDL2
Packit 4a5d52
@author Andrew T. Veliath
Packit 4a5d52
Packit 4a5d52
@page
Packit 4a5d52
@vskip 0pt plus 1filll
Packit 4a5d52
Copyright @copyright{} 1998, 1999 Andrew T. Veliath
Packit 4a5d52
@end titlepage
Packit 4a5d52
Packit 4a5d52
@node Top, , , (dir)
Packit 4a5d52
@ifinfo
Packit 4a5d52
This file documents the Interface Definition Language (IDL) parsing
Packit 4a5d52
library, libIDL.
Packit 4a5d52
Packit 4a5d52
This document applies to version 0.6 of libIDL.  It is still incomplete.
Packit 4a5d52
@end ifinfo
Packit 4a5d52
Packit 4a5d52
@menu
Packit 4a5d52
* Overview::                  General overview.
Packit 4a5d52
* Example::                   Simple example.
Packit 4a5d52
* Reference::                 Data structure and function reference.
Packit 4a5d52
Packit 4a5d52
* Function Index::            Index of available functions.
Packit 4a5d52
@end menu
Packit 4a5d52
Packit 4a5d52
@node Overview, Example, top, top
Packit 4a5d52
@chapter Overview
Packit 4a5d52
libIDL is a library licensed under the GNU LGPL for creating trees of
Packit 4a5d52
CORBA Interface Definition Language (IDL) files, which is a
Packit 4a5d52
specification for defining portable interfaces.  libIDL was initially
Packit 4a5d52
written for ORBit (the ORB from the GNOME project, and the primary
Packit 4a5d52
means of libIDL distribution).  However, the functionality was
Packit 4a5d52
designed to be as reusable and portable as possible.
Packit 4a5d52
Packit 4a5d52
It is written in C, and the aim is to retain the ability to compile it
Packit 4a5d52
on a system with a standard C compiler.  Preprocessed parser files are
Packit 4a5d52
included so you are not forced to rebuild the parser, however an
Packit 4a5d52
effort is made to keep the parser and lexer compatible with standard
Packit 4a5d52
Unix yacc and lex (although bison and flex are more efficient, and are
Packit 4a5d52
used for the preprocessed parsers in the distribution).
Packit 4a5d52
Packit 4a5d52
With libIDL, you can parse an IDL file which will be automatically run
Packit 4a5d52
through the C preprocessor (on systems with one available), and have
Packit 4a5d52
detailed error and warning messages displayed.  On a compilation
Packit 4a5d52
without errors, the tree is returned to the custom application.
Packit 4a5d52
libIDL performs compilation phases from lexical analysis to nearly
Packit 4a5d52
full semantic analysis with some optimizations, and will attempt to
Packit 4a5d52
generate meaningful errors and warnings for invalid or deprecated IDL.
Packit 4a5d52
Packit 4a5d52
libIDL exports functionality used to generate detailed conforming
Packit 4a5d52
error and warning messages in gcc-like format, and also comes with a
Packit 4a5d52
default backend to generate IDL into a file or string (useful for
Packit 4a5d52
customized messages or comments in the output).  The IDL backend is
Packit 4a5d52
complete enough that most generated IDL can be reparsed by libIDL
Packit 4a5d52
without errors. libIDL returns separate syntax and namespace trees,
Packit 4a5d52
and includes functionality to hide syntactical information from the
Packit 4a5d52
primary tree, while keeping it accessible through the namespace for
Packit 4a5d52
type information and name lookup.
Packit 4a5d52
Packit 4a5d52
Optional extensions to standard IDL can be enabled using parse flags.
Packit 4a5d52
These include node properties, embedded code fragments, and XPIDL.
Packit 4a5d52
Nodes can also have declarations tags which assign particular
Packit 4a5d52
attributions to certain IDL constructs to further facilitate custom
Packit 4a5d52
applications.
Packit 4a5d52
Packit 4a5d52
@node Example, Reference, Overview, top
Packit 4a5d52
@chapter Usage
Packit 4a5d52
The following C program using libIDL will parse an IDL file and print
Packit 4a5d52
the Repository IDs of the interfaces in the IDL module.
Packit 4a5d52
Packit 4a5d52
@example
Packit 4a5d52
#include <assert.h>
Packit 4a5d52
#include <stdio.h>
Packit 4a5d52
#include <stdlib.h>
Packit 4a5d52
#include <libIDL/IDL.h>
Packit 4a5d52
Packit 4a5d52
gboolean
Packit 4a5d52
print_repo_id (IDL_tree_func_data *tfd, gpointer user_data)
Packit 4a5d52
@{
Packit 4a5d52
	char *repo_id = NULL;
Packit 4a5d52
Packit 4a5d52
	if (IDL_NODE_TYPE (tfd->tree) == IDLN_INTERFACE)
Packit 4a5d52
		repo_id = IDL_IDENT_REPO_ID (IDL_INTERFACE (tfd->tree).ident);
Packit 4a5d52
Packit 4a5d52
	if (repo_id)
Packit 4a5d52
		printf ("%s\n", repo_id);
Packit 4a5d52
Packit 4a5d52
	return TRUE;
Packit 4a5d52
@}
Packit 4a5d52
Packit 4a5d52
int 
Packit 4a5d52
main (int argc, char *argv[])
Packit 4a5d52
@{
Packit 4a5d52
	IDL_tree tree;
Packit 4a5d52
	IDL_ns ns;
Packit 4a5d52
	char *fn;
Packit 4a5d52
	int rv;
Packit 4a5d52
Packit 4a5d52
	if (argc < 2) @{
Packit 4a5d52
		fprintf (stderr, "usage: %s <file>\n", argv[0]);
Packit 4a5d52
		exit (1);
Packit 4a5d52
	@}
Packit 4a5d52
	fn = argv[1];
Packit 4a5d52
Packit 4a5d52
	rv = IDL_parse_filename (fn, NULL, NULL, &tree, &ns, 0, IDL_WARNING1);
Packit 4a5d52
Packit 4a5d52
	if (rv == IDL_ERROR || rv < 0) @{
Packit 4a5d52
		if (rv < 0)
Packit 4a5d52
			perror (fn);
Packit 4a5d52
		exit (1);
Packit 4a5d52
	@}
Packit 4a5d52
	IDL_tree_walk_in_order (tree, print_repo_id, NULL);
Packit 4a5d52
	IDL_ns_free (ns);
Packit 4a5d52
	IDL_tree_free (tree);
Packit 4a5d52
Packit 4a5d52
	return 0;
Packit 4a5d52
@}
Packit 4a5d52
@end example
Packit 4a5d52
Packit 4a5d52
@node Reference, Function Index, Example, top
Packit 4a5d52
@chapter Reference
Packit 4a5d52
Packit 4a5d52
@menu
Packit 4a5d52
* Data Types::                Constructed data types used.
Packit 4a5d52
* Functions::                 Functions provided.
Packit 4a5d52
* Extensions::                Extensions provided to standard IDL.
Packit 4a5d52
* Tree Structure::            The C IDL tree representation.
Packit 4a5d52
@end menu
Packit 4a5d52
Packit 4a5d52
@node Data Types, Functions, , Reference
Packit 4a5d52
@chapter Data Types
Packit 4a5d52
Packit 4a5d52
@itemize @bullet
Packit 4a5d52
@item
Packit 4a5d52
IDL_tree
Packit 4a5d52
Packit 4a5d52
A semi-opaque tree which encapsulates an IDL tree node.  Must be freed
Packit 4a5d52
with IDL_tree_free (@pxref{Functions}).
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDL_ns
Packit 4a5d52
Packit 4a5d52
A semi-opaque structure which encapsulates the IDL module namespace.
Packit 4a5d52
Must be freed with IDL_ns_free (@pxref{Functions}).
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDL_msg_callback
Packit 4a5d52
Packit 4a5d52
Defined as typedef int (*IDL_msg_callback)(int LEVEL, int NUM, int LINE,
Packit 4a5d52
const char *NAME, const char *ERR).  A function of this type can be
Packit 4a5d52
optionally passed to IDL_parse_filename to be called when a parse
Packit 4a5d52
warning or error occurs.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDL_tree_func
Packit 4a5d52
Packit 4a5d52
Defined as typedef gboolean (*IDL_tree_func) (IDL_tree_func_data
Packit 4a5d52
*TREE_FUNC_DATA, gpointer DATA).  A function of this type is passed to
Packit 4a5d52
IDL_tree_walk_in_order to traverse the tree.  TREE_FUNC_DATA contains an
Packit 4a5d52
up traversal hierarchy of the current traversal, as well as some state
Packit 4a5d52
information.  The current node being processed is given by
Packit 4a5d52
TREE_FUNC_DATA->tree.
Packit 4a5d52
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@node Functions, Extensions, Data Types, Reference
Packit 4a5d52
@chapter Functions
Packit 4a5d52
Packit 4a5d52
@itemize @bullet
Packit 4a5d52
@item
Packit 4a5d52
Function: int IDL_parse_filename (const char *NAME, const char *CPP_ARGS,
Packit 4a5d52
IDL_msg_callback CALLBACK, IDL_tree *TREE, IDL_ns *NS, unsigned long FLAGS,
Packit 4a5d52
int MAX_MESSAGE_LEVEL)
Packit 4a5d52
@findex IDL_parse_filename
Packit 4a5d52
Packit 4a5d52
Parse an file containing an IDL definition into a parse tree.  Returns
Packit 4a5d52
IDL_SUCCESS if successful, or IDL_ERROR if there was a parse error.  If
Packit 4a5d52
-1 is returned, errno will be set accordingly.  Usually, if IDL_ERROR is
Packit 4a5d52
returned, all one needs to do is exit with a non-zero status, since
Packit 4a5d52
libIDL will probably have made the reason for failure explictly known.
Packit 4a5d52
Packit 4a5d52
@itemize @minus
Packit 4a5d52
@item
Packit 4a5d52
NAME: required, specifies the filename to be parsed.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
CPP_ARGS: optional, if non-NULL, specifies extra arguments to pass to
Packit 4a5d52
the C preprocessor.  The most common type of string would be in the form
Packit 4a5d52
of -I<dir> to include additional directories for file inclusion search,
Packit 4a5d52
or defines in the form of -D<define>=<value>.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
CALLBACK: optional, if non-NULL, this function will be called when a
Packit 4a5d52
warning or error is generated (@pxref{Data Types}).  If not given,
Packit 4a5d52
warnings and errors will be sent to stderr.  All errors and warning,
Packit 4a5d52
including callbacks, are subject to MAX_MESSAGE_LEVEL as described
Packit 4a5d52
below.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
TREE: optional, if non-NULL, points to an IDL_tree * to return the
Packit 4a5d52
generated tree which must be freed with IDL_tree_free.  If NULL, the
Packit 4a5d52
tree is freed and not returned.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
NS: optional, if non-NULL, points to an IDL_ns * to return the namespace
Packit 4a5d52
tree which must be freed with IDL_ns_free.  If NULL, the tree is freed
Packit 4a5d52
and not returned.  If TREE is NULL, then NS must also be NULL, since the
Packit 4a5d52
namespace is created as the AST is generated.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
FLAGS: optional, specifies extra flags for parsing or 0.  The various
Packit 4a5d52
flags are described here.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
General Parse Flags
Packit 4a5d52
Packit 4a5d52
@itemize @minus
Packit 4a5d52
@item
Packit 4a5d52
IDLF_NO_EVAL_CONST: instructs the parser not to evaluate constant expressions.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_COMBINE_REOPENED_MODULES: instructs the parser to combine modules
Packit 4a5d52
defined later in the IDL code in the first module node in the tree.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_PREFIX_FILENAME: instructs the parser to prefix the filename to the
Packit 4a5d52
namespace.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_IGNORE_FORWARDS: instructs the parser to not try to resolve and
Packit 4a5d52
print messages for unresovled forward declarations.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_PEDANTIC: instructs the parser to display stricter errors and
Packit 4a5d52
warnings.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_INHIBIT_TAG_ONLY: only tag inhibited nodes, do not remove them.
Packit 4a5d52
Use IDL_tree_remove_inhibits to remove them at a later time.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_INHIBIT_INCLUDES: causes libIDL to automatically inhibit IDL trees
Packit 4a5d52
in included files.
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
Syntax Extension Flags
Packit 4a5d52
Packit 4a5d52
@itemize @minus
Packit 4a5d52
@item
Packit 4a5d52
IDLF_TYPECODES: understand the `TypeCode' keyword extension.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_XPIDL: enable XPIDL syntax.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_PROPERTIES: enable support for node properties.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
IDLF_CODEFRAGS: enable support for embedded code fragments.
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
MAX_MESSAGE_LEVEL:
Packit 4a5d52
Packit 4a5d52
This specifies the maximum message level to display.  Possible values
Packit 4a5d52
are -1 for no messages, IDL_ERROR for errors only, or IDL_WARNING1,
Packit 4a5d52
IDL_WARNING2 and IDL_WARNING3.  A typical value is IDL_WARNING1, which
Packit 4a5d52
will limit verbosity.  IDL_WARNINGMAX is defined as the value in which
Packit 4a5d52
all messages will be displayed.
Packit 4a5d52
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
Function: void IDL_tree_walk_in_order (IDL_tree ROOT, IDL_tree_func
Packit 4a5d52
FUNC, gpointer DATA)
Packit 4a5d52
@findex IDL_tree_walk_in_order
Packit 4a5d52
Packit 4a5d52
Walks an IDL_tree, calling FUNC for every node.  If the FUNC returns
Packit 4a5d52
TRUE for a particular node, that particular node will also be traversed,
Packit 4a5d52
if FALSE is returned, that particular node will be skipped, in the
Packit 4a5d52
assumption that the function has taken care of it.
Packit 4a5d52
Packit 4a5d52
@itemize @minus
Packit 4a5d52
@item
Packit 4a5d52
ROOT: required, specifies the IDL_tree to traverse.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
FUNC: required, specifies the callback function (@pxref{Data Types}).
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
DATA: optional, specifies the callback data.
Packit 4a5d52
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
Function: void IDL_tree_free (IDL_tree TREE)
Packit 4a5d52
@findex IDL_tree_free
Packit 4a5d52
Packit 4a5d52
Frees the memory associated with TREE.
Packit 4a5d52
Packit 4a5d52
@item
Packit 4a5d52
Function: void IDL_ns_free (IDL_ns NS)
Packit 4a5d52
@findex IDL_ns_free
Packit 4a5d52
Packit 4a5d52
Frees the memory associated with NS.
Packit 4a5d52
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@node Extensions, Tree Structure, Functions, Reference
Packit 4a5d52
@chapter Extensions
Packit 4a5d52
This page documents extensions to standard IDL which libIDL will
Packit 4a5d52
understand.  To maintain portability, it is recommended that these
Packit 4a5d52
extensions are only used with some sort of C preprocessor define so they
Packit 4a5d52
can be conditionally omitted.
Packit 4a5d52
Packit 4a5d52
@itemize @bullet
Packit 4a5d52
@item
Packit 4a5d52
__declspec (<spec>)
Packit 4a5d52
Packit 4a5d52
This token assigns special attributions to particular IDL constructs.
Packit 4a5d52
Packit 4a5d52
@itemize @minus
Packit 4a5d52
@item
Packit 4a5d52
inhibit
Packit 4a5d52
Packit 4a5d52
If __declspec (inhibit) is placed before a definition or export, that
Packit 4a5d52
module or interface definition will be removed from the tree.  The tree
Packit 4a5d52
is only deleted when the IDL_ns component is freed, so it can be
Packit 4a5d52
traversed from the namespace component for extended information, but
Packit 4a5d52
will be omitted from the primary tree.
Packit 4a5d52
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@end itemize
Packit 4a5d52
Packit 4a5d52
@node Tree Structure, , Extensions, Reference
Packit 4a5d52
@chapter Tree Structure
Packit 4a5d52
Packit 4a5d52
@node Function Index, , Reference, top
Packit 4a5d52
@chapter Function Index
Packit 4a5d52
@printindex fn
Packit 4a5d52
Packit 4a5d52
@contents
Packit 4a5d52
@bye