Fix SWIG's handling of qualified (e.g. const) variables of array type
This commit is contained in:
parent
9d330a9970
commit
ee2b46abe0
4 changed files with 153 additions and 0 deletions
|
|
@ -433,6 +433,7 @@ CPP_TEST_CASES += \
|
|||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_arrays \
|
||||
typemap_array_qualifiers \
|
||||
typemap_delete \
|
||||
typemap_directorout \
|
||||
typemap_global_scope \
|
||||
|
|
|
|||
79
Examples/test-suite/typemap_array_qualifiers.i
Normal file
79
Examples/test-suite/typemap_array_qualifiers.i
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
%module typemap_array_qualifiers
|
||||
|
||||
%define CLEAR_SWIGTYPE_TYPEMAPS
|
||||
%typemap(in)
|
||||
SWIGTYPE,
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE *const,
|
||||
SWIGTYPE *const&,
|
||||
const SWIGTYPE *,
|
||||
const SWIGTYPE *const,
|
||||
const SWIGTYPE *const&,
|
||||
const volatile SWIGTYPE *,
|
||||
const volatile SWIGTYPE *const,
|
||||
const volatile SWIGTYPE *const&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE [ANY],
|
||||
const SWIGTYPE [],
|
||||
const SWIGTYPE [ANY],
|
||||
const volatile SWIGTYPE [],
|
||||
const volatile SWIGTYPE [ANY],
|
||||
SWIGTYPE &,
|
||||
const SWIGTYPE &,
|
||||
const volatile SWIGTYPE &
|
||||
{
|
||||
%#error Incorrect typemap for $symname: $type
|
||||
}
|
||||
%enddef
|
||||
|
||||
%inline %{
|
||||
typedef struct {
|
||||
int a;
|
||||
} SomeType;
|
||||
typedef SomeType myarray[3];
|
||||
typedef const SomeType myconstarray[4];
|
||||
typedef volatile SomeType ** mycrazyarray[5];
|
||||
typedef volatile SomeType (mycrazyfunc)(SomeType);
|
||||
typedef volatile SomeType (*mycrazyfuncptr)(SomeType);
|
||||
%}
|
||||
|
||||
CLEAR_SWIGTYPE_TYPEMAPS;
|
||||
%typemap(in) SWIGTYPE [ANY] {
|
||||
/* Correct typemap for $symname: $type */
|
||||
}
|
||||
%inline %{
|
||||
void func1a(myarray x) {};
|
||||
void func1b(volatile myarray x) {};
|
||||
%}
|
||||
|
||||
CLEAR_SWIGTYPE_TYPEMAPS;
|
||||
%typemap(in) const SWIGTYPE [ANY] {
|
||||
/* Correct typemap for $symname: $type */
|
||||
}
|
||||
%typemap(in) const volatile SWIGTYPE [ANY] {
|
||||
/* Correct typemap for $symname: $type */
|
||||
}
|
||||
%inline %{
|
||||
void func2a(const myarray x) {};
|
||||
void func2b(const myconstarray x) {};
|
||||
void func2c(const volatile myconstarray x) {};
|
||||
%}
|
||||
|
||||
CLEAR_SWIGTYPE_TYPEMAPS;
|
||||
%typemap(in) volatile SWIGTYPE **const [ANY] {
|
||||
/* Correct typemap for $symname: $type */
|
||||
}
|
||||
%typemap(in) volatile SWIGTYPE **const [ANY][ANY] {
|
||||
/* Correct typemap for $symname: $type */
|
||||
}
|
||||
%inline %{
|
||||
void func3a(const mycrazyarray x, const mycrazyarray y[7]) {};
|
||||
%}
|
||||
|
||||
CLEAR_SWIGTYPE_TYPEMAPS;
|
||||
%typemap(in) SWIGTYPE (*const) (ANY) {
|
||||
/* Correct typemap for $symname: $type */
|
||||
}
|
||||
%inline %{
|
||||
void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {};
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue