summaryrefslogtreecommitdiff
path: root/Lib/scilab
diff options
context:
space:
mode:
authorSimon Marchetto <simon.marchetto@scilab-enterprises.com>2016-12-19 15:03:34 +0100
committerSimon Marchetto <simon.marchetto@scilab-enterprises.com>2016-12-19 15:04:30 +0100
commit94bee6b35a056d78f24ac6257de149b2bfedbf59 (patch)
tree1e4865807e51deab444f01c113fa5303c91897e0 /Lib/scilab
parent15b3c1dfa3bc4570a2ce5f80af1c9d3789c465ed (diff)
downloadswig-94bee6b35a056d78f24ac6257de149b2bfedbf59.tar.gz
[Scilab] put typemap int/double check into function (to reduce generated code size)
Diffstat (limited to 'Lib/scilab')
-rw-r--r--Lib/scilab/scitypemaps.swg24
1 files changed, 16 insertions, 8 deletions
diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg
index 175a41b51..1c2d9da30 100644
--- a/Lib/scilab/scitypemaps.swg
+++ b/Lib/scilab/scitypemaps.swg
@@ -122,29 +122,37 @@
}
%enddef
-/* Scilab equivalent for C integers can be sci_ints or sci_matrix */
-%define %scilab_typecheck_integer(PRECEDENCE, INTTYPE, TYPE)
-%typecheck(PRECEDENCE) TYPE {
+%fragment("SWIG_Check_SciDoubleOrInt", "header") {
+SWIGINTERN int
+SWIG_Check_SciDoubleOrInt(void *pvApiCtx, SwigSciObject iVar, int iIntegerType) {
int *piAddrVar = NULL;
- SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
+ int ret = 0;
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
- $1 = isIntegerType(pvApiCtx, piAddrVar);
- if ($1 == 1) {
+ ret = isIntegerType(pvApiCtx, piAddrVar);
+ if (ret == 1) {
int iPrec = 0;
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
- $1 = (iPrec == INTTYPE) ? 1 : 0;
+ ret = (iPrec == iIntegerType) ? 1 : 0;
}
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
%define %scilab_typecheck_pointer(PRECEDENCE, TYPE)