Debian Codegraph @

docs/main004.html

raw
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="hevea 2.35">
6 <link rel="stylesheet" type="text/css" href="main.css">
7 <title>Using camlidl</title>
8 </head>
9 <body >
10 <a href="main003.html"><img src="previous_motif.svg" alt="Previous"></a>
11 <a href="index.html"><img src="contents_motif.svg" alt="Up"></a>
12 <a href="main005.html"><img src="next_motif.svg" alt="Next"></a>
13 <hr>
14 <h2 id="sec33" class="section">4 Using <span class=machine><span class=font-tt>camlidl</span></span></h2>
15 <h3 id="sec34" class="subsection">4.1 Overview</h3>
16 <p>The <span class=machine><span class=font-tt>camlidl</span></span> stub generator is invoked as follows:
17 </p><pre>
18 camlidl <span class=font-it>options</span> <span class=font-it>file1</span>.idl <span class=font-it>file2</span>.idl ...
19 </pre><p>
20 For each file <span class=font-it>f</span><span class=machine><span class=font-tt>.idl</span></span> given on the command line, <span class=machine><span class=font-tt>camlidl</span></span>
21 generates the following files:
22 </p><ul class="itemize"><li class="li-itemize">
23 A Caml interface file <span class=font-it>f</span><span class=machine><span class=font-tt>.mli</span></span> that defines the Caml view
24 of the IDL file. It contains Caml definitions for the types declared
25 in the IDL file, as well as declarations for the functions and the
26 interfaces.
27 </li><li class="li-itemize">A Caml implementation file <span class=font-it>f</span><span class=machine><span class=font-tt>.ml</span></span> that implements the
28 <span class=font-it>f</span><span class=machine><span class=font-tt>.mli</span></span> file.
29 </li><li class="li-itemize">A C source file <span class=font-it>f</span><span class=machine><span class=font-tt>_</span></span><span class=machine><span class=font-tt>stubs.c</span></span> that contains the stub functions for
30 converting between C and Caml data representations.
31 </li><li class="li-itemize">If the <span class=machine><span class=font-tt>-header</span></span> option is given, a C header file <span class=font-it>f</span><span class=machine><span class=font-tt>.h</span></span>
32 containing C declarations for the types declared in the IDL file.
33 </li></ul><p>
34 The generated <span class=machine><span class=font-tt>.ml</span></span> and <span class=machine><span class=font-tt>.c</span></span> files must be compiled and linked with
35 the remainder of the Caml program.</p>
36 <h3 id="sec35" class="subsection">4.2 Options</h3>
37 <p>The following command-line options are recognized by <span class=machine><span class=font-tt>camlidl</span></span>.</p><dl class="description"><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-cpp</span></span></span></dt><dd class="dd-description">
38 Pre-process the source IDL files with the C preprocessor. This option
39 is set by default.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-D </span></span></span><span class=font-bold> </span><span class=font-bold><span class=font-it>symbol</span></span><span class=font-bold><span class=machine><span class=font-tt>=</span></span></span><span class=font-bold><span class=font-it>value</span></span></dt><dd class="dd-description">
40 Define a preprocessor symbol. The option <span class=machine><span class=font-tt>-D</span></span><span class=font-it>symbol</span><span class=machine><span class=font-tt>=</span></span><span class=font-it>value</span>
41 is passed to the C preprocessor. The <span class=font-it>value</span> can be omitted,
42 as in <span class=machine><span class=font-tt>-D</span></span> <span class=font-it>symbol</span>, and defaults to <span class=machine><span class=font-tt>1</span></span>.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-header</span></span></span></dt><dd class="dd-description">
43 Generate a C header file <span class=font-it>f</span><span class=machine><span class=font-tt>.h</span></span> containing C declarations for the
44 types and functions declared in the IDL file <span class=font-it>f</span><span class=machine><span class=font-tt>.c</span></span>.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-I </span></span></span><span class=font-bold> </span><span class=font-bold><span class=font-it>dir</span></span></dt><dd class="dd-description">
45 Add the directory <span class=font-it>dir</span> to the list of directories searched for
46 <span class=machine><span class=font-tt>.idl</span></span> files, as given on the command line or recursively loaded
47 by <span class=syntax-token>import</span> statements.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-keep-labels</span></span></span></dt><dd class="dd-description">
48 Keep the Caml names of record labels as specified in the IDL file.
49 Do not prefix them with the name of the enclosing struct, even if they
50 appear in several struct definitions.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-nocpp</span></span></span></dt><dd class="dd-description">
51 Suppresses the pre-processing of source IDL files.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-no-include</span></span></span></dt><dd class="dd-description">
52 By default, <span class=machine><span class=font-tt>camlidl</span></span> emits a <span class=machine><span class=font-tt>#include "</span></span><span class=font-it>f</span><span class=machine><span class=font-tt>.h"</span></span> statement in
53 the file <span class=font-it>f</span><span class=machine><span class=font-tt>.c</span></span> containing the generated C code.
54 The <span class=font-it>f</span><span class=machine><span class=font-tt>.h</span></span> header file being included is
55 either the one generated by <span class=machine><span class=font-tt>camlidl -header</span></span>, or generated by another
56 tool (such as Microsoft’s <span class=machine><span class=font-tt>midl</span></span> compiler) from the IDL file, or
57 hand-written. The <span class=font-it>f</span><span class=machine><span class=font-tt>.h</span></span> file is assumed to provide all C type
58 declarations needed for compiling the stub code.<p>The <span class=machine><span class=font-tt>-no-include</span></span> option suppresses the automatic inclusion of the
59 <span class=font-it>f</span><span class=machine><span class=font-tt>.h</span></span> file. The IDL file should then include the right header
60 files and provide the right type declarations via <span class=syntax-token>quote</span> statements.</p></dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-prefix-all-labels</span></span></span></dt><dd class="dd-description">
61 Prefix all Caml names of record labels with the name of the enclosing
62 struct. The default is to prefix only those labels that could cause
63 ambiguity because they appear in several struct definitions.</dd><dt class="dt-description"><span class=font-bold><span class=machine><span class=font-tt>-prepro</span></span></span><span class=font-bold> </span><span class=font-bold><span class=font-it>preprocessing-command</span></span></dt><dd class="dd-description">
64 Set the command that is executed to pre-process the source IDL files.
65 The default is the C preprocessor.</dd></dl>
66 <h3 id="sec36" class="subsection">4.3 The <span class=machine><span class=font-tt>camlidldll</span></span> script</h3>
67 <p>Under Windows, a <span class=machine><span class=font-tt>bash</span></span> script called <span class=machine><span class=font-tt>camlidldll</span></span> is provided to
68 automate the construction of a DLL containing a COM component written
69 in Caml.</p><p>The script <span class=machine><span class=font-tt>camlidldll</span></span> accepts essentially the same command-line
70 arguments and options as the <span class=machine><span class=font-tt>ocamlc</span></span> compiler. (It also accepts
71 <span class=machine><span class=font-tt>.tlb</span></span> type library files on the command-line; see
72 section ‍<a href="main005.html#s-dispatch">5.3</a>, “Dispatch interfaces”, for more
73 information on type libraries.)
74 It produces a DLL file that encapsulates the Caml and C object files
75 given on the command line.</p><p>Use <span class=machine><span class=font-tt>regsvr32 /s </span></span><span class=font-it>file</span><span class=machine><span class=font-tt>.dll</span></span> to record the components in the
76 system registry once it is compiled to a DLL.</p>
77 <hr>
78 <a href="main003.html"><img src="previous_motif.svg" alt="Previous"></a>
79 <a href="index.html"><img src="contents_motif.svg" alt="Up"></a>
80 <a href="main005.html"><img src="next_motif.svg" alt="Next"></a>
81 </body>
82 </html>