add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers
This commit is contained in:
parent
72964a1faf
commit
862501480e
3 changed files with 72 additions and 26 deletions
|
|
@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.0.0 (in progress)
|
Version 4.0.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2018-01-30: smarchetto
|
||||||
|
[Scilab] add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers
|
||||||
|
|
||||||
2018-01-16: wsfulton
|
2018-01-16: wsfulton
|
||||||
Expressions following a preprocessor directive must now be separated by whitespace
|
Expressions following a preprocessor directive must now be separated by whitespace
|
||||||
or non-numeric characters. This syntax change makes the SWIG preprocessor work like
|
or non-numeric characters. This syntax change makes the SWIG preprocessor work like
|
||||||
|
|
|
||||||
|
|
@ -446,36 +446,77 @@ int SWIG_this(SWIG_GatewayParameters) {
|
||||||
extern "C"
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
int SWIG_ptr(SWIG_GatewayParameters) {
|
int SWIG_ptr(SWIG_GatewayParameters) {
|
||||||
void *ptrValue = NULL;
|
if (SWIG_NbInputArgument(pvApiCtx) > 0) {
|
||||||
double dValue = 0;
|
int *piAddrVar1 = NULL;
|
||||||
if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) {
|
int iTypeVar1 = 0;
|
||||||
SWIG_Scilab_SetOutputPosition(1);
|
char *pstInputPtrTypeName = NULL;
|
||||||
return SWIG_Scilab_SetOutput(pvApiCtx,
|
char *pstOutputMListTypeName = NULL;
|
||||||
SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, NULL, 0, NULL));
|
if (SWIG_NbInputArgument(pvApiCtx) > 2) {
|
||||||
}
|
int *piAddrVar2 = NULL;
|
||||||
else {
|
int *piAddrVar3 = NULL;
|
||||||
int *piAddr;
|
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrVar2);
|
||||||
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
|
if (sciErr.iErr) {
|
||||||
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);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) {
|
sciErr = getVarType(pvApiCtx, piAddrVar1, &iTypeVar1);
|
||||||
if (dValue != (uintptr_t)dValue) {
|
if (sciErr.iErr) {
|
||||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ValueError;
|
return SWIG_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
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);
|
else if (iTypeVar1 == sci_matrix) {
|
||||||
return SWIG_OverflowError;
|
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));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return SWIG_TypeError;
|
||||||
}
|
}
|
||||||
SWIG_Scilab_SetOutputPosition(1);
|
|
||||||
return SWIG_Scilab_SetOutput(pvApiCtx,
|
|
||||||
SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL));
|
|
||||||
}
|
}
|
||||||
else {
|
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;
|
return SWIG_TypeError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: A mlist, pointer, or a double expected.\n"), "SWIG_ptr", 1);
|
||||||
|
return SWIG_TypeError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,14 @@ SWIG_Scilab_SetModule(swig_module_info *swig_module) {
|
||||||
SWIGRUNTIME swig_type_info *
|
SWIGRUNTIME swig_type_info *
|
||||||
SWIG_Scilab_TypeQuery(const char *name) {
|
SWIG_Scilab_TypeQuery(const char *name) {
|
||||||
if (SWIG_Module_Initialized()) {
|
if (SWIG_Module_Initialized()) {
|
||||||
return SWIG_TypeQuery(name);
|
if (name) {
|
||||||
|
return SWIG_TypeQuery(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SWIG_Error(SWIG_RuntimeError, "the module is not initialized");
|
SWIG_Error(SWIG_RuntimeError, "the module is not initialized");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue