Implement SWIG_AsVal_long
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12549 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3ca167ca82
commit
ba4a32e059
1 changed files with 54 additions and 1 deletions
|
|
@ -75,7 +75,60 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||||
SWIGINTERN int SWIG_AsVal_dec(long)(int iPos, long* val)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue