scilab: add help on primitive type mappings
This commit is contained in:
parent
d004632db5
commit
1eeb729487
1 changed files with 84 additions and 31 deletions
|
|
@ -27,6 +27,7 @@
|
||||||
<li><a href="#Scilab_wrapping_identifiers">Identifiers</a>
|
<li><a href="#Scilab_wrapping_identifiers">Identifiers</a>
|
||||||
<li><a href="#Scilab_wrapping_modules">Modules</a>
|
<li><a href="#Scilab_wrapping_modules">Modules</a>
|
||||||
<li><a href="#Scilab_wrapping_functions">Functions</a>
|
<li><a href="#Scilab_wrapping_functions">Functions</a>
|
||||||
|
<li><a href="#Scilab_wrapping_type_mappings">Default primitive type mappings</a>
|
||||||
<li><a href="#Scilab_wrapping_global_variables">Global variables</a>
|
<li><a href="#Scilab_wrapping_global_variables">Global variables</a>
|
||||||
<li><a href="#Scilab_wrapping_constants">Constants</a>
|
<li><a href="#Scilab_wrapping_constants">Constants</a>
|
||||||
<li><a href="#Scilab_wrapping_enums">Enums</a>
|
<li><a href="#Scilab_wrapping_enums">Enums</a>
|
||||||
|
|
@ -333,7 +334,59 @@ Creates a built-in function <tt>fact(n)</tt> that works exactly like you think i
|
||||||
ans=24
|
ans=24
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_global_variables"></a>37.3.4 Global variables</H3>
|
<H3><a name="Scilab_wrapping_primitive_type_mappings"></a>37.3.4 Default primitive type mappings</H3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following table give for each C/C++ primitive type the equivalent Scilab type.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="table">
|
||||||
|
<table border="1" sumary="Scilab default primitive type mappings">
|
||||||
|
<tr>
|
||||||
|
<td><b>C/C++ type</b></td>
|
||||||
|
<td><b>Scilab type</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td>bool</td><td>boolean</td></tr>
|
||||||
|
<tr><td>char</td><td>string</td></tr>
|
||||||
|
<tr><td>signed char</td><td>double or int8</td></tr>
|
||||||
|
<tr><td>unsigned char</td><td>uint8</td></tr>
|
||||||
|
<tr><td>short</td><td>double or int16</td></tr>
|
||||||
|
<tr><td>unsigned short</td><td>uint16</td></tr>
|
||||||
|
<tr><td>int</td><td>double or int32</td></tr>
|
||||||
|
<tr><td>unsigned int</td><td>uint32</td></tr>
|
||||||
|
<tr><td>long</td><td>double or int32</td></tr>
|
||||||
|
<tr><td>unsigned long</td><td>uint32</td></tr>
|
||||||
|
<tr><td>signed long long</td><td>not supported with Scilab 5.x</td></tr>
|
||||||
|
<tr><td>unsigned long long</td><td>not supported with Scilab 5.x</td></tr>
|
||||||
|
<tr><td>float</td><td>double</td></tr>
|
||||||
|
<tr><td>double</td><td>double</td></tr>
|
||||||
|
<tr><td>char* or char[]</td><td>string</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Notes:
|
||||||
|
<ul>
|
||||||
|
<li>Double type in Scilab is far more used than integer type.
|
||||||
|
That's why signed integer values (short, int, integer, long) are automatically converted to Scilab double values in output of a C function.
|
||||||
|
Also in input, double values are converted from doubles into the appropriate integer type.
|
||||||
|
Note that this conversion does not occur with unsigned integers.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
In SWIG for Scilab 5.x long long type is not supported since Scilab 5.x does not have a 64-bit integer type.
|
||||||
|
In that case, SWIG displays an error when wrapping a function that has long long type arguments.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<H3><a name="Scilab_wrapping_non-primitive_type_mappings"></a>37.3.5 Default type mappings for non-primitive types</H3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The default mapped type for C/C++ non-primitive types is the Scilab pointer. That is the case for exemple for C structs, C++ classes, ...
|
||||||
|
But there are many type mappings for non-primitive types (such as enums, arrays, STL types, etc...). Each of them is described further in this document.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<H3><a name="Scilab_wrapping_global_variables"></a>37.3.6 Global variables</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -353,7 +406,7 @@ c = 3
|
||||||
ans = 4
|
ans = 4
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_constants"></a>37.3.5 Constants</H3>
|
<H3><a name="Scilab_wrapping_constants"></a>37.3.7 Constants</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -395,7 +448,7 @@ ans= 37
|
||||||
ans= 3.14
|
ans= 3.14
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_enums"></a>37.3.6 Enums</H3>
|
<H3><a name="Scilab_wrapping_enums"></a>37.3.8 Enums</H3>
|
||||||
|
|
||||||
|
|
||||||
<p> The way SWIG deals with the enums is similar to constants. For example:
|
<p> The way SWIG deals with the enums is similar to constants. For example:
|
||||||
|
|
@ -423,11 +476,11 @@ typedef enum { RED, BLUE, GREEN } color;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_pointers"></a>37.3.7 Pointers</H3>
|
<H3><a name="Scilab_wrapping_pointers"></a>37.3.9 Pointers</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Pointers are fully supported by SWIG. One way to deal with the pointers is using the INPUT and OUTPUT typemaps. For example, in order to call C functions as the following:
|
Pointers are fully supported by SWIG. One way to deal with the pointers is using the INPUT and OUTPUT typemaps. For example, in order to call C functions as the following:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -471,7 +524,7 @@ extern int divide(int n, int d, int *r);
|
||||||
we only need a real value instead.
|
we only need a real value instead.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_structs"></a>37.3.8 Structs</H3>
|
<H3><a name="Scilab_wrapping_structs"></a>37.3.10 Structs</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -499,7 +552,7 @@ ans =
|
||||||
100
|
100
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_arrays"></a>37.3.9 Arrays</H3>
|
<H3><a name="Scilab_wrapping_arrays"></a>37.3.11 Arrays</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -546,7 +599,7 @@ ans =
|
||||||
0. 0.1428571 0.2857143 0.4285714 0.5714286 0.7142857 0.8571429
|
0. 0.1428571 0.2857143 0.4285714 0.5714286 0.7142857 0.8571429
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_matrices"></a>37.3.10 Matrices</H3>
|
<H3><a name="Scilab_wrapping_matrices"></a>37.3.12 Matrices</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -660,7 +713,7 @@ void mat_mult(double **m1, double **m2, double **m3) {
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_classes"></a>37.4.11 Classes</H3>
|
<H3><a name="Scilab_wrapping_classes"></a>37.4.13 Classes</H3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The classes are wrapped in the same manner as structs, through functions. For example, the following class:
|
The classes are wrapped in the same manner as structs, through functions. For example, the following class:
|
||||||
|
|
@ -694,14 +747,14 @@ ans =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_templates"></a>37.4.12 Templates</H3>
|
<H3><a name="Scilab_wrapping_templates"></a>37.4.14 Templates</H3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Templates are supported. See the SWIG general documentation on how templates are interfaced in SWIG.<br>
|
Templates are supported. See the SWIG general documentation on how templates are interfaced in SWIG.<br>
|
||||||
An example of templates can be found in <tt>Examples/scilab/templates</tt>.
|
An example of templates can be found in <tt>Examples/scilab/templates</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_stl"></a>37.4.13 STL</H3>
|
<H3><a name="Scilab_wrapping_stl"></a>37.4.15 STL</H3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Standard Template Library (STL) is partially supported.
|
Standard Template Library (STL) is partially supported.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue