Scilab: fix matrix typemap parameter names

This commit is contained in:
Simon Marchetto 2013-06-19 16:28:57 +02:00
commit 9b270b9f6a
2 changed files with 78 additions and 72 deletions

View file

@ -5,7 +5,9 @@
%include <scidouble.swg> %include <scidouble.swg>
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double* matrixAsInput, int rows, int cols) // in (double* matrixIn, int matrixInRowCount, int matrixInColCount)
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double* matrixIn, int matrixInRowCount, int matrixInColCount)
{ {
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR) if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR)
{ {
@ -13,7 +15,9 @@
} }
} }
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int rows, int cols, double* matrixAsInput) // in (int matrixInRowCount, int matrixInColCount, double* matrixIn)
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int matrixInRowCount, int matrixInColCount, double* matrixIn)
{ {
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR) if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR)
{ {
@ -21,13 +25,15 @@
} }
} }
%typemap(in) (double* matrixAsInput, int size) // in (double* vectorIn, int vectorInSize)
%typemap(in) (double* vectorIn, int vectorInSize)
{ {
int nbRows; int rowCount;
int nbCols; int colCount;
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$1, fname) != SWIG_ERROR) if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) != SWIG_ERROR)
{ {
$2 = nbRows * nbCols; $2 = rowCount * colCount;
} }
else else
{ {
@ -35,13 +41,15 @@
} }
} }
%typemap(in) (int size, double* matrixAsInput) // in (int vectorInSize, double* vectorIn)
%typemap(in) (int vectorInSize, double* vectorIn)
{ {
int nbRows; int rowCount;
int nbCols; int colCount;
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$2, fname) != SWIG_ERROR) if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) != SWIG_ERROR)
{ {
$1 = nbRows * nbCols; $1 = rowCount * colCount;
} }
else else
{ {
@ -49,18 +57,20 @@
} }
} }
%typemap(in, numinputs=0) (double** matrixAsOutput, int* rows, int* cols) // out (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
%typemap(in, numinputs=0) (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
} }
%typemap(arginit) (double** matrixAsOutput, int* rows, int* cols) %typemap(arginit) (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
$1 = (double**) malloc(sizeof(double*)); $1 = (double**) malloc(sizeof(double*));
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
$3 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int));
} }
%typemap(freearg) (double** matrixAsOutput, int* rows, int* cols) %typemap(freearg) (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
free(*$1); free(*$1);
free($1); free($1);
@ -68,7 +78,7 @@
free($3); free($3);
} }
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double** matrixAsOutput, int* rows, int* cols) %typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR) if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR)
{ {
@ -80,22 +90,22 @@
} }
} }
// (int* rows, int* cols, double** matrixAsOutput) // out (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
%typemap(in, numinputs=0) (int* rows, int* cols, double** matrixAsOutput) %typemap(in, numinputs=0) (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
{ {
} }
%typemap(arginit) (int* rows, int* cols, double** matrixAsOutput) %typemap(arginit) (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
{ {
$1 = (int*) malloc(sizeof(int)); $1 = (int*) malloc(sizeof(int));
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
$3 = (double**) malloc(sizeof(double*)); $3 = (double**) malloc(sizeof(double*));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* rows, int* cols, double** matrixAsOutput) %typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int* matrixInRowCount, int* matrixInColCount, double** matrixOut)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR) if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR)
{ {
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(); AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
} }
@ -105,7 +115,7 @@
} }
} }
%typemap(freearg) (int* rows, int* cols, double** matrixAsOutput) %typemap(freearg) (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
{ {
free($1); free($1);
free($2); free($2);
@ -114,21 +124,20 @@
} }
// (double** matrixAsOutput, int* size) // out (double** vectorOut, int* vectorOutSize)
%typemap(in, numinputs=0) (double** matrixAsOutput, int* size) %typemap(in, numinputs=0) (double** vectorOut, int* vectorOutSize)
{ {
} }
%typemap(arginit) (double** matrixAsOutput, int* size) %typemap(arginit) (double** vectorOut, int* vectorOutSize)
{ {
$1 = (double**) malloc(sizeof(double*)); $1 = (double**) malloc(sizeof(double*));
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (double** matrixAsOutput, int* size) %typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double** vectorOut, int* vectorOutSize)
{ {
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR) if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR)
{ {
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(); AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
@ -139,7 +148,7 @@
} }
} }
%typemap(freearg) (double** matrixAsOutput, int* size) %typemap(freearg) (double** vectorOut, int* vectorOutSize)
{ {
free(*$1); free(*$1);
free($1); free($1);
@ -147,21 +156,20 @@
} }
// (int* size, double** matrixAsOutput) // out (int* vectorOutSize, double** vectorOut)
%typemap(in, numinputs=0) (int* size, double** matrixAsOutput) %typemap(in, numinputs=0) (int* vectorOutSize, double** vectorOut)
{ {
} }
%typemap(arginit) (int* size, double** matrixAsOutput) %typemap(arginit) (int* vectorOutSize, double** vectorOut)
{ {
$1 = (int*) malloc(sizeof(int)); $1 = (int*) malloc(sizeof(int));
$2 = (double**) malloc(sizeof(double*)); $2 = (double**) malloc(sizeof(double*));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* size, double** matrixAsOutput) %typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int* vectorOutSize, double** vectorOut)
{ {
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR) if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR)
{ {
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(); AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
@ -172,7 +180,7 @@
} }
} }
%typemap(freearg) (int* size, double** matrixAsOutput) %typemap(freearg) (int* vectorOutSize, double** vectorOut)
{ {
free($1); free($1);
free(*$2); free(*$2);

View file

@ -5,9 +5,9 @@
%include <sciint.swg> %include <sciint.swg>
// (int* matrixAsInput, int rows, int cols) // in (int* matrixIn, int matrixInRowCount, int matrixInColCount)
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int* matrixAsInput, int rows, int cols) %typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int* matrixIn, int matrixInRowCount, int matrixInColCount)
{ {
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR) if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR)
{ {
@ -16,9 +16,9 @@
} }
// (int rows, int cols, int* matrixAsInput) // in (int matrixInRowCount, int matrixInColCount, int* matrixIn)
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int rows, int cols, int* matrixAsInput) %typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int matrixInRowCount, int matrixInColCount, int* matrixIn)
{ {
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR) if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR)
{ {
@ -27,15 +27,15 @@
} }
// (int* matrixAsInput, int size) // in (int* vectorIn, int vectorInSize)
%typemap(in) (int* matrixAsInput, int size) %typemap(in) (int* vectorIn, int vectorInSize)
{ {
int nbRows; int rowCount;
int nbCols; int colCount;
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$1, fname) != SWIG_ERROR) if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) != SWIG_ERROR)
{ {
$2 = nbRows * nbCols; $2 = rowCount * colCount;
} }
else else
{ {
@ -44,15 +44,15 @@
} }
// (int size, int* matrixAsInput) // in (int vectorInSize, int* vectorInSize)
%typemap(in) (int size, int* matrixAsInput) %typemap(in) (int vectorInSize, int* vectorInSize)
{ {
int nbRows; int rowCount;
int nbCols; int colCount;
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$2, fname) != SWIG_ERROR) if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) != SWIG_ERROR)
{ {
$1 = nbRows * nbCols; $1 = rowCount * colCount;
} }
else else
{ {
@ -60,20 +60,20 @@
} }
} }
// (int** matrixAsOutput, int* rows, int* cols) // out (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
%typemap(in, numinputs=0) (int** matrixAsOutput, int* rows, int* cols) %typemap(in, numinputs=0) (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
} }
%typemap(arginit) (int** matrixAsOutput, int* rows, int* cols) %typemap(arginit) (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
$1 = (int**) malloc(sizeof(int*)); $1 = (int**) malloc(sizeof(int*));
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
$3 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixAsOutput, int* rows, int* cols) %typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR) if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR)
{ {
@ -85,7 +85,7 @@
} }
} }
%typemap(freearg) (int** matrixAsOutput, int* rows, int* cols) %typemap(freearg) (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
free(*$1); free(*$1);
free($1); free($1);
@ -94,20 +94,20 @@
} }
// (int* rows, int* cols, int** matrixAsOutput) // out (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
%typemap(in, numinputs=0) (int* rows, int* cols, int** matrixAsOutput) %typemap(in, numinputs=0) (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
{ {
} }
%typemap(arginit) (int* rows, int* cols, int** matrixAsOutput) %typemap(arginit) (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
{ {
$1 = (int*) malloc(sizeof(int)); $1 = (int*) malloc(sizeof(int));
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
$3 = (int**) malloc(sizeof(int*)); $3 = (int**) malloc(sizeof(int*));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* rows, int* cols, int** matrixAsOutput) %typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR) if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR)
{ {
@ -119,7 +119,7 @@
} }
} }
%typemap(freearg) (int* rows, int* cols, int** matrixAsOutput) %typemap(freearg) (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
{ {
free($1); free($1);
free($2); free($2);
@ -128,21 +128,20 @@
} }
// (int** matrixAsOutput, int* size) // out (int** vectorOut, int* vectorOutSize)
%typemap(in, numinputs=0) (int** matrixAsOutput, int* size) %typemap(in, numinputs=0) (int** vectorOut, int* vectorOutSize)
{ {
} }
%typemap(arginit) (int** matrixAsOutput, int* size) %typemap(arginit) (int** vectorOut, int* vectorOutSize)
{ {
$1 = (int**) malloc(sizeof(int*)); $1 = (int**) malloc(sizeof(int*));
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixAsOutput, int* size) %typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** vectorOut, int* vectorOutSize)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR) if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR)
{ {
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(); AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
@ -153,7 +152,7 @@
} }
} }
%typemap(freearg) (int** matrixAsOutput, int* size) %typemap(freearg) (int** vectorOut, int* vectorOutSize)
{ {
free(*$1); free(*$1);
free($1); free($1);
@ -161,21 +160,20 @@
} }
// (int* size, int** matrixAsOutput) // out (int* vectorOutSize, int** vectorOut)
%typemap(in, numinputs=0) (int* size, int** matrixAsOutput) %typemap(in, numinputs=0) (int* vectorOutSize, int** vectorOut)
{ {
} }
%typemap(arginit) (int* size, int** matrixAsOutput) %typemap(arginit) (int* vectorOutSize, int** vectorOut)
{ {
$1 = (int*) malloc(sizeof(int)); $1 = (int*) malloc(sizeof(int));
$2 = (int**) malloc(sizeof(int*)); $2 = (int**) malloc(sizeof(int*));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* size, int** matrixAsOutput) %typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* vectorOutSize, int** vectorOut)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR) if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR)
{ {
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(); AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
@ -186,7 +184,7 @@
} }
} }
%typemap(freearg) (int* size, int** matrixAsOutput) %typemap(freearg) (int* vectorInSize, int** vectorOut)
{ {
free($1); free($1);
free(*$2); free(*$2);