cosmetic changes in doc
This commit is contained in:
parent
0544765abd
commit
7c9a9aee70
1 changed files with 120 additions and 70 deletions
|
|
@ -157,7 +157,7 @@ it may be because the SWIG library is not found. Check the <tt>SWIG_LIB</tt> env
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note: SWIG for Scilab can work in two modes related to the way the module is build, see the <a href="#Scilab_building_modes">Building modes</a> section for details.
|
Note: SWIG for Scilab can work in two modes related to the way the module is built, see the <a href="#Scilab_building_modes">Building modes</a> section for details.
|
||||||
This example uses the <tt>builder</tt> mode.
|
This example uses the <tt>builder</tt> mode.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ The <tt>swig</tt> executable has several other command line options you can use.
|
||||||
<H3><a name="Scilab_running_swig_building_module"></a>37.2.2 Building the module</H3>
|
<H3><a name="Scilab_running_swig_building_module"></a>37.2.2 Building the module</H3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
To be loaded in Scilab, the wrapper has to be build into a dynamic module (or shared library).
|
To be loaded in Scilab, the wrapper has to be built into a dynamic module (or shared library).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -183,7 +183,7 @@ $ gcc -shared example_wrap.o -o libexample.so
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note: we supposed in this example the path to the Scilab include directory is <tt>/usr/local/include/scilab</tt> (which is the case in a Debian environment), this sould be changed for another environment.
|
Note: we supposed in this example that the path to the Scilab include directory is <tt>/usr/local/include/scilab</tt> (which is the case in a Debian environment), this should be changed for another environment.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_loading_module"></a>37.2.3 Loading the module</H3>
|
<H3><a name="Scilab_running_swig_loading_module"></a>37.2.3 Loading the module</H3>
|
||||||
|
|
@ -206,7 +206,7 @@ Link done.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Which means that Scilab has sucessfully loaded the shared library. The module functions and other symbols are now available in Scilab.
|
which means that Scilab has successfully loaded the shared library. The module functions and other symbols are now available in Scilab.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_using_module"></a>37.2.4 Using the module</H3>
|
<H3><a name="Scilab_running_swig_using_module"></a>37.2.4 Using the module</H3>
|
||||||
|
|
@ -217,23 +217,29 @@ In Scilab, the function <tt>fact()</tt> is simply called as following:
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
--> fact(5)
|
--> fact(5)
|
||||||
ans = 120
|
ans =
|
||||||
|
|
||||||
|
120.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>For the <tt>Foo</tt> global variable, the accessors need to be used:
|
<p>For the <tt>Foo</tt> global variable, the accessors need to be used:
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
--> Foo_get
|
--> Foo_get
|
||||||
ans = 3
|
ans =
|
||||||
|
|
||||||
|
3.
|
||||||
|
|
||||||
--> Foo_set(4);
|
--> Foo_set(4);
|
||||||
|
|
||||||
--> Foo_get
|
--> Foo_get
|
||||||
ans = 4
|
ans =
|
||||||
|
|
||||||
|
4.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note: in order to be concise, the remaining Scilab code examples assume the modules have been successfully built and loaded in Scilab.
|
Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_options"></a>37.2.5 Scilab command line options</H3>
|
<H3><a name="Scilab_running_swig_options"></a>37.2.5 Scilab command line options</H3>
|
||||||
|
|
@ -455,10 +461,14 @@ These functions are used as following:
|
||||||
--> Foo_set(4);
|
--> Foo_set(4);
|
||||||
|
|
||||||
--> c
|
--> c
|
||||||
c = 3
|
c =
|
||||||
|
|
||||||
|
3.
|
||||||
|
|
||||||
--> Foo_get()
|
--> Foo_get()
|
||||||
ans = 4
|
ans =
|
||||||
|
|
||||||
|
4.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -498,8 +508,6 @@ It works the same:</p>
|
||||||
|
|
||||||
--> y_set([0:6] / 10);
|
--> y_set([0:6] / 10);
|
||||||
--> y_get()
|
--> y_get()
|
||||||
|
|
||||||
-->
|
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
0. 0.1 0.2 0.3 0.4 0.5 0.6
|
0. 0.1 0.2 0.3 0.4 0.5 0.6
|
||||||
|
|
@ -532,30 +540,45 @@ the following getter functions are generated:
|
||||||
--> exec loader.sce;
|
--> exec loader.sce;
|
||||||
--> ICONST_get();
|
--> ICONST_get();
|
||||||
ans =
|
ans =
|
||||||
42
|
|
||||||
|
42.
|
||||||
|
|
||||||
--> FCONST_get();
|
--> FCONST_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
2.1828
|
2.1828
|
||||||
|
|
||||||
--> CCONST_get();
|
--> CCONST_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
x
|
x
|
||||||
|
|
||||||
--> CCONST2_get();
|
--> CCONST2_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
--> SCONST_get();
|
--> SCONST_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
Hello World
|
Hello World
|
||||||
|
|
||||||
--> SCONST2_get();
|
--> SCONST2_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
"Hello World"
|
"Hello World"
|
||||||
|
|
||||||
--> EXPR_get();
|
--> EXPR_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
48.5484
|
48.5484
|
||||||
|
|
||||||
--> iconst_get();
|
--> iconst_get();
|
||||||
ans =
|
ans =
|
||||||
37
|
|
||||||
|
37.
|
||||||
|
|
||||||
--> fconst_get();
|
--> fconst_get();
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
3.14
|
3.14
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
@ -591,30 +614,45 @@ are mapped to Scilab variables, with the same name:
|
||||||
--> exec loader.sce;
|
--> exec loader.sce;
|
||||||
--> ICONST
|
--> ICONST
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
42
|
42
|
||||||
|
|
||||||
--> FCONST
|
--> FCONST
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
2.1828
|
2.1828
|
||||||
|
|
||||||
--> CCONST
|
--> CCONST
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
x
|
x
|
||||||
|
|
||||||
--> CCONST2
|
--> CCONST2
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
--> SCONST
|
--> SCONST
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
Hello World
|
Hello World
|
||||||
|
|
||||||
--> SCONST2
|
--> SCONST2
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
"Hello World"
|
"Hello World"
|
||||||
|
|
||||||
--> EXPR
|
--> EXPR
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
48.5484
|
48.5484
|
||||||
|
|
||||||
--> iconst
|
--> iconst
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
37
|
37
|
||||||
|
|
||||||
--> fconst
|
--> fconst
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
3.14
|
3.14
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
@ -638,12 +676,17 @@ a getter function will be generated for each value of the enumeration:
|
||||||
--> exec loader.sce;
|
--> exec loader.sce;
|
||||||
--> RED_get()
|
--> RED_get()
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
0.
|
0.
|
||||||
|
|
||||||
--> BLUE_get()
|
--> BLUE_get()
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
1.
|
1.
|
||||||
|
|
||||||
--> GREEN_get()
|
--> GREEN_get()
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
2.
|
2.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
@ -661,13 +704,19 @@ typedef enum { RED, BLUE, GREEN } color;
|
||||||
--> exec loader.sce;
|
--> exec loader.sce;
|
||||||
--> RED
|
--> RED
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
0.
|
0.
|
||||||
|
|
||||||
--> BLUE
|
--> BLUE
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
1.
|
1.
|
||||||
|
|
||||||
--> GREEN
|
--> GREEN
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
2.
|
2.
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -894,6 +943,7 @@ can be used in Scilab like this:
|
||||||
--> p2 = Point_new(1, 2);
|
--> p2 = Point_new(1, 2);
|
||||||
--> p1.distance(p2)
|
--> p1.distance(p2)
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
3.6056
|
3.6056
|
||||||
|
|
||||||
--> delete_Point(p1);
|
--> delete_Point(p1);
|
||||||
|
|
@ -1344,7 +1394,7 @@ The following table provides the equivalent Scilab type for C/C++ primitive type
|
||||||
<p>
|
<p>
|
||||||
Notes:
|
Notes:
|
||||||
<ul>
|
<ul>
|
||||||
<li>In Scilab the <tt>double</tt> type is used far more than any integer type.
|
<li>In Scilab the <tt>double</tt> type is far more used than any integer type.
|
||||||
This is why integer values (<tt>int32</tt>, <tt>uint32</tt>, ...) are automatically converted to Scilab <tt>double</tt> values when marshalled from C into Scilab.
|
This is why integer values (<tt>int32</tt>, <tt>uint32</tt>, ...) are automatically converted to Scilab <tt>double</tt> values when marshalled from C into Scilab.
|
||||||
Additionally on input to a C function, Scilab <tt>double</tt> values are converted into the related integer type.
|
Additionally on input to a C function, Scilab <tt>double</tt> values are converted into the related integer type.
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue