adding struct example

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11457 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2009-07-27 02:57:09 +00:00
commit 8217f59d55
8 changed files with 118 additions and 27 deletions

View file

@ -1,7 +1,7 @@
%insert(runtime) %{
void SWIG_Error(int code, const char *msg) {
Scierror(code,_("%s\n"),msg);
Scierror(code, _("%s\n"), msg);
}
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(999, msg); } else

View file

@ -318,7 +318,7 @@
}
%typemap(in) SWIGTYPE *(int *piAddrVar, int iRows, int iCols) {
$&1_ltype _piData=($&1_ltype)0;
$&1_ltype _piData = ($&1_ltype)0;
getVarAddressFromPosition($argnum, &piAddrVar);
getVarDimension(piAddrVar, &iRows, &iCols);
@ -328,6 +328,7 @@
getMatrixOfDouble(piAddrVar, &iRows, &iCols, &_piData);
$1 = ($1_ltype)*_piData;
}
%typemap(in) SWIGTYPE {
}
@ -338,28 +339,34 @@
/* Basic C types */
%typemap(out) signed char (int iRowsOut, int iColsOut) {
char temp;
temp = (char)($result);
iRowsOut = 1;
iColsOut = 1;
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp);
createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(out) short (int iRowsOut, int iColsOut),
unsigned char (int iRowsOut, int iColsOut) {
short temp;
temp = (short)($result);
%typemap(out) unsigned char (int iRowsOut, int iColsOut) {
iRowsOut = 1;
iColsOut = 1;
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp);
createMatrixOfUnsignedInteger8(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(out) short (int iRowsOut, int iColsOut) {
iRowsOut = 1;
iColsOut = 1;
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(out) unsigned short (int iRowsOut, int iColsOut) {
iRowsOut = 1;
iColsOut = 1;
createMatrixOfUnsignedInteger16(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(out) int (int iRowsOut, int iColsOut),
unsigned int (int iRowsOut, int iColsOut),
unsigned short (int iRowsOut, int iColsOut),
unsigned long (int iRowsOut, int iColsOut),
long (int iRowsOut, int iColsOut) {
int temp;
temp = (int)($result);
@ -369,6 +376,16 @@
LhsVar(iOutNum) = iVarOut;
}
%typemap(out) unsigned int (int iRowsOut, int iColsOut),
unsigned long (int iRowsOut, int iColsOut) {
int temp;
temp = (int)($result);
iRowsOut = 1;
iColsOut = 1;
createMatrixOfUnsignedInteger32(iVarOut, iRowsOut, iColsOut, &temp);
LhsVar(iOutNum) = iVarOut;
}
%typemap(out) double (int iRowsOut, int iColsOut),
float (int iRowsOut, int iColsOut) {
double temp;
@ -436,7 +453,7 @@
iVarOut++;
}
%typemap(out) char *(int iRowsOut, int iColsOut){
%typemap(out) char *(int iRowsOut, int iColsOut) {
iRowsOut = 1;
iColsOut = 1;
createMatrixOfString(iVarOut, iRowsOut, iColsOut, &($result));
@ -627,27 +644,33 @@
LhsVar(iOutNum) = iVarOut;
}
%typemap(varout,noblock=1) unsigned char {
createMatrixOfUnsignedInteger8(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(varout,noblock=1) short {
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(varout,noblock=1) unsigned char {
short temp;
temp = $result;
createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp);
%typemap(varout,noblock=1) unsigned short {
createMatrixOfUnsignedInteger16(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(varout,noblock=1) int,
unsigned int,
unsigned short,
unsigned long,
long {
createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(varout,noblock=1) unsigned int,
unsigned long {
createMatrixOfUnsignedInteger32(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;
}
%typemap(varout,noblock=1) double {
createMatrixOfDouble(iVarOut, iRowsOut, iColsOut, &$result);
LhsVar(iOutNum) = iVarOut;