Fix C# typemaps.i so that %apply works doesn't break function returns using the same types, for example, %apply int &INPUT { int & } won't break 'int &foo(int &x);'
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12400 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2a449306f1
commit
2f0dc16b2e
2 changed files with 55 additions and 12 deletions
46
Examples/test-suite/li_typemaps_apply.i
Normal file
46
Examples/test-suite/li_typemaps_apply.i
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
%module li_typemaps_apply
|
||||
|
||||
// Test %apply to global primitive type references/pointers to make sure the return types are still okay... mainly for the strongly typed languages.
|
||||
|
||||
%include "typemaps.i"
|
||||
|
||||
#if !defined(SWIGJAVA) // Needs asymmetric type marshalling support for this testcase to work
|
||||
|
||||
%define TMAPS(PRIMTYPE, NAME)
|
||||
%apply PRIMTYPE *INPUT { PRIMTYPE * }
|
||||
%apply PRIMTYPE &INPUT { PRIMTYPE & }
|
||||
%inline %{
|
||||
PRIMTYPE *input_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; return &stat; }
|
||||
PRIMTYPE &input_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; return stat; }
|
||||
%}
|
||||
|
||||
%apply PRIMTYPE *OUTPUT { PRIMTYPE * }
|
||||
%apply PRIMTYPE &OUTPUT { PRIMTYPE & }
|
||||
%inline %{
|
||||
PRIMTYPE *output_ptr_##NAME(PRIMTYPE x, PRIMTYPE *v) { static PRIMTYPE stat; stat = x; *v = x; return &stat; }
|
||||
PRIMTYPE &output_ref_##NAME(PRIMTYPE x, PRIMTYPE &v) { static PRIMTYPE stat; stat = x; v = x; return stat; }
|
||||
%}
|
||||
|
||||
%apply PRIMTYPE *INOUT { PRIMTYPE * }
|
||||
%apply PRIMTYPE &INOUT { PRIMTYPE & }
|
||||
%inline %{
|
||||
PRIMTYPE *inout_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; *v = *v; return &stat; }
|
||||
PRIMTYPE &inout_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; v = v; return stat; }
|
||||
%}
|
||||
%enddef
|
||||
|
||||
TMAPS(bool, bool)
|
||||
TMAPS(int, int)
|
||||
TMAPS(short, short)
|
||||
TMAPS(long, long)
|
||||
TMAPS(unsigned int, uint)
|
||||
TMAPS(unsigned short, ushort)
|
||||
TMAPS(unsigned long, ulong)
|
||||
TMAPS(unsigned char, uchar)
|
||||
TMAPS(signed char, schar)
|
||||
TMAPS(float, float)
|
||||
TMAPS(double, double)
|
||||
TMAPS(long long, longlong)
|
||||
TMAPS(unsigned long long, ulonglong)
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue