scilab: add pointer conversion builtin functions swig_this & swig_ptr
This commit is contained in:
parent
b58d996743
commit
675c4cee0f
5 changed files with 97 additions and 7 deletions
|
|
@ -18,6 +18,7 @@ CPP_TEST_CASES += \
|
|||
primitive_types \
|
||||
inout \
|
||||
scilab_li_matrix \
|
||||
scilab_pointer_conversion_functions \
|
||||
|
||||
CPP_STD_TEST_CASES += \
|
||||
li_std_container_typemaps \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
// Test on NULL
|
||||
null = getNull();
|
||||
checkequal(swig_this(null), 0, "swig_this(null)");
|
||||
|
||||
null = swig_ptr(0);
|
||||
checkequal(isNull(null), %T, "func(null)");
|
||||
|
||||
// Test on variable
|
||||
expected_foo_addr = getFooAddress();
|
||||
foo_addr = swig_this(pfoo_get());
|
||||
checkequal(uint32(foo_addr), expected_foo_addr, "swig_this(pfoo_get())");
|
||||
|
||||
pfoo = swig_ptr(foo_addr);
|
||||
checkequal(equalFooPointer(pfoo), %T, "equalFooPointer(pfoo)");
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
16
Examples/test-suite/scilab_pointer_conversion_functions.i
Normal file
16
Examples/test-suite/scilab_pointer_conversion_functions.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module scilab_pointer_conversion_functions
|
||||
|
||||
%inline %{
|
||||
|
||||
void* getNull() { return NULL; }
|
||||
bool isNull(void *p) { return p == NULL; }
|
||||
|
||||
int foo = 3;
|
||||
int *pfoo = &foo;
|
||||
|
||||
unsigned long getFooAddress() { return (unsigned long) pfoo; }
|
||||
bool equalFooPointer(void *p) { return p == pfoo; }
|
||||
|
||||
%}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue