aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ic/doc/src/ch_c_mapping.xml
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/ic/doc/src/ch_c_mapping.xml
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/ic/doc/src/ch_c_mapping.xml')
-rw-r--r--lib/ic/doc/src/ch_c_mapping.xml892
1 files changed, 892 insertions, 0 deletions
diff --git a/lib/ic/doc/src/ch_c_mapping.xml b/lib/ic/doc/src/ch_c_mapping.xml
new file mode 100644
index 0000000000..58b026ee78
--- /dev/null
+++ b/lib/ic/doc/src/ch_c_mapping.xml
@@ -0,0 +1,892 @@
+<?xml version="1.0" encoding="latin1" ?>
+<!DOCTYPE chapter SYSTEM "chapter.dtd">
+
+<chapter>
+ <header>
+ <copyright>
+ <year>1998</year><year>2009</year>
+ <holder>Ericsson AB. All Rights Reserved.</holder>
+ </copyright>
+ <legalnotice>
+ The contents of this file are subject to the Erlang Public License,
+ Version 1.1, (the "License"); you may not use this file except in
+ compliance with the License. You should have received a copy of the
+ Erlang Public License along with this software. If not, it can be
+ retrieved online at http://www.erlang.org/.
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ the License for the specific language governing rights and limitations
+ under the License.
+
+ </legalnotice>
+
+ <title>IDL to C mapping</title>
+ <prepared></prepared>
+ <docno></docno>
+ <date>2002-08-06</date>
+ <rev>PB1</rev>
+ <file>ch_c_mapping.xml</file>
+ </header>
+
+ <section>
+ <title>Introduction</title>
+ <p>The IC C mapping (used by the C client and C server back-ends) follows
+ the <em>OMG C Language Mapping Specification</em>. </p>
+ <p>The C mapping supports the following:</p>
+ <list type="bulleted">
+ <item>
+ <p>All OMG IDL basic types except <c>long double</c> and <c>any</c>.</p>
+ </item>
+ <item>
+ <p>All OMG IDL constructed types.</p>
+ </item>
+ <item>
+ <p>OMG IDL constants.</p>
+ </item>
+ <item>
+ <p>Operations with passing of parameters and receiving of
+ results. <c>inout</c> parameters are not supported.</p>
+ </item>
+ </list>
+ <p>The following is not supported:
+ </p>
+ <list type="bulleted">
+ <item>
+ <p>Access to attributes.</p>
+ </item>
+ <item>
+ <p>User defined exceptions.</p>
+ <p></p>
+ </item>
+ <item>
+ <p>User defined objects.</p>
+ <p></p>
+ </item>
+ </list>
+ </section>
+
+ <section>
+ <title>C Mapping Characteristics</title>
+
+ <section>
+ <title>Reserved Names</title>
+ <p>The IDL compiler reserves all identifiers starting with
+ <c>OE_</c> and <c>oe_</c> for internal use.</p>
+ </section>
+
+ <section>
+ <title>Scoped Names</title>
+ <p>The C programmer must always use the global name for a type,
+ constant or operation. The C global name corresponding to an
+ OMG IDL global name is derived by converting occurrences of
+ "::" to underscore, and eliminating the leading "::". So, for
+ example, an operation <c>op1</c> defined in interface
+ <c>I1</c> which is defined in module <c>M1</c> would be
+ written as <c>M1::I1::op1</c> in IDL and as <c>M1_I1_op1</c>
+ in C.</p>
+ <warning>
+ <p>If underscores are used in IDL names it can lead to
+ ambiguities due to the name mapping described above,
+ therefore it is advisable to avoid underscores in
+ identifiers.</p>
+ </warning>
+ </section>
+
+ <section>
+ <title>Generated Files</title>
+ <p>Two files will be generated for each scope. One set of files
+ will be generated for each module and each interface scope.
+ An extra set is generated for those definitions at top
+ level scope. One of the files is a header file(<c>.h</c>), and the
+ other file is a C source code file (<c>.c</c>). In addition to these
+ files a number of C source files will be generated for type encodings,
+ they are named according to the following template:
+ <c><![CDATA[oe_code_<type>.c]]></c>.</p>
+ <p>For example:</p>
+ <code type="none"><![CDATA[
+// IDL, in the file "spec.idl"
+module m1 {
+
+ typedef sequence<long> lseq;
+
+ interface i1 {
+ ...
+ };
+ ...
+};
+ ]]></code>
+ <p>XXX This is C client specific.
+ Will produce the files <c>oe_spec.h</c> and
+ <c>oe_spec.c</c> for the top scope level. Then the files
+ <c>m1.h</c> and <c>m1.c</c> for the module <c>m1</c> and
+ files <c>m1_i1.h</c> and <c>m1_i1.c</c> for the interface
+ <c>i1</c>. The typedef will produce <c>oe_code_m1_lseq.c</c>.</p>
+ <p>The header file contains type definitions for all
+ <c>struct</c> types and sequences and constants in the IDL file. The
+ c file contains all operation stubs if the the scope is an interface.</p>
+ <p>In addition to the scope-related files a C source file will
+ be generated for encoding operations of all <c>struct</c> and
+ sequence types.</p>
+ </section>
+ </section>
+
+ <section>
+ <title>Basic OMG IDL Types</title>
+ <p>The mapping of basic types is as follows.</p>
+ <table>
+ <row>
+ <cell align="left" valign="middle"><em>OMG IDL type</em></cell>
+ <cell align="left" valign="middle"><em>C type</em></cell>
+ <cell align="left" valign="middle"><em>Mapped to C type</em></cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">float</cell>
+ <cell align="left" valign="middle">CORBA_float</cell>
+ <cell align="left" valign="middle">float</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">double</cell>
+ <cell align="left" valign="middle">CORBA_double</cell>
+ <cell align="left" valign="middle">double</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">short</cell>
+ <cell align="left" valign="middle">CORBA_short</cell>
+ <cell align="left" valign="middle">short</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned short</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_short</cell>
+ <cell align="left" valign="middle">unsigned short</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long</cell>
+ <cell align="left" valign="middle">CORBA_long</cell>
+ <cell align="left" valign="middle">long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long long</cell>
+ <cell align="left" valign="middle">CORBA_long_long</cell>
+ <cell align="left" valign="middle">long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned long</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long</cell>
+ <cell align="left" valign="middle">unsigned long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned long long</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long_long</cell>
+ <cell align="left" valign="middle">unsigned long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">char</cell>
+ <cell align="left" valign="middle">CORBA_char</cell>
+ <cell align="left" valign="middle">char</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">wchar</cell>
+ <cell align="left" valign="middle">CORBA_wchar</cell>
+ <cell align="left" valign="middle">unsigned long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">boolean</cell>
+ <cell align="left" valign="middle">CORBA_boolean</cell>
+ <cell align="left" valign="middle">unsigned char</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">octet</cell>
+ <cell align="left" valign="middle">CORBA_octet</cell>
+ <cell align="left" valign="middle">char</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">any</cell>
+ <cell align="left" valign="middle">Not supported</cell>
+ <cell align="left" valign="middle"></cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long double</cell>
+ <cell align="left" valign="middle">Not supported</cell>
+ <cell align="left" valign="middle"></cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">Object</cell>
+ <cell align="left" valign="middle">Not supported</cell>
+ <cell align="left" valign="middle"></cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">void</cell>
+ <cell align="left" valign="middle">void</cell>
+ <cell align="left" valign="middle">void</cell>
+ </row>
+ <tcaption>OMG IDL Basic Types</tcaption>
+ </table>
+ <p>XXX Note that several mappings are not according to OMG C Language
+ mapping.</p>
+ </section>
+
+ <section>
+ <title>Constructed OMG IDL Types</title>
+ <p>Constructed types have mappings as shown in the following table.</p>
+ <table>
+ <row>
+ <cell align="left" valign="middle">OMG IDL type</cell>
+ <cell align="left" valign="middle">Mapped to C type</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">string</cell>
+ <cell align="left" valign="middle">CORBA_char*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">wstring</cell>
+ <cell align="left" valign="middle">CORBA_wchar*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">struct</cell>
+ <cell align="left" valign="middle">struct</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">union</cell>
+ <cell align="left" valign="middle">union</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">enum</cell>
+ <cell align="left" valign="middle">enum</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">sequence</cell>
+ <cell align="left" valign="middle">struct (see below)</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">array</cell>
+ <cell align="left" valign="middle">array</cell>
+ </row>
+ <tcaption>OMG IDL Constructed Types</tcaption>
+ </table>
+ <p>An OMG IDL sequence (an array of variable length), </p>
+ <code type="none"><![CDATA[
+// IDL
+typedef sequence <IDL_TYPE> NAME;
+ ]]></code>
+ <p>is mapped to a C struct as follows:</p>
+ <code type="none">
+/* C */
+typedef struct {
+ CORBA_unsigned_long _maximum;
+ CORBA_unsigned_long _length;
+ C_TYPE* _buffer;
+} C_NAME;
+ </code>
+ <p>where <c>C_TYPE</c> is the mapping of <c>IDL_TYPE</c>, and where
+ <c>C_NAME</c> is the scoped name of <c>NAME</c>.</p>
+ </section>
+
+ <section>
+ <title>OMG IDL Constants</title>
+ <p>An IDL constant is mapped to a C constant through a C
+ <c>#define</c> macro, where the name of the macro is scoped.
+ Example:</p>
+ <code type="none">
+// IDL
+module M1 {
+ const long c1 = 99;
+};
+ </code>
+ <p>results in the following:</p>
+ <code type="none">
+/* C */
+#define M1_c1 99
+ </code>
+ </section>
+
+ <section>
+ <title>OMG IDL Operations</title>
+ <p>An OMG IDL operation is mapped to C function. Each C operation
+ function has two mandatory parameters: a first parameter of
+ <em>interface object</em> type, and a last parameter of
+ <em>environment</em> type.</p>
+ <p></p>
+ <p>In a C operation function the the <c>in</c> and <c>out</c>
+ parameters are located between the first and last parameters
+ described above, and they appear in the same order as in the IDL
+ operation declaration.</p>
+ <p>Notice that <c>inout</c> parameters are not supported. </p>
+ <p></p>
+ <p>The return value of an OMG IDL operation is mapped to a
+ corresponding return value of the C operation function.</p>
+ <p>Mandatory C operation function parameters:</p>
+ <list type="bulleted">
+ <item><c>CORBA_Object oe_obj</c> - the first parameter of a C
+ operation function. This parameter is required by the <em>OMG C Language Mapping Specification</em>, but in the current
+ implementation there is no particular use for it.</item>
+ <item>
+ <p><c>CORBA_Environment* oe_env</c> - the last parameter of a C
+ operation function. The parameter is defined in the C header
+ file <c>ic.h</c> and has the following public fields:</p>
+ <list type="bulleted">
+ <item>
+ <p><c>CORBA_Exception_type _major</c> - indicates if an
+ operation invocation was successful which will be one of
+ the following:</p>
+ <list type="bulleted">
+ <item>CORBA_NO_EXCEPTION</item>
+ <item>CORBA_SYSTEM_EXCEPTION</item>
+ </list>
+ </item>
+ <item>int <em>_fd</em> - a file descriptor returned from
+ <em>erl_connect</em> function.</item>
+ <item>int <em>_inbufsz</em> - size of input buffer.</item>
+ <item>char* <em>_inbuf</em> - pointer to a buffer used for
+ input.</item>
+ <item>int <em>_outbufsz</em> - size of output buffer.</item>
+ <item>char* <em>_outbuf</em> - pointer to a buffer used for
+ output.</item>
+ <item>
+ <p>int <em>_memchunk</em> - expansion unit size for the
+ output buffer. This is the size of memory chunks in
+ bytes used for increasing the output in case of buffer
+ expansion. The value of this field must be always set
+ to &gt;= 32, should be at least 1024 for performance
+ reasons.</p>
+ </item>
+ <item>char <em>regname[256]</em> - a registered name for a
+ process.</item>
+ <item>erlang_pid* <em>_to_pid</em> - an Erlang process
+ identifier, is only used if the registered_name parameter
+ is the empty string.</item>
+ <item>erlang_pid* <em>_from_pid</em> - your own process id so
+ the answer can be returned</item>
+ </list>
+ <p>Beside the public fields, other private fields
+ are internally used but are not mentioned here. </p>
+ </item>
+ </list>
+ <p>Example:</p>
+ <code type="none">
+// IDL
+interface i1 {
+ long op1(in long a);
+ long op2(in string s, out long count);
+};
+ </code>
+ <p>Is mapped to the following C functions</p>
+ <code type="none">
+/* C */
+CORBA_long i1_op1(i1 oe_obj, CORBA_long a, CORBA_Environment* oe_env)
+{
+ ...
+}
+CORBA_long i1_op2(i1 oe_obj, CORBA_char* s, CORBA_long *count,
+CORBA_Environment* oe_env)
+{
+ ...
+}
+ </code>
+ <marker id="op_impl"></marker>
+
+ <section>
+ <title>Operation Implementation</title>
+ <p>There is no standard CORBA mapping for the C-server side,
+ as it is implementation-dependent but built in a similar way.
+ The current server side mapping is different from the client
+ side mapping in several ways:</p>
+ <list type="bulleted">
+ <item>Argument mappings</item>
+ <item>Result values</item>
+ <item>Structure</item>
+ <item>Usage</item>
+ <item>Exception handling</item>
+ </list>
+ </section>
+ </section>
+
+ <section>
+ <title>Exceptions</title>
+ <p>Although exception mapping is not implemented, the stubs will
+ generate CORBA system exceptions in case of operation failure.
+ Thus, the only exceptions propagated by the system are built in
+ system exceptions.</p>
+ </section>
+
+ <section>
+ <title>Access to Attributes</title>
+ <p>Not Supported</p>
+ </section>
+
+ <section>
+ <title>Summary of Argument/Result Passing for the C-client</title>
+ <p>The user-defined parameters can only be <c>in</c> or <c>out</c>
+ parameters, as
+ <c>inout</c> parameters are not supported.</p>
+ <p>This table summarize the types a client passes as arguments to
+ a stub, and receives as a result.</p>
+ <table>
+ <row>
+ <cell align="left" valign="middle">OMG IDL type</cell>
+ <cell align="left" valign="middle">In</cell>
+ <cell align="left" valign="middle">Out</cell>
+ <cell align="left" valign="middle">Return</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">short</cell>
+ <cell align="left" valign="middle">CORBA_short</cell>
+ <cell align="left" valign="middle">CORBA_short*</cell>
+ <cell align="left" valign="middle">CORBA_short</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long</cell>
+ <cell align="left" valign="middle">CORBA_long</cell>
+ <cell align="left" valign="middle">CORBA_long*</cell>
+ <cell align="left" valign="middle">CORBA_long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long long</cell>
+ <cell align="left" valign="middle">CORBA_long_long</cell>
+ <cell align="left" valign="middle">CORBA_long_long*</cell>
+ <cell align="left" valign="middle">CORBA_long_long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned short</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_short</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_short*</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_short</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned long</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long*</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned long long</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long_long</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long_long*</cell>
+ <cell align="left" valign="middle">CORBA_unsigned_long_long</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">float</cell>
+ <cell align="left" valign="middle">CORBA_float</cell>
+ <cell align="left" valign="middle">CORBA_float*</cell>
+ <cell align="left" valign="middle">CORBA_float</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">double</cell>
+ <cell align="left" valign="middle">CORBA_double</cell>
+ <cell align="left" valign="middle">CORBA_double*</cell>
+ <cell align="left" valign="middle">CORBA_double</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">boolean</cell>
+ <cell align="left" valign="middle">CORBA_boolean</cell>
+ <cell align="left" valign="middle">CORBA_boolean*</cell>
+ <cell align="left" valign="middle">CORBA_boolean</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">char</cell>
+ <cell align="left" valign="middle">CORBA_char</cell>
+ <cell align="left" valign="middle">CORBA_char*</cell>
+ <cell align="left" valign="middle">CORBA_char</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">wchar</cell>
+ <cell align="left" valign="middle">CORBA_wchar</cell>
+ <cell align="left" valign="middle">CORBA_wchar*</cell>
+ <cell align="left" valign="middle">CORBA_wchar</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">octet</cell>
+ <cell align="left" valign="middle">CORBA_octet</cell>
+ <cell align="left" valign="middle">CORBA_octet*</cell>
+ <cell align="left" valign="middle">CORBA_octet</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">enum</cell>
+ <cell align="left" valign="middle">CORBA_enum</cell>
+ <cell align="left" valign="middle">CORBA_enum*</cell>
+ <cell align="left" valign="middle">CORBA_enum</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">struct, fixed</cell>
+ <cell align="left" valign="middle">struct*</cell>
+ <cell align="left" valign="middle">struct*</cell>
+ <cell align="left" valign="middle">struct</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">struct, variable</cell>
+ <cell align="left" valign="middle">struct*</cell>
+ <cell align="left" valign="middle">struct**</cell>
+ <cell align="left" valign="middle">struct*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">union, fixed</cell>
+ <cell align="left" valign="middle">union*</cell>
+ <cell align="left" valign="middle">union*</cell>
+ <cell align="left" valign="middle">union</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">union, variable</cell>
+ <cell align="left" valign="middle">union*</cell>
+ <cell align="left" valign="middle">union**</cell>
+ <cell align="left" valign="middle">union*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">string</cell>
+ <cell align="left" valign="middle">CORBA_char*</cell>
+ <cell align="left" valign="middle">CORBA_char**</cell>
+ <cell align="left" valign="middle">CORBA_char*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">wstring</cell>
+ <cell align="left" valign="middle">CORBA_wchar*</cell>
+ <cell align="left" valign="middle">CORBA_wchar**</cell>
+ <cell align="left" valign="middle">CORBA_wchar*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">sequence</cell>
+ <cell align="left" valign="middle">sequence*</cell>
+ <cell align="left" valign="middle">sequence**</cell>
+ <cell align="left" valign="middle">sequence*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">array, fixed</cell>
+ <cell align="left" valign="middle">array</cell>
+ <cell align="left" valign="middle">array</cell>
+ <cell align="left" valign="middle">array_slice*</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">array, variable</cell>
+ <cell align="left" valign="middle">array</cell>
+ <cell align="left" valign="middle">array_slice**</cell>
+ <cell align="left" valign="middle">array_slice*</cell>
+ </row>
+ <tcaption>Basic Argument and Result passing</tcaption>
+ </table>
+ <p>A client is responsible for providing storage of all arguments passed
+ as <em>in</em> arguments.</p>
+ <table>
+ <row>
+ <cell align="left" valign="middle">OMG IDL type</cell>
+ <cell align="left" valign="middle">Out</cell>
+ <cell align="left" valign="middle">Return</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">short</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">long long</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned short</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned long</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">unsigned long long</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">float</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">double</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">boolean</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">char</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">wchar</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">octet</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">enum</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">struct, fixed</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">1</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">struct, variable</cell>
+ <cell align="left" valign="middle">2</cell>
+ <cell align="left" valign="middle">2</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">string</cell>
+ <cell align="left" valign="middle">2</cell>
+ <cell align="left" valign="middle">2</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">wstring</cell>
+ <cell align="left" valign="middle">2</cell>
+ <cell align="left" valign="middle">2</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">sequence</cell>
+ <cell align="left" valign="middle">2</cell>
+ <cell align="left" valign="middle">2</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">array, fixed</cell>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">3</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">array, variable</cell>
+ <cell align="left" valign="middle">3</cell>
+ <cell align="left" valign="middle">3</cell>
+ </row>
+ <tcaption>Client argument storage responsibility</tcaption>
+ </table>
+ <table>
+ <row>
+ <cell align="left" valign="middle">Case</cell>
+ <cell align="left" valign="middle">Description</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">1</cell>
+ <cell align="left" valign="middle">Caller allocates all necessary storage, except that which may be encapsulated and managed within the parameter itself.</cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">2</cell>
+ <cell align="left" valign="middle">The caller allocates a pointer and passes it by reference to the callee. The callee sets the pointer to point to a valid instance of the parameter's type. The caller is responsible for releasing the returned storage. Following completion of a request, the caller is not allowed to modify any values in the returned storage. To do so the caller must first copy the returned instance into a new instance, then modify the new instance. </cell>
+ </row>
+ <row>
+ <cell align="left" valign="middle">3</cell>
+ <cell align="left" valign="middle">The caller allocates a pointer to an array slice which has all the same dimensions of the original array except the first, and passes it by reference to the callee. The callee sets the pointer to point to a valid instance of the array. The caller is responsible for releasing the returned storage. Following completion of a request, the caller is not allowed to modify any values in the returned storage. To do so the caller must first copy the returned instance into a new instance, then modify the new instance. </cell>
+ </row>
+ <tcaption>Argument passing cases</tcaption>
+ </table>
+ <p>The returned storage in case 2 and 3 is allocated as one block of memory
+ so it is possible to deallocate it with one call of CORBA_free.</p>
+ </section>
+
+ <section>
+ <title>Supported Memory Allocation Functions</title>
+ <list type="bulleted">
+ <item>
+ <p><em>CORBA_Environment</em> can be allocated from the user by calling
+ <em>CORBA_Environment_alloc()</em>.</p>
+ <p>The interface for this function is </p>
+ <p><c>CORBA_Environment *CORBA_Environment_alloc(int inbufsz, int outbufsz);</c></p>
+ <p>where :</p>
+ <list type="bulleted">
+ <item>
+ <p><em>inbufsz</em> is the desired size of input buffer</p>
+ </item>
+ <item>
+ <p><em>outbufsz</em> is the desired size of output buffer</p>
+ </item>
+ <item>
+ <p>return value is a <em>pointer</em> to an allocated and initialized
+ <em>CORBA_Environment</em> structure</p>
+ <p></p>
+ </item>
+ </list>
+ </item>
+ <item>
+ <p>Strings can be allocated from the user by calling <em>CORBA_string_alloc()</em>.</p>
+ <p>The interface for this function is </p>
+ <p><c>CORBA_char *CORBA_string_alloc(CORBA_unsigned_long len);</c></p>
+ <p>where :</p>
+ <list type="bulleted">
+ <item>
+ <p><em>len</em> is the length of the string to be allocated.</p>
+ </item>
+ </list>
+ </item>
+ </list>
+ <p>Thus far, no other type allocation function is supported.</p>
+ </section>
+
+ <section>
+ <title>Special Memory Deallocation Functions</title>
+ <list type="bulleted">
+ <item>
+ <p><c>void CORBA_free(void *storage)</c></p>
+ <p>This function will free storage allocated by the stub.</p>
+ </item>
+ <item>
+ <p><c>void CORBA_exception_free(CORBA_environment *ev)</c></p>
+ <p>This function will free storage allocated under exception propagation. </p>
+ </item>
+ </list>
+ </section>
+
+ <section>
+ <title>Exception Access Functions</title>
+ <list type="bulleted">
+ <item>
+ <p><c>CORBA_char *CORBA_exception_id(CORBA_Environment *ev)</c></p>
+ <p>This function will return raised exception identity.</p>
+ </item>
+ <item>
+ <p><c>void *CORBA_exception_value(CORBA_Environment *ev)</c></p>
+ <p>This function will return the value of a raised exception. </p>
+ </item>
+ </list>
+ </section>
+
+ <section>
+ <title>Special Types</title>
+ <list type="bulleted">
+ <item>
+ <p>The erlang binary type has some special features.</p>
+ <p></p>
+ <p>While the <c>erlang::binary</c> idl type has the same C-definition as
+ a generated sequence of octets :</p>
+ <code type="none"><![CDATA[
+\011 module erlang
+\011 {
+
+\011 ....
+
+\011 // an erlang binary
+\011 typedef sequence<octet> binary;
+\011
+\011 };
+ ]]></code>
+ <p>it provides a way on sending trasparent data between C and Erlang.</p>
+ <p>The C-definition (ic.h) for an erlang binary is :</p>
+ <code type="none">
+\011 typedef struct {
+\011 CORBA_unsigned_long _maximum;
+\011 CORBA_unsigned_long _length;
+\011 CORBA_octet* _buffer;
+\011 } erlang_binary; /* ERLANG BINARY */
+ </code>
+ <p>The differences (between <c>erlang::binary</c> and <c><![CDATA[sequence< octet >]]></c>) are :</p>
+ <list type="bulleted">
+ <item>
+ <p>on the erlang side the user is sending/receiving typical
+ built in erlang binaries, using <c>term_to_binary() / binary_to_term()</c>
+ to create / extract binary structures.</p>
+ </item>
+ <item>
+ <p>no encoding/decoding functions are generated</p>
+ </item>
+ <item>
+ <p>the underlying protocol is more efficient than usual sequences of
+ octets</p>
+ </item>
+ </list>
+ <p>The erlang binary IDL type is defined in <c>erlang.idl</c>, while it's
+ C definition is located in the <c>ic.h</c> header file, both in the
+ <c><![CDATA[IC-< vsn >/include]]></c> directory.
+ The user will have to include the file <c>erlang.idl</c> in order to use the
+ <c>erlang::binary</c> type.</p>
+ </item>
+ </list>
+ </section>
+
+ <section>
+ <title>A Mapping Example</title>
+ <p> <marker id="stack_idl"></marker>
+
+ This is a small example of a simple stack. There are two
+ operations on the stack, push and pop. The example shows all
+ generated files as well as conceptual usage of the stack.</p>
+ <code type="none">
+// The source IDL file: stack.idl
+
+struct s {
+ long l;
+ string s;
+};
+
+interface stack {
+ void push(in s val);
+ s pop();
+};
+ </code>
+ <p>When this file is compiled it produces four files, two for the
+ top scope and two for the stack interface scope. The important parts
+ of the generated C code for the stack API is shown below. <marker id="stack_serv"></marker>
+</p>
+ <p>stack.c</p>
+ <code type="none">
+
+void push(stack oe_obj, s val, CORBA_Environment* oe_env) {
+ ...
+}
+
+
+s* pop(stack oe_obj, CORBA_Environment* oe_env) {
+ ...
+}
+ </code>
+ <p>oe_stack.h</p>
+ <code type="none">
+#ifndef OE_STACK_H
+#define OE_STACK_H
+
+
+/*------------------------------------------------------------
+ * Struct definition: s
+ */
+typedef struct {
+ long l;
+ char *s;
+} s;
+
+
+
+#endif
+ </code>
+ <p>stack.h just contains an include statement of <c>oe_stack.h</c>.</p>
+ <p>oe_code_s.c</p>
+ <code type="none">
+
+int oe_sizecalc_s(CORBA_Environment
+ *oe_env, int* oe_size_count_index, int* oe_size) {
+ ...
+}
+
+int oe_encode_s(CORBA_Environment *oe_env, s* oe_rec) {
+ ...
+}
+
+int oe_decode_s(CORBA_Environment *oe_env, char *oe_first,
+ int* oe_outindex, s *oe_out) {
+ ...
+}
+ </code>
+ <p>The only files that are really important are the <c>.h</c>
+ files and the stack.c file.</p>
+ </section>
+</chapter>
+