<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">

<chapter>
  <header>
    <copyright>
      <year>1998</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
 
          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    
    </legalnotice>

    <title>Using the IC Compiler</title>
    <prepared></prepared>
    <docno></docno>
    <date>2002-08-02</date>
    <rev>PB1</rev>
    <file>ch_introduction.xml</file>
  </header>

  <section>
    <title>Introduction</title>
    <p>The IC application is an IDL compiler implemented in Erlang.
      The IDL compiler generates client stubs and server skeletons.
      Several back-ends are supported, and they fall into three main
      groups.</p>
    <p>The first group consists of a CORBA back-end:</p>
    <taglist>
      <tag>IDL to Erlang CORBA</tag>
      <item>
        <p>This back-end is for CORBA communication and implementation,
          and the generated code uses the CORBA specific protocol for
          communication between clients and servers. See the
          <em>Orber</em> application User's Guide and manuals for
          further details.</p>
      </item>
    </taglist>
    <p>The second group consists of a simple Erlang back-end:</p>
    <taglist>
      <tag>IDL to plain Erlang</tag>
      <item>
        <p>This back-end provides a very simple Erlang client
          interface. It can only be used within an Erlang node,
          and the communication between client and "server" is
          therefore in terms of ordinary function calls. </p>
        <p>This back-end can be considered a short-circuit version of
          the IDL to Erlang gen_server back-end (see further below).</p>
      </item>
    </taglist>
    <p>The third group consists of backends for Erlang, C, and
      Java. The communication between clients and servers is by the
      Erlang distribution protocol, facilitated by
      <em>erl_interface</em> and <em>jinterface</em> for C and Java,
      respectively.</p>
    <p>All back-ends of the third group generate code compatible with
      the Erlang gen_server behavior protocol. Thus generated client
      code corresponds to <c>call()</c> or <c>cast()</c> of an Erlang
      <c>gen_server</c>. Similarly, generated server code corresponds
      to <c>handle_call()</c> or <c>handle_cast()</c> of an Erlang
      <c>gen_server</c>.</p>
    <p>The back-ends of the third group are:
      </p>
    <taglist>
      <tag>IDL to Erlang gen_server</tag>
      <item>
        <p>Client stubs and server skeletons are generated. Data types
          are mapped according to the IDL to Erlang mapping described
          in the <em>Orber User's Guide</em>.</p>
        <p></p>
      </item>
      <tag>IDL to C client</tag>
      <item>
        <p>Client stubs are generated. The mapping of data types is
          described further on in the C client part of this guide.</p>
      </item>
      <tag>IDL to C server</tag>
      <item>
        <p>Server skeletons are generated. The mapping of data types is
          described further on in the C server part of this guide.</p>
      </item>
      <tag>IDL to Java</tag>
      <item>
        <p>Client stubs and server skeletons are generated. The mapping
          of data types is described further on in the Java part of
          this guide.</p>
      </item>
    </taglist>
  </section>

  <section>
    <title>Compilation of IDL Files</title>
    <p>The IC compiler is invoked by executing the generic <c>erlc</c>
      compiler from a shell:</p>
    <code type="none">
%> erlc +'{be,BackEnd}' File.idl
    </code>
    <p>where <c>BackEnd</c> is according to the table below, and
      <c>File.idl</c> is the IDL file to be compiled.</p>
    <table>
      <row>
        <cell align="left" valign="middle"><em>Back-end</em></cell>
        <cell align="left" valign="middle"><c>BackEnd</c>option</cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to CORBA</cell>
        <cell align="left" valign="middle"><c>erl_corba</c></cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to CORBA template</cell>
        <cell align="left" valign="middle"><c>erl_template</c></cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to plain Erlang</cell>
        <cell align="left" valign="middle"><c>erl_plain</c></cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to Erlang gen_server</cell>
        <cell align="left" valign="middle"><c>erl_genserv</c></cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to C client</cell>
        <cell align="left" valign="middle"><c>c_client</c></cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to C server</cell>
        <cell align="left" valign="middle"><c>c_server</c></cell>
      </row>
      <row>
        <cell align="left" valign="middle">IDL to Java</cell>
        <cell align="left" valign="middle"><c>java</c></cell>
      </row>
      <tcaption>Compiler back-ends and options</tcaption>
    </table>
    <p>For more details on IC compiler options consult the ic(3) manual page.</p>
  </section>
</chapter>

