From ed36fb862a94ae47f44205fec169461da147d5e3 Mon Sep 17 00:00:00 2001
From: Simon Marchetto
Notes:
unsigned int uint32 long double or int32
-unsigned long uint32
-signed long long not supported with Scilab 5.x
+unsigned long long not supported with Scilab 5.x
+signed long long not supported in Scilab 5.x unsigned long long not supported in Scilab 5.x float double double double
@@ -775,13 +775,16 @@ The following table give for each C/C++ primitive type the equivalent Scilab typ
char* or char[] string
-
@@ -802,34 +805,52 @@ Typemaps are available by default for arrays. Primitive type arrays are automati
-The type mappings used for arrays is the same for primtive types, described here. -It means that, if needed, a Scilab double vector is converted in input into a C int array. -And this C int array is automatically converted in output to a Scilab double vector. +In input, the matrix is usually one-dimensional (it can be either a row or column vector). But it can be also a two-dimensional matrix. +Warning: in Scilab, the values are column-major orderered, unlike in C, in which there are row-major ordered.
-This example illustrates this:
+The type mappings used for arrays is the same for primtive types, described here. +It means that, if needed, a Scilab double vector is converted in input into a C int array. +And this C int array is automatically converted in output to a Scilab double vector. +Note that unlike scalars, no control is done for arrays when a double is converted to integer. + + ++
+ ++This example illustrates all this:
%module example
+%#include <stdio.h>
+
%inline %{
-int sumArray(int values[], int len) {
- int s = 0;
+void printArray(int values[], int len) {
int i = 0;
- for (i=0; i < len; i++)
- s += values[i];
- return s;
+ for (i = 0; i < len; i++) {
+ printf("%s %d %s", i==0?"[":"", values[i], i==len-1?"]\n":"");
+ }
+}
%}
---> sum([1. 2. 3. 5.], 4); - ans = +--> printArray([0 1 2 3], 4) +[ 0 1 2 3 ] - 11. +-->printArray([0.2; -1.8; 2; 3.7], 4) +[ 0 -1 2 3 ] + +--> printArray([0 1; 2 3], 4) +[ 0 2 1 3 ] + +--> printArray([0; 1; 2; 3], 4) +[ 0 1 2 3 ]
+The remarks made for arrays remain here: +