scilab: SWIG_ptr() accepts mlist typed pointers and converts them to pointers
This commit is contained in:
parent
07b7edcd87
commit
88b4827d87
3 changed files with 46 additions and 18 deletions
|
|
@ -15,4 +15,10 @@ checkequal(foo_addr, expected_foo_addr, "SWIG_this(pfoo_get())");
|
||||||
pfoo = SWIG_ptr(foo_addr);
|
pfoo = SWIG_ptr(foo_addr);
|
||||||
checkequal(equalFooPointer(pfoo), %T, "equalFooPointer(pfoo)");
|
checkequal(equalFooPointer(pfoo), %T, "equalFooPointer(pfoo)");
|
||||||
|
|
||||||
|
// Test conversion of mlist type pointers
|
||||||
|
stA = new_structA();
|
||||||
|
assert_checkequal(typeof(stA), "_p_structA");
|
||||||
|
p = SWIG_ptr(stA);
|
||||||
|
assert_checkequal(typeof(p), "pointer");
|
||||||
|
|
||||||
exec("swigtest.quit", -1);
|
exec("swigtest.quit", -1);
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,17 @@ bool equalFooPointer(void *p) { return p == pfoo; }
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%typemap(out, noblock=1) struct structA* {
|
||||||
|
if (SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), $1, SWIG_Scilab_TypeQuery("struct structA *"), 0, NULL) != SWIG_OK) {
|
||||||
|
return SWIG_ERROR;
|
||||||
|
}
|
||||||
|
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
struct structA {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,14 @@ int SWIG_this(SWIG_GatewayParameters) {
|
||||||
extern "C"
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
int SWIG_ptr(SWIG_GatewayParameters) {
|
int SWIG_ptr(SWIG_GatewayParameters) {
|
||||||
|
void *ptrValue = NULL;
|
||||||
double dValue = 0;
|
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;
|
int *piAddr;
|
||||||
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
|
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
|
||||||
if(sciErr.iErr) {
|
if(sciErr.iErr) {
|
||||||
|
|
@ -469,6 +476,8 @@ int SWIG_ptr(SWIG_GatewayParameters) {
|
||||||
SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL));
|
SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return SWIG_ERROR;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue