Enable multiple 'fragment' keywords to be attached to typemaps
This is consistent with the use of `%fragment`. Previously only the last `fragment=` keyword would be added.
This commit is contained in:
parent
b06ab566cb
commit
325056453a
2 changed files with 138 additions and 0 deletions
|
|
@ -34,3 +34,86 @@ int foo(int hola)
|
|||
}
|
||||
|
||||
%}
|
||||
|
||||
/* Instantiate multiple fragments at once using multiple keywords */
|
||||
typedef int int_infrag3;
|
||||
typedef int explicit_frag3;
|
||||
|
||||
%fragment("explicit_frag1","header", noblock=1) {
|
||||
typedef int explicit_frag1;
|
||||
}
|
||||
|
||||
%fragment("explicit_frag2","header", noblock=1, noblock=1) {
|
||||
typedef explicit_frag1 explicit_frag2;
|
||||
}
|
||||
|
||||
%fragment("explicit_frag3","header",
|
||||
fragment="explicit_frag1", fragment="explicit_frag2")
|
||||
%{typedef explicit_frag2 explicit_frag3;%}
|
||||
|
||||
%fragment("explicit_frag3");
|
||||
%inline %{
|
||||
explicit_frag3 my_int = 0;
|
||||
%}
|
||||
|
||||
/* Test typemap's ability to instantiate multiple fragments on demand */
|
||||
typedef int int_infrag1;
|
||||
typedef int int_infrag2;
|
||||
typedef int int_outfrag1;
|
||||
typedef int int_outfrag2;
|
||||
typedef int int_outfrag3;
|
||||
|
||||
%fragment("infrag2","runtime") %{
|
||||
typedef int_infrag1 int_infrag2;
|
||||
%}
|
||||
|
||||
%fragment("infrag1","runtime") %{
|
||||
typedef int int_infrag1;
|
||||
%}
|
||||
%fragment("infrag2","runtime") %{
|
||||
typedef int_infrag1 int_infrag2;
|
||||
%}
|
||||
|
||||
%fragment("outfrag1","runtime") %{
|
||||
typedef int int_outfrag1;
|
||||
%}
|
||||
%fragment("outfrag2","runtime") %{
|
||||
typedef int_outfrag1 int_outfrag2;
|
||||
%}
|
||||
|
||||
%fragment("tcfrag1","runtime") %{
|
||||
typedef int int_tcfrag1;
|
||||
%}
|
||||
%fragment("tcfrag2","runtime") %{
|
||||
typedef int_tcfrag1 int_tcfrag2;
|
||||
%}
|
||||
|
||||
%fragment("outspecial"{bool},"runtime") %{
|
||||
typedef int int_outfrag3_temp;
|
||||
%}
|
||||
%fragment("outfrag3","runtime") %{
|
||||
typedef int_outfrag3_temp int_outfrag3;
|
||||
%}
|
||||
|
||||
%typemap(in, fragment="infrag1", fragment="infrag2") int_infrag2
|
||||
%{$typemap(in,int)%}
|
||||
|
||||
%typemap(check, fragment="tcfrag1", noblock=1, fragment="tcfrag2") int_infrag2
|
||||
{(void)sizeof(int_tcfrag2);}
|
||||
|
||||
%typemap(out, fragment="outfrag1", fragment="outfrag2", noblock=1) int_outfrag2
|
||||
{$typemap(out,int)}
|
||||
|
||||
/* Test another permutation of keyword order */
|
||||
%typemap(out, noblock=1, fragment="outfrag1", fragment="outfrag2") int_outfrag1
|
||||
{$typemap(out,int)}
|
||||
|
||||
/* Test fragment specialization */
|
||||
%typemap(out, noblock=1, fragment="outspecial"{bool}, fragment="outfrag3") int_outfrag3
|
||||
{$typemap(out,int)}
|
||||
|
||||
%inline %{
|
||||
int identity_in(int_infrag2 inp) { return inp; }
|
||||
int_outfrag2 identity_out(int inp) { return inp; }
|
||||
int_outfrag3 identity_out_2(int inp) { return inp; }
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue