The ic module is an Erlang implementation of an OMG IDL compiler. Depending on the choice of back-end the code will map to Erlang, C, or Java. The compiler generates client stubs and server skeletons.
Two kinds of files are generated for each scope: Ordinary code files and header files. The latter are used for defining record definitions, while the ordinary files contain the object interface functions.
ic:gen(FileName) -> Result
ic:gen(FileName, [Option]) -> Result
Types:
Result = ok | error | {ok, [Warning]} | {error, [Warning], [Error]}
Option = [ GeneralOption | CodeOption | WarningOption | BackendOption]
GeneralOption =
{outdir, String()} | {cfgfile, String()} | {use_preproc, bool()} |
{preproc_cmd, String()} | {preproc_flags, String()}
CodeOption =
{gen_hrl, bool()} | {serv_last_call, exception | exit} | {{impl, String()}, String()} | {light_ifr, bool()}
this | {this, String()} | {{this, String()}, bool()} |
from | {from, String()} | {{from, String()}, bool()} |
handle_info | {handle_info, String()} | {{handle_info, String()}, bool()} |
timeout | {timeout, String()} | {{timeout, String()}, bool()} |
{scoped_op_calls, bool()} | {scl, bool()} |
{user_protocol, Prefix} |
{c_timeout, SendTimeout, RecvTimeout} |
{c_report, bool()} |
{precond, {atom(), atom()}} | {{precond, String()} {atom(), atom()}} |
{postcond, {atom(), atom()}} | {{postcond, String()} {atom(), atom()}}
WarningOption =
{'Wall', bool()} | {maxerrs, int() | infinity} |
{maxwarns, int() | infinity} | {nowarn, bool()} |
{warn_name_shadow, bool()} | {pedantic, bool()} |
{silent, bool()}
BackendOption = {be, Backend}
Backend = erl_corba | erl_template | erl_plain | erl_genserv | c_client | c_server | java
DirNAme = string() | atom()
FileName = string() | atom()
The tuple {Option, true} can be replaced by Option for boolean values.
The ic:gen/2 function can be called from the command line as follows:
erlc "+Option" ... File.idl
Example:
erlc "+{be,c_client}" '+{outdir, "../out"}' File.idl
Which back-end IC will generate code for is determined by the supplied {be,atom()} option. If left out, erl_corba is used. Currently, IC support the following back-ends:
The IDL compiler allows several preprocessors to be used, the Erlang IDL preprocessor or other standard C preprocessors. Options can be used to provide extra flags such as include directories to the preprocessor. The build in the Erlang IDL preprocessor is used by default, but any standard C preprocessor such as gcc is adequate.
The preprocessor command is formed by appending the prepoc_cmd to the preproc_flags option and then appending the input IDL file name.
The compiler can be configured in two ways:
The configuration file is optional and overrides the compiler defaults and is in turn overridden by the command line options. The configuration file shall contain options in the form of Erlang terms. The configuration file is read using file:consult.
An example of a configuration file, note the "." after each line.
{outdir, gen_dir}. {{impl, "M1::M2::object"}, "obj"}.
The compiler will produce output in several files depending on scope declarations found in the IDL file. At most three file types will be generated for each scope (including the top scope), depending on the compiler back-end and the compiled interface. Generally, the output per interface will be a header file (.hrl/ .h) and one or more Erlang/C files (.erl/.c). Please look at the language mapping for each back-end for details.
There will be at least one set of files for an IDL file, for the file level scope. Modules and interfaces also have their own set of generated files.