From: <vin...@us...> - 2011-03-23 15:37:36
|
Revision: 12549 http://swig.svn.sourceforge.net/swig/?rev=12549&view=rev Author: vincentcouvert Date: 2011-03-23 15:37:30 +0000 (Wed, 23 Mar 2011) Log Message: ----------- Implement SWIG_AsVal_long Modified Paths: -------------- branches/gsoc2009-sploving/Lib/scilab/sciprimtypes.swg Modified: branches/gsoc2009-sploving/Lib/scilab/sciprimtypes.swg =================================================================== --- branches/gsoc2009-sploving/Lib/scilab/sciprimtypes.swg 2011-03-20 23:24:32 UTC (rev 12548) +++ branches/gsoc2009-sploving/Lib/scilab/sciprimtypes.swg 2011-03-23 15:37:30 UTC (rev 12549) @@ -75,7 +75,60 @@ %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERN int SWIG_AsVal_dec(long)(int iPos, long* val) { - return 0; + SciErr sciErr; + int iRows = 1; + int iCols = 1; + int iType = 0; + int* piAddrVar = NULL; + double* piData = NULL; + double v = 0.0; + + sciErr = getVarAddressFromPosition(pvApiCtx, iPos, &piAddrVar); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return SWIG_TypeError; + } + + sciErr = getVarType(pvApiCtx, piAddrVar, &iType); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return SWIG_TypeError; + } + if (iType != sci_matrix) + { + return SWIG_TypeError; + } + + if (isVarComplex(pvApiCtx, piAddrVar)) + { + return SWIG_TypeError; + } + + sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, (double **)&piData); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return SWIG_TypeError; + } + if (iRows * iCols != 1) + { + return SWIG_TypeError; + } + + v = piData[0]; + if (v != floor(v)) + { + return SWIG_TypeError; + } + + if (val != NULL) + { + *val = (long) piData[0]; + } + + return SWIG_OK; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |