[Scilab] put typemap int/double check into function (to reduce generated code size)
This commit is contained in:
parent
15b3c1dfa3
commit
94bee6b35a
1 changed files with 16 additions and 8 deletions
|
|
@ -122,29 +122,37 @@
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
/* Scilab equivalent for C integers can be sci_ints or sci_matrix */
|
%fragment("SWIG_Check_SciDoubleOrInt", "header") {
|
||||||
%define %scilab_typecheck_integer(PRECEDENCE, INTTYPE, TYPE)
|
SWIGINTERN int
|
||||||
%typecheck(PRECEDENCE) TYPE {
|
SWIG_Check_SciDoubleOrInt(void *pvApiCtx, SwigSciObject iVar, int iIntegerType) {
|
||||||
int *piAddrVar = NULL;
|
int *piAddrVar = NULL;
|
||||||
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
|
int ret = 0;
|
||||||
|
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||||
if (sciErr.iErr) {
|
if (sciErr.iErr) {
|
||||||
printError(&sciErr, 0);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
$1 = isIntegerType(pvApiCtx, piAddrVar);
|
ret = isIntegerType(pvApiCtx, piAddrVar);
|
||||||
if ($1 == 1) {
|
if (ret == 1) {
|
||||||
int iPrec = 0;
|
int iPrec = 0;
|
||||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||||
if (sciErr.iErr) {
|
if (sciErr.iErr) {
|
||||||
printError(&sciErr, 0);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
$1 = (iPrec == INTTYPE) ? 1 : 0;
|
ret = (iPrec == iIntegerType) ? 1 : 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$1 = isDoubleType(pvApiCtx, piAddrVar);
|
ret = isDoubleType(pvApiCtx, piAddrVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scilab equivalent for C integers can be sci_intXX or sci_matrix */
|
||||||
|
%define %scilab_typecheck_integer(PRECEDENCE, INTTYPE, TYPE)
|
||||||
|
%typecheck(PRECEDENCE, fragment="SWIG_Check_SciDoubleOrInt") TYPE {
|
||||||
|
$1 = SWIG_Check_SciDoubleOrInt(pvApiCtx, $input, INTTYPE);
|
||||||
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
%define %scilab_typecheck_pointer(PRECEDENCE, TYPE)
|
%define %scilab_typecheck_pointer(PRECEDENCE, TYPE)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue