add support for constants
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11251 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
25f17ae463
commit
4e9cbd8a7c
15 changed files with 470 additions and 142 deletions
|
|
@ -1,5 +1,5 @@
|
|||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <sciprimtype.swg>
|
||||
%include <sciprimtypes.swg>
|
||||
%include <scitypemaps.swg>
|
||||
|
||||
|
|
|
|||
1
Lib/scilab/sciprimtypes.swg
Normal file
1
Lib/scilab/sciprimtypes.swg
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -12,131 +12,115 @@
|
|||
//%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
|
||||
%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)
|
||||
{
|
||||
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) signed char (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned char (int *piAddrVar, int iRows, int iCols),
|
||||
short (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned short (int *piAddrVar, int iRows, int iCols),
|
||||
int (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned int (int *piAddrVar, int iRows, int iCols),
|
||||
long (int *piAddrVar, int iRows, int iCols),
|
||||
unsigned long (int *piAddrVar, int iRows, int iCols),
|
||||
float (int *piAddrVar, int iRows, int iCols),
|
||||
double (int *piAddrVar, int iRows, int iCols) {
|
||||
double* _piData;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_matrix || iRows != 1 || iCols != 1 || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||
$1=($1_ltype)*_piData;
|
||||
}
|
||||
|
||||
%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) char (int *piAddrVar, int iRows, int iCols) {
|
||||
char* _pstStrings;
|
||||
int _piLength;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_strings || iRows != 1 || iCols != 1 || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfString(piAddrVar, &iRows, &iCols,&_piLength, &_pstStrings);
|
||||
$1=($1_ltype)*_pstStrings;
|
||||
|
||||
}
|
||||
|
||||
%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)
|
||||
|
||||
{ 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)
|
||||
{
|
||||
GetRhsVar($argnum,STRING_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)strdup(cstk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
%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)
|
||||
{
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger8(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
%typemap(out) signed char (int iRowsOut,int iColsOut,int* _piAddress) {
|
||||
char temp;
|
||||
temp=(char)$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger8(Rhs+1, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
%typemap(out) short (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned short(int iRowsOut,int iColsOut,int* _piAddress)
|
||||
|
||||
{
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger16(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
unsigned char (int iRowsOut,int iColsOut,int* _piAddress) {
|
||||
short temp;
|
||||
temp=(short)$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger16(Rhs+1, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
%typemap(out) int (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned int(int iRowsOut,int iColsOut,int* _piAddress)
|
||||
|
||||
{
|
||||
unsigned int (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned short (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
unsigned long (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
long (int iRowsOut,int iColsOut,int* _piAddress) {
|
||||
int temp;
|
||||
temp=(int)$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfInteger32(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
createMatrixOfInteger32(Rhs+1, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
}
|
||||
|
||||
|
||||
%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)
|
||||
{
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixDouble(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
PutLhsVar();
|
||||
%typemap(out) double (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
float (int iRowsOut,int iColsOut,int* _piAddress) {
|
||||
double temp;
|
||||
temp=(double)$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfDouble(Rhs+1, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
%typemap(out) char (int iRowsOut,int iColsOut,int* _piAddress) {
|
||||
char* temp;
|
||||
temp=(char*)&$1;
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfString(Rhs+1, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
|
||||
%typemap(out,noblock=1) void
|
||||
{
|
||||
%typemap(out,noblock=1) void {
|
||||
}
|
||||
|
||||
%typemap(in) char *(int *piAddrVar, int iRows, int iCols) {
|
||||
char* _pstStrings;
|
||||
int _piLength;
|
||||
getVarAddressFromNumber($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_strings || iRows != 1 || iCols != 1 || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, 1);
|
||||
}
|
||||
getMatrixOfString(piAddrVar, &iRows, &iCols,&_piLength, &_pstStrings);
|
||||
$1=strdup(_pstStrings);
|
||||
}
|
||||
|
||||
%typemap(out) char *(int iRowsOut,int iColsOut,int* _piAddress){
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfString(Rhs+1, iRowsOut, iColsOut, &$1, &_piAddress);
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue