summaryrefslogtreecommitdiff
path: root/Lib/scilab
diff options
context:
space:
mode:
authorSimon Marchetto <simon.marchetto@scilab-enterprises.com>2018-01-30 16:34:31 +0100
committerSimon Marchetto <simon.marchetto@scilab-enterprises.com>2018-01-30 16:34:31 +0100
commit862501480efea950e33215cc49c1a20cb2af2958 (patch)
treec7667e387970490d9c0618027ac35f96b2abcbe0 /Lib/scilab
parent72964a1fafd2be8849ddd8f6cc6f5a8e04871c53 (diff)
downloadswig-862501480efea950e33215cc49c1a20cb2af2958.tar.gz
add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers
Diffstat (limited to 'Lib/scilab')
-rw-r--r--Lib/scilab/scirun.swg85
-rw-r--r--Lib/scilab/sciruntime.swg6
2 files changed, 67 insertions, 24 deletions
diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg
index 29f8096ef..a9e9d6351 100644
--- a/Lib/scilab/scirun.swg
+++ b/Lib/scilab/scirun.swg
@@ -446,36 +446,77 @@ int SWIG_this(SWIG_GatewayParameters) {
extern "C"
#endif
int SWIG_ptr(SWIG_GatewayParameters) {
- void *ptrValue = NULL;
- double dValue = 0;
- if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) {
- SWIG_Scilab_SetOutputPosition(1);
- return SWIG_Scilab_SetOutput(pvApiCtx,
- SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, NULL, 0, NULL));
- }
- else {
- int *piAddr;
- SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
- if(sciErr.iErr) {
+ if (SWIG_NbInputArgument(pvApiCtx) > 0) {
+ int *piAddrVar1 = NULL;
+ int iTypeVar1 = 0;
+ char *pstInputPtrTypeName = NULL;
+ char *pstOutputMListTypeName = NULL;
+ if (SWIG_NbInputArgument(pvApiCtx) > 2) {
+ int *piAddrVar2 = NULL;
+ int *piAddrVar3 = NULL;
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrVar2);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (getAllocatedSingleString(pvApiCtx, piAddrVar2, &pstInputPtrTypeName)) {
+ return SWIG_ERROR;
+ }
+ sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrVar3);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (getAllocatedSingleString(pvApiCtx, piAddrVar3, &pstOutputMListTypeName)) {
+ return SWIG_ERROR;
+ }
+ }
+
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrVar1);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ sciErr = getVarType(pvApiCtx, piAddrVar1, &iTypeVar1);
+ 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 ((iTypeVar1 == sci_pointer) || (iTypeVar1 == sci_mlist)) {
+ void *ptrValue = NULL;
+ if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, (char *) "SWIG_ptr") == SWIG_OK) {
+ SWIG_Scilab_SetOutputPosition(1);
+ return SWIG_Scilab_SetOutput(pvApiCtx,
+ SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, pstOutputMListTypeName));
+ }
+ }
+ else if (iTypeVar1 == sci_matrix) {
+ double dValue = 0;
+ if (getScalarDouble(pvApiCtx, piAddrVar1, &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, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, pstOutputMListTypeName));
}
- 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;
+ else {
+ return SWIG_TypeError;
}
- 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);
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A mlist, pointer or a double expected.\n"), (char *) "SWIG_ptr", 1);
return SWIG_TypeError;
}
}
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: A mlist, pointer, or a double expected.\n"), "SWIG_ptr", 1);
+ return SWIG_TypeError;
+ }
}
diff --git a/Lib/scilab/sciruntime.swg b/Lib/scilab/sciruntime.swg
index 9abedfe3d..3de138e11 100644
--- a/Lib/scilab/sciruntime.swg
+++ b/Lib/scilab/sciruntime.swg
@@ -25,12 +25,14 @@ SWIG_Scilab_SetModule(swig_module_info *swig_module) {
SWIGRUNTIME swig_type_info *
SWIG_Scilab_TypeQuery(const char *name) {
if (SWIG_Module_Initialized()) {
- return SWIG_TypeQuery(name);
+ if (name) {
+ return SWIG_TypeQuery(name);
+ }
}
else {
SWIG_Error(SWIG_RuntimeError, "the module is not initialized");
- return NULL;
}
+ return NULL;
}
%}