Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better vector/C++ containers support for Scilab
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-scilab@13719 626c5289-ae23-0410-ae9c-e8d60b6d4f22
- Loading branch information
Vincent Couvert
committed
Aug 24, 2012
1 parent
0d7be20
commit 6138b43
Showing
8 changed files
with
243 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Vectors typemaps | ||
*/ | ||
|
||
// Typemap for input arguments of type const std::vector<double> & | ||
%typecheck(SWIG_TYPECHECK_POINTER) | ||
const std::vector<double> & | ||
{ | ||
// TODO | ||
} | ||
%typemap(in) | ||
const std::vector<double> & | ||
(int is_new_object=0, std::vector<double> arrayv) | ||
{ | ||
{ | ||
SciErr sciErr; | ||
int iRows = 0; | ||
int iCols = 0; | ||
int *piAddrVar = NULL; | ||
double *pdblTmp = NULL; | ||
|
||
/* Scilab value must be a double vector */ | ||
sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar); | ||
if (sciErr.iErr) { | ||
printError(&sciErr, 0); | ||
return SWIG_ERROR; | ||
} | ||
|
||
if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) { | ||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdblTmp); | ||
if (sciErr.iErr) { | ||
printError(&sciErr, 0); | ||
return SWIG_ERROR; | ||
} | ||
} else { | ||
Scierror(999, _("%s: Wrong type for input argument #%d: A real vector expected.\n"), fname, $input); | ||
return SWIG_ERROR; | ||
} | ||
|
||
if ((iRows!=1) && (iCols!=1)) { | ||
Scierror(999, _("%s: Wrong size for input argument #%d: A real vector expected.\n"), fname, $input); | ||
return SWIG_ERROR; | ||
} | ||
/* Copy vector contents into new allocated std::vector<double> */ | ||
arrayv = std::vector<double>(iRows*iCols); | ||
$1 = &arrayv; | ||
{ | ||
int arr_i = 0; | ||
for (arr_i = 0; arr_i < iRows*iCols; ++arr_i) | ||
arrayv[arr_i] = pdblTmp[arr_i]; | ||
} | ||
} | ||
} | ||
%typemap(freearg) | ||
const std::vector<double> & | ||
{ | ||
// TODO | ||
} | ||
|
||
// Typemap for return values of type std::vector<double> | ||
%typemap(out) std::vector<double> | ||
{ | ||
// TODO | ||
} |
Oops, something went wrong.