aboutsummaryrefslogtreecommitdiff
path: root/Lib/scilab
diff options
context:
space:
mode:
authorSimon Marchetto <simon.marchetto@scilab-enterprises.com>2016-12-15 23:57:30 +0100
committerSimon Marchetto <simon.marchetto@scilab-enterprises.com>2016-12-15 23:57:42 +0100
commit88b4827d8753657c62ae143a64f8d8c668680d70 (patch)
treeee058a0e297ac0bbe7d252d1494cacb5f0fb0e3c /Lib/scilab
parent07b7edcd87ff3d01e5791556a72906f1225594d9 (diff)
downloadswig-88b4827d8753657c62ae143a64f8d8c668680d70.tar.gz
scilab: SWIG_ptr() accepts mlist typed pointers and converts them to pointers
Diffstat (limited to 'Lib/scilab')
-rw-r--r--Lib/scilab/scirun.swg43
1 files changed, 26 insertions, 17 deletions
diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg
index ad3a7fa1f..10d18ac9d 100644
--- a/Lib/scilab/scirun.swg
+++ b/Lib/scilab/scirun.swg
@@ -448,27 +448,36 @@ int SWIG_this(SWIG_GatewayParameters) {
extern "C"
#endif
int SWIG_ptr(SWIG_GatewayParameters) {
+ void *ptrValue = NULL;
double dValue = 0;
- int *piAddr;
- SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
- if(sciErr.iErr) {
- printError(&sciErr, 0);
- return SWIG_ERROR;
- }
- if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) {
- if (dValue != (uintptr_t)dValue) {
- Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
- return SWIG_ValueError;
- }
- if ((dValue < 0) || (dValue > ULONG_MAX)) {
- Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
- return SWIG_OverflowError;
- }
+ if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) {
SWIG_Scilab_SetOutputPosition(1);
return SWIG_Scilab_SetOutput(pvApiCtx,
- SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL));
+ SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, NULL, 0, NULL));
}
else {
- return SWIG_ERROR;
+ int *piAddr;
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if(sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) {
+ if (dValue != (uintptr_t)dValue) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
+ return SWIG_ValueError;
+ }
+ if ((dValue < 0) || (dValue > ULONG_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
+ return SWIG_OverflowError;
+ }
+ SWIG_Scilab_SetOutputPosition(1);
+ return SWIG_Scilab_SetOutput(pvApiCtx,
+ SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL));
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A pointer or a double expected.\n"), "SWIG_ptr", 1);
+ return SWIG_TypeError;
+ }
}
}