mirror of https://github.com/swig/swig
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
|
@ -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
|
|
@ -51,13 +51,12 @@ or you can use the %apply directive :
|
|||
|
||||
In C# you could then use it like this:
|
||||
double answer = modulename.fadd(10.0, 20.0);
|
||||
|
||||
*/
|
||||
|
||||
%define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE)
|
||||
%typemap(ctype) TYPE *INPUT, TYPE &INPUT "CTYPE"
|
||||
%typemap(imtype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(cstype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
|
||||
%typemap(imtype, out="IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput"
|
||||
%typemap(csdirectorin) TYPE *INPUT, TYPE &INPUT "$iminput"
|
||||
%typemap(csdirectorout) TYPE *INPUT, TYPE &INPUT "$cscall"
|
||||
|
@ -143,18 +142,16 @@ value returned in the second output parameter. In C# you would use it like this:
|
|||
|
||||
double dptr;
|
||||
double fraction = modulename.modf(5, out dptr);
|
||||
|
||||
*/
|
||||
|
||||
%define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
|
||||
%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(cstype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
|
||||
%typemap(imtype, out="IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput"
|
||||
%typemap(csdirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$iminput"
|
||||
%typemap(csdirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$cscall"
|
||||
|
||||
|
||||
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
|
@ -250,9 +247,9 @@ of the function return value.
|
|||
*/
|
||||
|
||||
%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *"
|
||||
%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(cstype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
|
||||
%typemap(imtype, out="IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput"
|
||||
%typemap(csdirectorin) TYPE *INOUT, TYPE &INOUT "$iminput"
|
||||
%typemap(csdirectorout) TYPE *INOUT, TYPE &INOUT "$cscall"
|
||||
|
|
Loading…
Reference in New Issue