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
|
|
@ -208,7 +208,23 @@ scilab:4> c
|
||||||
c = 3
|
c = 3
|
||||||
|
|
||||||
scilab:5> Foo_get()
|
scilab:5> Foo_get()
|
||||||
ans = 4</pre></div>
|
ans = 4
|
||||||
|
|
||||||
|
scilab:6> Foo_set([1,2,3;4,5,6]);
|
||||||
|
|
||||||
|
scilab:7> Foo_get()
|
||||||
|
ans =
|
||||||
|
|
||||||
|
1. 2. 3.
|
||||||
|
4. 5. 6.
|
||||||
|
scilab:8> Foo_set([1+2*%i,2+3*%i;3+4*%i,7+8*%i]);
|
||||||
|
|
||||||
|
scilab:9> Foo_get()
|
||||||
|
ans =
|
||||||
|
|
||||||
|
1. + 2.i 2. + 3.i
|
||||||
|
3. + 4.i 7. + 8.i
|
||||||
|
</pre></div>
|
||||||
<H3><a name="Scilab_nn11"></a>27.3.4 Constants</H3>
|
<H3><a name="Scilab_nn11"></a>27.3.4 Constants</H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,10 @@ printf("fvar = %f\n", fvar_get());
|
||||||
printf("dvar = %f\n", dvar_get());
|
printf("dvar = %f\n", dvar_get());
|
||||||
printf("cvar = %s\n", cvar_get());
|
printf("cvar = %s\n", cvar_get());
|
||||||
printf("strvar = %s\n", strvar_get());
|
printf("strvar = %s\n", strvar_get());
|
||||||
Foo1_get();
|
Foo1_get()
|
||||||
Foo2_get();
|
Foo2_get()
|
||||||
|
|
||||||
printf("\nVariables (values printed from C)\n");
|
printf("\nVariables (values printed from C)\n");
|
||||||
|
|
||||||
print_vars()
|
print_vars();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,77 @@
|
||||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
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)) {
|
if (getVarType(piAddrVar) != sci_ints || isVarComplex(piAddrVar)) {
|
||||||
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
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),
|
%typemap(in) short [ANY](int *piAddrVar, int iRows, int iCols),
|
||||||
unsigned char *(int *piAddrVar, int iRows, int iCols),
|
|
||||||
short [ANY](int *piAddrVar, int iRows, int iCols),
|
|
||||||
unsigned char [ANY](int *piAddrVar, int iRows, int iCols) {
|
unsigned char [ANY](int *piAddrVar, int iRows, int iCols) {
|
||||||
short* _piData;
|
short* _piData;
|
||||||
int index;
|
int index;
|
||||||
|
|
@ -93,12 +162,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(in) unsigned short *(int *piAddrVar, int iRows, int iCols),
|
%typemap(in) unsigned short [ANY](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),
|
|
||||||
int [ANY](int *piAddrVar, int iRows, int iCols),
|
int [ANY](int *piAddrVar, int iRows, int iCols),
|
||||||
unsigned 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),
|
long [ANY](int *piAddrVar, int iRows, int iCols),
|
||||||
|
|
@ -121,50 +185,29 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(in) double *(int *piAddrVar, int iRows, int iCols),
|
%typemap(in) double [ANY](int *piAddrVar, int iRows, int iCols),
|
||||||
float *(int *piAddrVar, int iRows, int iCols),
|
|
||||||
double [ANY](int *piAddrVar, int iRows, int iCols),
|
|
||||||
float [ANY](int *piAddrVar, int iRows, int iCols){
|
float [ANY](int *piAddrVar, int iRows, int iCols){
|
||||||
double* _piData;
|
double* _piData;
|
||||||
int index;
|
int index;
|
||||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||||
getVarDimension(piAddrVar, &iRows, &iCols);
|
getVarDimension(piAddrVar, &iRows, &iCols);
|
||||||
|
|
||||||
if (getVarType(piAddrVar) == sci_matrix ){
|
if (getVarType(piAddrVar) != sci_matrix || isVarComplex(piAddrVar)) {
|
||||||
if(!isVarComplex(piAddrVar)) {
|
Scierror(999, _("%s: Wrong type for input argument #%d: Real scalar expected.\n"), fname, $argnum);
|
||||||
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 {
|
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
|
||||||
Scierror(999, _("%s: Wrong type for input argument #%d: double matrix expected.\n"), fname, $argnum);
|
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),
|
%typemap(in) char [ANY](int *piAddrVar, int iRows, int iCols){
|
||||||
char [ANY](int *piAddrVar, int iRows, int iCols){
|
|
||||||
char* _pstStrings;
|
char* _pstStrings;
|
||||||
int _piLength;
|
int _piLength;
|
||||||
getVarAddressFromPosition($argnum, &piAddrVar);
|
getVarAddressFromPosition($argnum, &piAddrVar);
|
||||||
|
|
@ -177,6 +220,7 @@
|
||||||
$1=strdup(_pstStrings);
|
$1=strdup(_pstStrings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Arrays */
|
/* Arrays */
|
||||||
%typemap(in) signed char [ANY][ANY](int *piAddrVar, int iRows, int iCols) {
|
%typemap(in) signed char [ANY][ANY](int *piAddrVar, int iRows, int iCols) {
|
||||||
char* _piData;
|
char* _piData;
|
||||||
|
|
@ -300,8 +344,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) short (int iRowsOut,int iColsOut,int* _piAddress),
|
%typemap(out) short (int iRowsOut,int iColsOut,int* _piAddress),
|
||||||
|
|
@ -312,8 +354,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) int (int iRowsOut,int iColsOut,int* _piAddress),
|
%typemap(out) int (int iRowsOut,int iColsOut,int* _piAddress),
|
||||||
|
|
@ -327,8 +367,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) double (int iRowsOut,int iColsOut),
|
%typemap(out) double (int iRowsOut,int iColsOut),
|
||||||
|
|
@ -339,8 +377,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp);
|
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) char (int iRowsOut,int iColsOut) {
|
%typemap(out) char (int iRowsOut,int iColsOut) {
|
||||||
|
|
@ -350,8 +386,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &temp);
|
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &temp);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out,noblock=1) void {
|
%typemap(out,noblock=1) void {
|
||||||
|
|
@ -365,8 +399,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) short *(int iRowsOut,int iColsOut,int* _piAddress),
|
%typemap(out) short *(int iRowsOut,int iColsOut,int* _piAddress),
|
||||||
|
|
@ -377,8 +409,6 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) int *(int iRowsOut,int iColsOut,int* _piAddress),
|
%typemap(out) int *(int iRowsOut,int iColsOut,int* _piAddress),
|
||||||
|
|
@ -392,24 +422,18 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, temp, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) double *,
|
%typemap(out) double *,
|
||||||
float * {
|
float * {
|
||||||
if(isComplex) {
|
double *temp;
|
||||||
createComplexMatrixOfDouble(iVarOut, iRowsOut, iColsOut, $result,&$result[iRowsOut*iColsOut]);
|
temp=(double *)($result);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
iRowsOut=1;
|
||||||
iOutNum++;
|
iColsOut=1;
|
||||||
iVarOut++;
|
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, temp);
|
||||||
}
|
LhsVar(iOutNum)=iVarOut;
|
||||||
else {
|
iOutNum++;
|
||||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, $result);
|
iVarOut++;
|
||||||
LhsVar(iOutNum)=iVarOut;
|
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) char *(int iRowsOut,int iColsOut){
|
%typemap(out) char *(int iRowsOut,int iColsOut){
|
||||||
|
|
@ -417,8 +441,10 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &($result));
|
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &($result));
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
}
|
||||||
iVarOut++;
|
|
||||||
|
%typemap(freearg, noblock=1) char * {
|
||||||
|
if ($1) free($1);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) SWIGTYPE *(int iRowsOut,int iColsOut) {
|
%typemap(out) SWIGTYPE *(int iRowsOut,int iColsOut) {
|
||||||
|
|
@ -426,10 +452,167 @@
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &$result);
|
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &$result);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
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
|
* Enums mapped as integer values
|
||||||
|
|
|
||||||
|
|
@ -141,8 +141,6 @@ output values.
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(argout) short *OUTPUT(int iRowsOut,int iColsOut,int* _piAddress),
|
%typemap(argout) short *OUTPUT(int iRowsOut,int iColsOut,int* _piAddress),
|
||||||
|
|
@ -151,8 +149,6 @@ output values.
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(argout) int *OUTPUT(int iRowsOut,int iColsOut,int* _piAddress),
|
%typemap(argout) int *OUTPUT(int iRowsOut,int iColsOut,int* _piAddress),
|
||||||
|
|
@ -164,8 +160,6 @@ output values.
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp$argnum, &_piAddress);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -177,8 +171,6 @@ output values.
|
||||||
iColsOut=1;
|
iColsOut=1;
|
||||||
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
||||||
LhsVar(iOutNum)=iVarOut;
|
LhsVar(iOutNum)=iVarOut;
|
||||||
iOutNum++;
|
|
||||||
iVarOut++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,8 @@ public:
|
||||||
|
|
||||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||||
Replaceall(tm, "$result", "result");
|
Replaceall(tm, "$result", "result");
|
||||||
|
if(out_required>0)
|
||||||
|
Printf(f->code,"iOutNum++;\niVarOut++;\n");
|
||||||
Printf(f->code, "%s\n", tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
if(strlen(Char(tm))!=0)
|
if(strlen(Char(tm))!=0)
|
||||||
out_required++;
|
out_required++;
|
||||||
|
|
@ -268,7 +270,9 @@ public:
|
||||||
String *outarg = NewString("");
|
String *outarg = NewString("");
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p, "tmap:argout"))) {
|
if ((tm = Getattr(p, "tmap:argout"))) {
|
||||||
Printv(outarg, tm, "\n", NIL);
|
if(out_required>0)
|
||||||
|
Printf(f->code,"iOutNum++;\niVarOut++;\n");
|
||||||
|
Printv(outarg, tm, "\n", NIL);
|
||||||
p = Getattr(p, "tmap:argout:next");
|
p = Getattr(p, "tmap:argout:next");
|
||||||
out_required++;
|
out_required++;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -277,13 +281,37 @@ public:
|
||||||
}
|
}
|
||||||
Printv(f->code, outarg, NIL);
|
Printv(f->code, outarg, NIL);
|
||||||
|
|
||||||
|
/* Insert cleanup code */
|
||||||
|
String *cleanup = NewString("");
|
||||||
|
for (p = l; p;) {
|
||||||
|
if ((tm = Getattr(p, "tmap:freearg"))) {
|
||||||
|
if (tm && (Len(tm) != 0)) {
|
||||||
|
Printv(cleanup, tm, "\n", NIL);
|
||||||
|
}
|
||||||
|
p = Getattr(p, "tmap:freearg:next");
|
||||||
|
} else {
|
||||||
|
p = nextSibling(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Output cleanup code */
|
||||||
|
Printv(f->code, cleanup, NIL);
|
||||||
|
|
||||||
/* Insert the code checking for the number of input and output */
|
/* Insert the code checking for the number of input and output */
|
||||||
if(out_required==0) out_required=1;
|
int flag;
|
||||||
|
if(out_required==0) {
|
||||||
|
out_required=1;
|
||||||
|
flag=0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flag=1;
|
||||||
|
}
|
||||||
Printf(f->def,"CheckRhs(%d,%d);\n",num_required,num_required);
|
Printf(f->def,"CheckRhs(%d,%d);\n",num_required,num_required);
|
||||||
Printf(f->def,"CheckLhs(%d,%d);\n",out_required,out_required);
|
Printf(f->def,"CheckLhs(%d,%d);\n",out_required,out_required);
|
||||||
|
|
||||||
/* Insert the order of output parameters*/
|
/* Insert the order of output parameters*/
|
||||||
Printf(f->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;");
|
if(flag)
|
||||||
|
Printf(f->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;");
|
||||||
|
|
||||||
/* Finish the the code for the function */
|
/* Finish the the code for the function */
|
||||||
Printf(f->code, "return 0;\n");
|
Printf(f->code, "return 0;\n");
|
||||||
|
|
@ -347,18 +375,13 @@ public:
|
||||||
Printf(setf->def,"CheckRhs(1,1);\n");
|
Printf(setf->def,"CheckRhs(1,1);\n");
|
||||||
Printf(setf->def,"CheckLhs(1,1);\n");
|
Printf(setf->def,"CheckLhs(1,1);\n");
|
||||||
|
|
||||||
/* Insert the order of output parameters*/
|
|
||||||
Printf(setf->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;");
|
|
||||||
|
|
||||||
/* add the local variable */
|
/* add the local variable */
|
||||||
Wrapper_add_local(setf, "piAddrVar", "int *piAddrVar");
|
Wrapper_add_local(setf, "piAddrVar", "int *piAddrVar");
|
||||||
//Wrapper_add_local(setf, "iRows", "int iRows");
|
|
||||||
//Wrapper_add_local(setf, "iCols", "int iCols");
|
|
||||||
|
|
||||||
/* deal with the set function */
|
/* deal with the set function */
|
||||||
if (is_assignable(n)) {
|
if (is_assignable(n)) {
|
||||||
Setattr(n, "wrap:name", setname);
|
Setattr(n, "wrap:name", setname);
|
||||||
if ((tm = Swig_typemap_lookup("in", n, name, 0))) {
|
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
|
||||||
Replaceall(tm, "$argnum", "1");
|
Replaceall(tm, "$argnum", "1");
|
||||||
Replaceall(tm,"iRows",rowname);
|
Replaceall(tm,"iRows",rowname);
|
||||||
Replaceall(tm,"iCols",colname);
|
Replaceall(tm,"iCols",colname);
|
||||||
|
|
@ -387,12 +410,7 @@ public:
|
||||||
/* Insert the order of output parameters*/
|
/* Insert the order of output parameters*/
|
||||||
Printf(getf->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;");
|
Printf(getf->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;");
|
||||||
|
|
||||||
/* add local variabe */
|
if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
|
||||||
Wrapper_add_local(getf, "piAddrOut", "int* _piAddress");
|
|
||||||
//Wrapper_add_local(getf, "iRows", "int iRowsOut");
|
|
||||||
//Wrapper_add_local(getf, "iColsOut", "int iColsOut ");
|
|
||||||
|
|
||||||
if ((tm = Swig_typemap_lookup("out", n, name, 0))) {
|
|
||||||
Replaceall(tm, "$result", name);
|
Replaceall(tm, "$result", name);
|
||||||
Replaceall(tm,"iRowsOut",rowname);
|
Replaceall(tm,"iRowsOut",rowname);
|
||||||
Replaceall(tm,"iColsOut",colname);
|
Replaceall(tm,"iColsOut",colname);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue