~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/ic/doc/src/ic.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1997</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>ic</title>
 
27
    <prepared></prepared>
 
28
    <docno></docno>
 
29
    <checked></checked>
 
30
    <date>2004-01-08</date>
 
31
    <rev>B</rev>
 
32
  </header>
 
33
  <module>ic</module>
 
34
  <modulesummary>The Erlang IDL Compiler</modulesummary>
 
35
  <description>
 
36
    <p>The ic module is an Erlang implementation of an OMG IDL
 
37
      compiler. Depending on the choice of back-end the code will map
 
38
      to Erlang, C, or Java. The compiler generates client stubs and
 
39
      server skeletons.</p>
 
40
    <p>Two kinds of files are generated for each scope: Ordinary code
 
41
      files and header files. The latter are used for defining record
 
42
      definitions, while the ordinary files contain the object
 
43
      interface functions.</p>
 
44
  </description>
 
45
  <funcs>
 
46
    <func>
 
47
      <name>ic:gen(FileName) -> Result</name>
 
48
      <name>ic:gen(FileName, [Option]) -> Result</name>
 
49
      <fsummary>Generate stub and server code according to the OMG CORBA standard.</fsummary>
 
50
      <type>
 
51
        <v>Result = ok | error | {ok, [Warning]} | {error, [Warning], [Error]}</v>
 
52
        <v></v>
 
53
        <v>Option = [ GeneralOption | CodeOption | WarningOption | BackendOption]</v>
 
54
        <v></v>
 
55
        <v>GeneralOption = </v>
 
56
        <v>{outdir, String()} | {cfgfile, String()} | {use_preproc, bool()} |</v>
 
57
        <v>{preproc_cmd, String()} | {preproc_flags, String()}</v>
 
58
        <v></v>
 
59
        <v>CodeOption =</v>
 
60
        <v>{gen_hrl, bool()} | {serv_last_call, exception | exit} | {{impl, String()}, String()} | {light_ifr, bool()}</v>
 
61
        <v>this | {this, String()} | {{this, String()}, bool()} |</v>
 
62
        <v>from | {from, String()} | {{from, String()}, bool()} |</v>
 
63
        <v>handle_info | {handle_info, String()} | {{handle_info, String()}, bool()} |</v>
 
64
        <v>timeout | {timeout, String()} | {{timeout, String()}, bool()} |</v>
 
65
        <v>{scoped_op_calls, bool()} | {scl, bool()} |</v>
 
66
        <v>{user_protocol, Prefix} |</v>
 
67
        <v>{c_timeout, SendTimeout, RecvTimeout} |</v>
 
68
        <v>{c_report, bool()} |</v>
 
69
        <v>{precond, {atom(), atom()}} | {{precond, String()} {atom(), atom()}} |</v>
 
70
        <v>{postcond, {atom(), atom()}} | {{postcond, String()} {atom(), atom()}}</v>
 
71
        <v></v>
 
72
        <v>WarningOption =</v>
 
73
        <v>{'Wall', bool()} | {maxerrs, int() | infinity} |</v>
 
74
        <v>{maxwarns, int() | infinity} | {nowarn, bool()} |</v>
 
75
        <v>{warn_name_shadow, bool()} | {pedantic, bool()} |</v>
 
76
        <v>{silent, bool()}</v>
 
77
        <v></v>
 
78
        <v>BackendOption = {be, Backend}</v>
 
79
        <v></v>
 
80
        <v>Backend = erl_corba | erl_template | erl_plain | erl_genserv | c_client | c_server | java</v>
 
81
        <v></v>
 
82
        <v>DirNAme = string() | atom()</v>
 
83
        <v>FileName = string() | atom()</v>
 
84
      </type>
 
85
      <desc>
 
86
        <p>The tuple <c>{Option, true}</c> can be replaced by
 
87
          <c>Option</c> for boolean values.</p>
 
88
        <p>The <c>ic:gen/2</c> function can be called from the command 
 
89
          line as follows:</p>
 
90
        <p><c>erlc "+Option" ... File.idl</c></p>
 
91
        <p>Example:</p>
 
92
        <p><c>erlc "+{be,c_client}"  '+{outdir, "../out"}' File.idl</c></p>
 
93
      </desc>
 
94
    </func>
 
95
  </funcs>
 
96
 
 
97
  <section>
 
98
    <title>General options</title>
 
99
    <taglist>
 
100
      <tag><em>outdir</em></tag>
 
101
      <item>
 
102
        <p>Places all output files in the directory given by the option.
 
103
          The directory will be created if it does not already exist.</p>
 
104
        <p>Example option: <c>{outdir, "output/generated"}</c>.</p>
 
105
      </item>
 
106
      <tag><em>cfgfile</em></tag>
 
107
      <item>
 
108
        <p>Uses <em>FileName</em> as configuration file. Options will
 
109
          override compiler defaults but can be overridden by command line
 
110
          options. Default value is <c>".ic_config"</c>.</p>
 
111
        <p>Example option: <c>{cfgfile, "special.cfg"}</c>.</p>
 
112
      </item>
 
113
      <tag><em>use_preproc</em></tag>
 
114
      <item>
 
115
        <p>Uses a preprocessor. Default value is true.</p>
 
116
      </item>
 
117
      <tag><em>preproc_cmd</em></tag>
 
118
      <item>
 
119
        <p>Command string to invoke the preprocessor. The actual
 
120
          command will be built as
 
121
          <c>preproc_cmd++preproc_flags++FileName</c></p>
 
122
        <p>Example option: <c>{preproc_cmd, "erl"})</c>.</p>
 
123
        <p>Example option: <c>{preproc_cmd, "gcc -x c++ -E"}</c>.</p>
 
124
      </item>
 
125
      <tag><em>preproc_flags</em></tag>
 
126
      <item>
 
127
        <p>Flags given to the preprocessor.</p>
 
128
        <p>Example option: <c>{preproc_flags, "-I../include"}</c>.</p>
 
129
      </item>
 
130
    </taglist>
 
131
  </section>
 
132
 
 
133
  <section>
 
134
    <title>Code options</title>
 
135
    <taglist>
 
136
      <tag><em>light_ifr</em></tag>
 
137
      <item>
 
138
        <p>Currently, the default setting is <c>false</c>. To be able to
 
139
          use this option Orber must be configured to use Light IFR (see
 
140
          Orber's User's Guide). When this options is used, the size of the
 
141
          generated files used to register the API in the IFR DB are minimized.</p>
 
142
        <p>Example option: <c>{light_ifr, true}</c>.</p>
 
143
      </item>
 
144
      <tag><em>gen_hrl</em></tag>
 
145
      <item>
 
146
        <p>Generate header files. Default is true.</p>
 
147
      </item>
 
148
      <tag><em>serv_last_call</em></tag>
 
149
      <item>
 
150
        <p>Makes the last <c>gen_server handle_call</c> either raise a
 
151
          CORBA exception or just  exit plainly. Default is the exception.
 
152
          </p>
 
153
      </item>
 
154
      <tag><em>{{impl, IntfName}, ModName}</em></tag>
 
155
      <item>
 
156
        <p>Assumes that the interface with name <em>IntfName</em> is
 
157
          implemented by the module with name <em>ModName</em> and
 
158
          will generate calls to the <em>ModName</em> module in the
 
159
          server behavior.  Note that the <em>IntfName</em> must be a
 
160
          fully scoped name as in <c>"M1::I1"</c>.</p>
 
161
        <p></p>
 
162
      </item>
 
163
      <tag><em>this</em></tag>
 
164
      <item>
 
165
        <p>Adds the object reference as the first parameter to the
 
166
          object implementation functions. This makes the
 
167
          implementation aware of its own object reference. 
 
168
                    <br></br>
 
169
The option
 
170
          comes in three varieties: <c>this</c> which activates the
 
171
          parameter for all interfaces in the source file, <c>{this, IntfName}</c> which activates the parameter for a specified
 
172
          interface and <c>{{this, IntfName}, false}</c> which
 
173
          deactivates the parameter for a specified
 
174
          interface.</p>
 
175
        <p>Example option: <c>this)</c> activates the parameter for
 
176
          all interfaces.</p>
 
177
        <p>Example option: <c>{this, "M1::I1"}</c> activates the
 
178
          parameter for all functions of <c>M1::I1</c>.</p>
 
179
        <p>Example options: <c>[this, {{this, "M1::I2"}, false}]</c>
 
180
          activates the parameter for all interfaces except
 
181
          <c>M1::I2</c>.</p>
 
182
      </item>
 
183
      <tag><em>from</em></tag>
 
184
      <item>
 
185
        <p>Adds the invokers reference as the first parameter to the
 
186
          object implementation two-way functions. If both
 
187
          <c>from</c> and <c>this</c> options are used the invokers
 
188
          reference parameter will be passed as the second
 
189
          parameter. This makes it possible for the implementation to
 
190
          respond to a request and continue executing
 
191
          afterwards. Consult the <c>gen_server</c> and <c>Orber</c>
 
192
          documentation how this option may be used.            <br></br>
 
193
The option
 
194
          comes in three varieties: <c>from</c> which activates the
 
195
          parameter for all interfaces in the source file, <c>{from, IntfName}</c> which activates the parameter for a specified
 
196
          interface and <c>{{from, IntfName}, false}</c> which
 
197
          deactivates the parameter for a specified interface.</p>
 
198
        <p>Example option: <c>from)</c> activates the parameter for
 
199
          all interfaces.</p>
 
200
        <p>Example options: <c>[{from, "M1::I1"}]</c> activates the
 
201
          parameter for all functions of <c>M1::I1</c>.</p>
 
202
        <p>Example options: <c>[from, {{from, "M1::I2"}, false}]</c>
 
203
          activates the parameter for all interfaces except
 
204
          <c>M1::I2</c>.</p>
 
205
      </item>
 
206
      <tag><em>handle_info</em></tag>
 
207
      <item>
 
208
        <p>Makes the object server call a function <c>handle_info</c>
 
209
          in the object implementation module on all unexpected
 
210
          messages. Useful if the object implementation need to trap
 
211
          exits.</p>
 
212
        <p>Example option: <c>handle_info</c> will activates module
 
213
          implementation <c>handle_info</c> for all interfaces in the
 
214
          source file.</p>
 
215
        <p>Example option: <c>{{handle_info, "M1::I1"}, true}</c>
 
216
          will activates module implementation <c>handle_info</c> for
 
217
          the specified interface.</p>
 
218
        <p>Example options: <c>[handle_info, {{handle_info, "M1::I1"}, false}]</c> will generate the <c>handle_info</c>
 
219
          call for all interfaces except <c>M1::I1</c>.</p>
 
220
      </item>
 
221
      <tag><em>timeout</em></tag>
 
222
      <item>
 
223
        <p>Used to allow a server response time limit to be set by the user. 
 
224
          This should be a string that represents the scope for the interface 
 
225
          which should have an extra variable for wait time initialization.</p>
 
226
        <p>Example option: <c>{timeout,"M::I"})</c> produces server
 
227
          stub which will has an extra timeout parameter in the initialization 
 
228
          function for that interface.</p>
 
229
        <p>Example option: <c>timeout</c> produces server
 
230
          stub which will has an extra timeout parameter in the initialization 
 
231
          function for all interfaces in the source file.</p>
 
232
        <p>Example options: <c>[timeout, {{timeout,"M::I"}, false}]</c>
 
233
          produces server stub which will has an extra timeout
 
234
          parameter in the initialization function for all interfaces
 
235
          except <c>M1::I1</c>.</p>
 
236
      </item>
 
237
      <tag><em>scoped_op_calls</em></tag>
 
238
      <item>
 
239
        <p>Used to produce more refined request calls to server. When
 
240
          this option is set to true, the operation name which was
 
241
          mentioned in the call is scoped. This is essential to avoid
 
242
          name clashes when communicating with c-servers. This option
 
243
          is available for the c-client, c-server and the Erlang
 
244
          gen_server back ends. <c>All</c> of the parts generated by ic
 
245
          have to agree in the use of this option. Default is
 
246
          <c>false</c>.  </p>
 
247
        <p>Example options:
 
248
          <c>[{be,c_genserv},{scoped_op_calls,true}])</c> produces
 
249
          client stubs which sends "scoped" requests to a gen_server
 
250
          or a c-server.</p>
 
251
      </item>
 
252
      <tag><em>user_protocol</em></tag>
 
253
      <item>
 
254
        <p>Used to define a own protocol different from the default
 
255
          Erlang distribution + gen_server protocol. Currently only
 
256
          valid for C back-ends. For further details see <seealso marker="ic_c_protocol">IC C protocol</seealso>.</p>
 
257
        <p>Example options:
 
258
          <c>[{be,c_client},{user_protocol, "my_special"}])</c> produces
 
259
          client stubs which use C protocol functions with the prefix 
 
260
          "my_special".</p>
 
261
      </item>
 
262
      <tag><em>c_timeout</em></tag>
 
263
      <item>
 
264
        <p>Makes sends and receives to have timeouts (C back-ends only).  These
 
265
          timeouts are specified in milliseconds. </p>
 
266
        <p>Example options:
 
267
          <c>[{be,c_client},{c_timeout, 10000, 20000}])</c> produces
 
268
          client stubs which use a 10 seconds send timeout, and a
 
269
          20 seconds receive timeout.</p>
 
270
      </item>
 
271
      <tag><em>c_report</em></tag>
 
272
      <item>
 
273
        <p>Generates code for writing encode/decode errors to <c>stderr</c> (C back-ends only).
 
274
          timeouts are specified in milliseconds. </p>
 
275
        <p>Example options:
 
276
          <c>[{be,c_client}, c_report])</c>.</p>
 
277
      </item>
 
278
      <tag><em>scl</em></tag>
 
279
      <item>
 
280
        <p>Used for compatibility with previous compiler versions up
 
281
          to <c>3.3</c>.  Due to better semantic checks on enumerants,
 
282
          the compiler discovers name clashes between user defined
 
283
          types and enumerant values in the same name space. By
 
284
          enabling this option the compiler turns off the extended
 
285
          semantic check on enumerant values.  Default is
 
286
          <c>false</c>.  </p>
 
287
        <p>Example option: <c>{scl,true}</c></p>
 
288
      </item>
 
289
      <tag><em>precond</em></tag>
 
290
      <item>
 
291
        <p>Adds a precondition call before the call to the operation
 
292
          implementation on the server side.</p>
 
293
        <p>The option comes in three varieties: <c>{precond, {M, F}}</c> which activates the call for operations in all
 
294
          interfaces in the source file, <c>{{precond, IntfName}, {M, F}}</c> which activates the call for all operations in a
 
295
          specific interface and <c>{{precond, OpName}, {M, F}}</c>
 
296
          which activates the call for a specific operation.</p>
 
297
        <p>The precondition function has the following signature
 
298
          <c>m:f(Module, Function, Args)</c>.</p>
 
299
        <p>Example option: <c>{precond, {mod, fun}}</c> adds the call
 
300
          of m:f for all operations in the idl file.</p>
 
301
        <p>Example options: <c>[{{precond, "M1::I"}, {mod, fun}}]</c>
 
302
          adds the call of <c>m:f</c> for all operations in the
 
303
          interface <c>M1::I1</c>.</p>
 
304
        <p>Example options: <c>[{{precond, "M1::I::Op"}, {mod, fun}}]</c> adds the call of <c>m:f</c> for the operation
 
305
          <c>M1::I::Op</c>.</p>
 
306
      </item>
 
307
      <tag><em>postcond</em></tag>
 
308
      <item>
 
309
        <p>Adds a postcondition call after the call to the operation
 
310
          implementation on the server side. </p>
 
311
        <p>The option comes in three varieties: <c>{postcond, {M, F}}</c> which activates the call for operations in all
 
312
          interfaces in the source file, <c>{{postcond, IntfName}, {M, F}}</c> which activates the call for all operations in a
 
313
          specific interface and <c>{{postcond, OpName}, {M, F}}</c>
 
314
          which activates the call for a specific operation.</p>
 
315
        <p>The postcondition function has the following signature
 
316
          <c>m:f(Module, Function, Args, Result)</c>.</p>
 
317
        <p>Example option: <c>{postcond, {mod, fun}}</c> adds the call
 
318
          of m:f for all operations in the idl file.</p>
 
319
        <p>Example options: <c>[{{postcond, "M1::I"}, {mod, fun}}]</c>
 
320
          adds the call of <c>m:f</c> for all operations in the
 
321
          interface <c>M1::I1</c>.</p>
 
322
        <p>Example options: <c>[{{postcond, "M1::I::Op"}, {mod, fun}}]</c> adds the call of <c>m:f</c> for the operation
 
323
          <c>M1::I::Op</c>.</p>
 
324
      </item>
 
325
    </taglist>
 
326
  </section>
 
327
 
 
328
  <section>
 
329
    <title>Warning options</title>
 
330
    <taglist>
 
331
      <tag><em>'Wall'</em></tag>
 
332
      <item>
 
333
        <p>The option activates all reasonable warning messages  in
 
334
          analogy with the gcc -Wall option. Default value is true.</p>
 
335
      </item>
 
336
      <tag><em>maxerrs</em></tag>
 
337
      <item>
 
338
        <p>The maximum numbers of errors that can be detected before
 
339
          the compiler gives up. The option can either have an integer
 
340
          value or the atom <c>infinity</c>. Default number is 10.</p>
 
341
      </item>
 
342
      <tag><em>maxwarns</em></tag>
 
343
      <item>
 
344
        <p>The maximum numbers of warnings that can be detected before
 
345
          the compiler gives up. The option can either have an integer
 
346
          value or the atom <c>infinity</c>. Default value is
 
347
          infinity.</p>
 
348
      </item>
 
349
      <tag><em>nowarn</em></tag>
 
350
      <item>
 
351
        <p>Suppresses all warnings. Default value is false.</p>
 
352
      </item>
 
353
      <tag><em>warn_name_shadow</em></tag>
 
354
      <item>
 
355
        <p>Warning appears whenever names are shadowed due to
 
356
          inheritance; for example, if a type name is redefined from a
 
357
          base interface. Note that it is illegal to overload 
 
358
          operation and attribute names as this causes an error to be
 
359
          produced. Default value is true. </p>
 
360
      </item>
 
361
      <tag><em>pedantic</em></tag>
 
362
      <item>
 
363
        <p>Activates all warning options. Default value is false.</p>
 
364
      </item>
 
365
      <tag><em>silent</em></tag>
 
366
      <item>
 
367
        <p>Suppresses compiler printed output. Default value is false.</p>
 
368
      </item>
 
369
    </taglist>
 
370
  </section>
 
371
 
 
372
  <section>
 
373
    <title>Back-End options</title>
 
374
    <p>Which back-end IC will generate code for is determined by the supplied
 
375
      <c>{be,atom()}</c> option. If left out, <c>erl_corba</c> is used.
 
376
      Currently, IC support the following back-ends:</p>
 
377
    <taglist>
 
378
      <tag><em>erl_corba</em></tag>
 
379
      <item>
 
380
        <p>This option switches to the IDL generation for CORBA.</p>
 
381
      </item>
 
382
      <tag><em>erl_template</em></tag>
 
383
      <item>
 
384
        <p>Generate CORBA call-back module templates for each interface in the target
 
385
          IDL file. Note, will overwrite existing files.</p>
 
386
      </item>
 
387
      <tag><em>erl_plain</em></tag>
 
388
      <item>
 
389
        <p>Will produce plain Erlang modules which contain functions that
 
390
          map to the corresponding interface functions on the input file.</p>
 
391
      </item>
 
392
      <tag><em>erl_genserv</em></tag>
 
393
      <item>
 
394
        <p>This is an IDL to Erlang generic server generation option.</p>
 
395
      </item>
 
396
      <tag><em>c_client</em></tag>
 
397
      <item>
 
398
        <p>Will produce a C client to the generic Erlang server.</p>
 
399
      </item>
 
400
      <tag><em>c_server</em></tag>
 
401
      <item>
 
402
        <p>Will produce a C server switch with functionality of a
 
403
          generic Erlang server.</p>
 
404
      </item>
 
405
      <tag><em>java</em></tag>
 
406
      <item>
 
407
        <p>Will produce Java client stubs and server skeletons with
 
408
          functionality of a generic Erlang server.</p>
 
409
      </item>
 
410
      <tag><em>c_genserv</em></tag>
 
411
      <item>
 
412
        <p>Deprecated. Use <c>c_client</c> instead.</p>
 
413
      </item>
 
414
    </taglist>
 
415
  </section>
 
416
 
 
417
  <section>
 
418
    <title>Preprocessor</title>
 
419
    <p>The IDL compiler allows several preprocessors to be used, the
 
420
      <c>Erlang IDL preprocessor</c> or other standard <c>C</c> preprocessors.
 
421
      Options can  be used to provide extra flags such as include
 
422
      directories to the preprocessor.  The build in the Erlang IDL
 
423
      preprocessor is used by default, but any standard  C preprocessor
 
424
      such as <c>gcc</c> is adequate.</p>
 
425
    <p>The preprocessor command is formed by appending the prepoc_cmd
 
426
      to the preproc_flags option and then appending the input IDL
 
427
      file name.</p>
 
428
  </section>
 
429
 
 
430
  <section>
 
431
    <title>Configuration</title>
 
432
    <p>The compiler can be configured in two ways:</p>
 
433
    <list type="ordered">
 
434
      <item>
 
435
        <p>Configuration file</p>
 
436
      </item>
 
437
      <item>
 
438
        <p>Command line options</p>
 
439
      </item>
 
440
    </list>
 
441
    <p>The configuration file is optional and overrides the compiler
 
442
      defaults and is in turn overridden by the command line options.
 
443
      The configuration file shall contain options in the form of
 
444
      Erlang terms. The configuration file is read using
 
445
      <c>file:consult</c>.</p>
 
446
    <p>An example of a configuration file, note the "." after each
 
447
      line.</p>
 
448
    <code type="none">
 
449
{outdir, gen_dir}.
 
450
{{impl, "M1::M2::object"}, "obj"}.
 
451
    </code>
 
452
  </section>
 
453
 
 
454
  <section>
 
455
    <title>Output files</title>
 
456
    <p>The compiler will produce output in several files depending on
 
457
      scope declarations found in the IDL file. At most
 
458
      three file types will be generated for each scope (including the top scope), 
 
459
      depending on the compiler back-end and the compiled interface.
 
460
      Generally, the output per interface will be a header file (<c>.hrl</c>/
 
461
      <c>.h</c>) and one or more Erlang/C files (<c>.erl</c>/<c>.c</c>).
 
462
      Please look at the language mapping for each back-end for details.</p>
 
463
    <p>There will be at least one set of files for an IDL file, for the
 
464
      file level scope. Modules and interfaces also have their own set
 
465
      of  generated files.</p>
 
466
  </section>
 
467
  
 
468
</erlref>
 
469