clear up some code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11351 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
86a125e910
commit
59b9f3b6de
5 changed files with 310 additions and 104 deletions
|
|
@ -58,6 +58,77 @@
|
|||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_ints || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||
}
|
||||
getMatrixOfInteger8(piAddrVar, &iRows, &iCols, &_piData);
|
||||
$1=($1_ltype)_piData;
|
||||
}
|
||||
|
||||
%typemap(in) short *(int *piAddrVar, int iRows, int iCols),
|
||||
unsigned char *(int *piAddrVar, int iRows, int iCols) {
|
||||
short* _piData;
|
||||
int index;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_ints || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||
}
|
||||
getMatrixOfInteger16(piAddrVar, &iRows, &iCols, &_piData);
|
||||
$1=($1_ltype)_piData;
|
||||
}
|
||||
|
||||
%typemap(in) 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) {
|
||||
int* _piData;
|
||||
int index;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_ints || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||
}
|
||||
getMatrixOfInteger32(piAddrVar, &iRows, &iCols, &_piData);
|
||||
$1=($1_ltype)_piData;
|
||||
}
|
||||
|
||||
%typemap(in) double *(int *piAddrVar, int iRows, int iCols),
|
||||
float *(int *piAddrVar, int iRows, int iCols) {
|
||||
double* _piData;
|
||||
int index;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_matrix || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||
}
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||
$1=($1_ltype)_piData;
|
||||
}
|
||||
|
||||
%typemap(in) char *(int *piAddrVar, int iRows, int iCols){
|
||||
char* _pstStrings;
|
||||
int _piLength;
|
||||
getVarAddressFromPosition($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, $argnum);
|
||||
}
|
||||
getMatrixOfString(piAddrVar, &iRows, &iCols,&_piLength, &_pstStrings);
|
||||
$1=strdup(_pstStrings);
|
||||
}
|
||||
|
||||
%typemap(in) signed char [ANY](int *piAddrVar, int iRows, int iCols) {
|
||||
char* _piData;
|
||||
int index;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) != sci_ints || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||
}
|
||||
|
|
@ -71,9 +142,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) short *(int *piAddrVar, int iRows, int iCols),
|
||||
unsigned char *(int *piAddrVar, int iRows, int iCols),
|
||||
short [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
%typemap(in) short [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
unsigned char [ANY](int *piAddrVar, int iRows, int iCols) {
|
||||
short* _piData;
|
||||
int index;
|
||||
|
|
@ -93,12 +162,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) 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),
|
||||
unsigned short [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
%typemap(in) unsigned short [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
int [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
unsigned int [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
long [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
|
|
@ -121,50 +185,29 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) double *(int *piAddrVar, int iRows, int iCols),
|
||||
float *(int *piAddrVar, int iRows, int iCols),
|
||||
double [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
%typemap(in) double [ANY](int *piAddrVar, int iRows, int iCols),
|
||||
float [ANY](int *piAddrVar, int iRows, int iCols){
|
||||
double* _piData;
|
||||
int index;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) == sci_matrix ){
|
||||
if(!isVarComplex(piAddrVar)) {
|
||||
isComplex=0;
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||
if($1!=NULL) {
|
||||
free($1);
|
||||
}
|
||||
$1=($1_ltype)malloc(iRows*iCols*sizeof($*1_ltype));
|
||||
for(index=0;index<iRows*iCols;index++){
|
||||
$1[index]=($*1_ltype)_piData[index];
|
||||
}
|
||||
}
|
||||
else {
|
||||
isComplex=1;
|
||||
double *_pdblImg;
|
||||
getComplexMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData, &_pdblImg);
|
||||
if($1!=NULL) {
|
||||
free($1);
|
||||
}
|
||||
$1=($1_ltype)malloc(2*iRows*iCols*sizeof($*1_ltype));
|
||||
for(index=0;index<iRows*iCols;index++){
|
||||
$1[index]=($*1_ltype)_piData[index];
|
||||
$1[index+iRows*iCols]=(double)_pdblImg[index];
|
||||
}
|
||||
}
|
||||
if (getVarType(piAddrVar) != sci_matrix || isVarComplex(piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||
}
|
||||
else {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: double matrix expected.\n"), fname, $argnum);
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||
if($1!=NULL) {
|
||||
free($1);
|
||||
}
|
||||
$1=($1_ltype)malloc(iRows*iCols*sizeof($*1_ltype));
|
||||
for(index=0;index<iRows*iCols;index++){
|
||||
$1[index]=($*1_ltype)_piData[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
%typemap(in) char *(int *piAddrVar, int iRows, int iCols),
|
||||
char [ANY](int *piAddrVar, int iRows, int iCols){
|
||||
%typemap(in) char [ANY](int *piAddrVar, int iRows, int iCols){
|
||||
char* _pstStrings;
|
||||
int _piLength;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
|
|
@ -177,6 +220,7 @@
|
|||
$1=strdup(_pstStrings);
|
||||
}
|
||||
|
||||
|
||||
/* Arrays */
|
||||
%typemap(in) signed char [ANY][ANY](int *piAddrVar, int iRows, int iCols) {
|
||||
char* _piData;
|
||||
|
|
@ -300,8 +344,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) short (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
|
|
@ -312,8 +354,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) int (int iRowsOut,int iColsOut,int* _piAddress),
|
||||
|
|
@ -327,8 +367,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) double (int iRowsOut,int iColsOut),
|
||||
|
|
@ -339,8 +377,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) char (int iRowsOut,int iColsOut) {
|
||||
|
|
@ -350,8 +386,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &temp);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1) void {
|
||||
|
|
@ -365,8 +399,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) short *(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
|
|
@ -377,8 +409,6 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) int *(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
|
|
@ -392,24 +422,18 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) double *,
|
||||
float * {
|
||||
if(isComplex) {
|
||||
createComplexMatrixOfDouble(iVarOut, iRowsOut, iColsOut, $result,&$result[iRowsOut*iColsOut]);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
else {
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, $result);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
double *temp;
|
||||
temp=(double *)($result);
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, temp);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) char *(int iRowsOut,int iColsOut){
|
||||
|
|
@ -417,8 +441,10 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &($result));
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) char * {
|
||||
if ($1) free($1);
|
||||
}
|
||||
|
||||
%typemap(out) SWIGTYPE *(int iRowsOut,int iColsOut) {
|
||||
|
|
@ -426,10 +452,167 @@
|
|||
iColsOut=1;
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &$result);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* --- Variable input ---
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(varin,noblock=1) signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
float,
|
||||
double {
|
||||
double* _piData;
|
||||
getVarAddressFromPosition($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, $argnum);
|
||||
}
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||
$1=($1_ltype)*_piData;
|
||||
}
|
||||
|
||||
%typemap(varin,noblock=1) char {
|
||||
char* _pstStrings;
|
||||
int _piLength;
|
||||
getVarAddressFromPosition($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, $argnum);
|
||||
}
|
||||
getMatrixOfString(piAddrVar, &iRows, &iCols,&_piLength, &_pstStrings);
|
||||
$1=($1_ltype)*_pstStrings;
|
||||
}
|
||||
|
||||
%typemap(varin,noblock=1) char *,
|
||||
char [ANY] {
|
||||
char* _pstStrings;
|
||||
int _piLength;
|
||||
getVarAddressFromPosition($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, $argnum);
|
||||
}
|
||||
getMatrixOfString(piAddrVar, &iRows, &iCols,&_piLength, &_pstStrings);
|
||||
$1=strdup(_pstStrings);
|
||||
}
|
||||
|
||||
%typemap(varin,noblock=1) double *,
|
||||
float * {
|
||||
double* _piData;
|
||||
int index;
|
||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||
|
||||
if (getVarType(piAddrVar) == sci_matrix ){
|
||||
if(!isVarComplex(piAddrVar)) {
|
||||
isComplex=0;
|
||||
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||
if($1!=NULL) {
|
||||
free($1);
|
||||
}
|
||||
$1=($1_ltype)malloc(iRows*iCols*sizeof($*1_ltype));
|
||||
for(index=0;index<iRows*iCols;index++){
|
||||
$1[index]=($*1_ltype)_piData[index];
|
||||
}
|
||||
}
|
||||
else {
|
||||
isComplex=1;
|
||||
double *_pdblImg;
|
||||
getComplexMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData, &_pdblImg);
|
||||
if($1!=NULL) {
|
||||
free($1);
|
||||
}
|
||||
$1=($1_ltype)malloc(2*iRows*iCols*sizeof($*1_ltype));
|
||||
for(index=0;index<iRows*iCols;index++){
|
||||
$1[index]=($*1_ltype)_piData[index];
|
||||
$1[index+iRows*iCols]=(double)_pdblImg[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: double matrix expected.\n"), fname, $argnum);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* --- Variable output ---
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* Basic C types */
|
||||
%typemap(varout,noblock=1) signed char {
|
||||
int* _piAddress;
|
||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &$result, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) short {
|
||||
int* _piAddress;
|
||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &$result, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) unsigned char {
|
||||
int* _piAddress;
|
||||
short temp;
|
||||
temp=$result;
|
||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) int,
|
||||
unsigned int,
|
||||
unsigned short,
|
||||
unsigned long,
|
||||
long {
|
||||
int* _piAddress;
|
||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &$result, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) double {
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &$result);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) float {
|
||||
double temp;
|
||||
temp=(double)$result;
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) char {
|
||||
char* temp;
|
||||
temp=(char*)&($result);
|
||||
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &temp);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) char * {
|
||||
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &($result));
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
|
||||
%typemap(varout,noblock=1) double *,
|
||||
float * {
|
||||
if(isComplex) {
|
||||
createComplexMatrixOfDouble(iVarOut, iRowsOut, iColsOut, $result,&$result[iRowsOut*iColsOut]);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
else {
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, $result);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Enums mapped as integer values
|
||||
|
|
|
|||
|
|
@ -141,8 +141,6 @@ output values.
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(argout) short *OUTPUT(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
|
|
@ -151,8 +149,6 @@ output values.
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(argout) int *OUTPUT(int iRowsOut,int iColsOut,int* _piAddress),
|
||||
|
|
@ -164,8 +160,6 @@ output values.
|
|||
iColsOut=1;
|
||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -177,8 +171,6 @@ output values.
|
|||
iColsOut=1;
|
||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
||||
LhsVar(iOutNum)=iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue