global variable
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11249 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4aa72f9b01
commit
25f17ae463
5 changed files with 183 additions and 72 deletions
|
|
@ -1,4 +1,5 @@
|
|||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <sciprimtype.swg>
|
||||
%include <scitypemaps.swg>
|
||||
|
||||
|
|
|
|||
|
|
@ -12,49 +12,69 @@
|
|||
//%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
|
||||
%typemap(in) char (int m, int n,int l),
|
||||
signed char (int m,int n,int l),
|
||||
unsigned char(int m,int n,int l)
|
||||
%typemap(in) char (int *piAddrVar, int iRows, int iCols),
|
||||
signed char (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned char(int *piAddrVar, int iRows, int iCols)
|
||||
{
|
||||
if (GetType($argnum) == sci_strings)
|
||||
{
|
||||
GetRhsVar($argnum,STRING_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)(*cstk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
char* _piData8;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
if(getVarType(piAddrVar) != sci_matrix || iRows1 != 1 || iCols1 != 1 || isVarComplex(piAddrVar))
|
||||
{
|
||||
Scierror(999,_("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfInteger8(piAddrVar, &iRows, &iCols, &_piData8);
|
||||
$1=_piData8[0];
|
||||
}
|
||||
|
||||
%typemap(in) short (int m, int n,int l),
|
||||
unsigned short (int m,int n,int l),
|
||||
int(int m,int n,int l),
|
||||
unsigned int(int m, int n,int l),
|
||||
long(int m,int n,int l),
|
||||
unsigned long(int m,int n,int l),
|
||||
double(int m,int n,int l)
|
||||
%typemap(in) short (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned short (int *piAddrVar, int iRows, int iCols)
|
||||
|
||||
{ short* _piData16;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
if(getVarType(piAddrVar) != sci_matrix || iRows1 != 1 || iCols1 != 1 || isVarComplex(piAddrVar))
|
||||
{
|
||||
Scierror(999,_("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfInteger16(piAddrVar, &iRows, &iCols, &_piData16);
|
||||
$1= _piData16[0];
|
||||
|
||||
}
|
||||
|
||||
%typemap(in) int (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned int (int *piAddrVar, int iRows, int iCols)
|
||||
|
||||
{ int* _piData32;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
if(getVarType(piAddrVar) != sci_matrix || iRows1 != 1 || iCols1 != 1 || isVarComplex(piAddrVar))
|
||||
{
|
||||
Scierror(999,_("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfInteger16(piAddrVar, &iRows, &iCols, &_piData32);
|
||||
$1= _piData32[0];
|
||||
|
||||
}
|
||||
|
||||
%typemap(in) long(int* piAddrVar,int iRows,int iCols),
|
||||
unsigned long(int* piAddrVar,int iRows,int iCols),
|
||||
double(int* piAddrVar,int iRows,int iCols),
|
||||
float (int* piAddrVar,int iRows,int iCols)
|
||||
|
||||
{
|
||||
if (GetType($argnum) == sci_matrix)
|
||||
{
|
||||
GetRhsVar($argnum,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)(*stk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
}
|
||||
|
||||
%typemap(in) float (int m, int n,int l)
|
||||
{
|
||||
if (GetType($argnum) == sci_matrix)
|
||||
{
|
||||
GetRhsVar($argnum,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)(*stk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
{ double *pdblReal;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
if(getVarType(piAddrVar) != sci_matrix || iRows1 != 1 || iCols1 != 1 || isVarComplex(piAddrVar))
|
||||
{
|
||||
Scierror(999,_("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &pdblReal);
|
||||
$1= pdblReal[0];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
%typemap(in) char *(int m,int n,int l)
|
||||
{
|
||||
if (GetType($argnum) == sci_strings)
|
||||
|
|
@ -65,54 +85,53 @@
|
|||
else
|
||||
Scierror(999,"error ...\n");
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
%typemap(out) char (int m, int n,int l),
|
||||
signed char (int m,int n,int l),
|
||||
unsigned char(int m,int n,int l)
|
||||
%typemap(out) char (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
signed char (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned char(int iRowsOut,int iColsOut,int* _piAddress)
|
||||
{
|
||||
m=1,n=1;
|
||||
CreateVar(Rhs+1,STRING_DATATYPE,&m,&n,&l);
|
||||
*cstk(l)=$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger8(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
}
|
||||
|
||||
%typemap(out) short (int m, int n,int l),
|
||||
unsigned short (int m,int n,int l),
|
||||
int(int m,int n,int l),
|
||||
unsigned int(int m, int n,int l),
|
||||
long(int m,int n,int l),
|
||||
unsigned long(int m,int n,int l),
|
||||
double(int m,int n,int l)
|
||||
%typemap(out) short (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned short(int iRowsOut,int iColsOut,int* _piAddress)
|
||||
|
||||
{
|
||||
m=1,n=1;
|
||||
CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
*stk(l)=(double)$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger16(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
}
|
||||
|
||||
%typemap(out) float (int m, int n,int l)
|
||||
%typemap(out) int (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned int(int iRowsOut,int iColsOut,int* _piAddress)
|
||||
|
||||
{
|
||||
m=1,n=1;
|
||||
CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
*stk(l)=(double)$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger32(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) char *(int m,int n, int l)
|
||||
%typemap(out) long(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned long(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
double(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
float(int iRowsOut,int iColsOut,int* _piAddress)
|
||||
{
|
||||
m=1;
|
||||
if ($1)
|
||||
n = (int)strlen($1);
|
||||
else
|
||||
n = (int)strlen("");
|
||||
|
||||
CreateVar(Rhs+1,STRING_DATATYPE ,&m,&n,&l);
|
||||
if ($1) strcpy(cstk(l),$1);
|
||||
else strcpy(cstk(l),"");
|
||||
LhsVar(1) = Rhs+1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixDouble(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue