diff --git a/SWIG/Lib/typemaps/fragments.swg b/SWIG/Lib/typemaps/fragments.swg index c9c5a5d72..35b75cb9e 100644 --- a/SWIG/Lib/typemaps/fragments.swg +++ b/SWIG/Lib/typemaps/fragments.swg @@ -297,18 +297,20 @@ #define SWIG_FROM_CALL_ARGS #endif -#define SWIG_Traits_frag(Type...) %string_type(Traits, Type) -#define SWIG_AsPtr_frag(Type...) %string_type(AsPtr, Type) -#define SWIG_AsVal_frag(Type...) %string_type(AsVal, Type) -#define SWIG_From_frag(Type...) %string_type(From, Type) +#define %fragment_name(Name, Type...) %string_name(Name) "_" {Type} -#define SWIG_AsVal_dec(Type...) %name_type(AsVal, Type) SWIG_ASVAL_DECL_ARGS -#define SWIG_AsPtr_dec(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_DECL_ARGS -#define SWIG_From_dec(Type...) %name_type(From, Type) SWIG_FROM_DECL_ARGS +#define SWIG_Traits_frag(Type...) %fragment_name(Traits, Type) +#define SWIG_AsPtr_frag(Type...) %fragment_name(AsPtr, Type) +#define SWIG_AsVal_frag(Type...) %fragment_name(AsVal, Type) +#define SWIG_From_frag(Type...) %fragment_name(From, Type) -#define SWIG_AsVal(Type...) %name_type(AsVal, Type) SWIG_ASVAL_CALL_ARGS -#define SWIG_AsPtr(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_CALL_ARGS -#define SWIG_From(Type...) %name_type(From, Type) SWIG_FROM_CALL_ARGS +#define SWIG_AsVal_dec(Type...) %symbol_name(AsVal, Type) SWIG_ASVAL_DECL_ARGS +#define SWIG_AsPtr_dec(Type...) %symbol_name(AsPtr, Type) SWIG_ASPTR_DECL_ARGS +#define SWIG_From_dec(Type...) %symbol_name(From, Type) SWIG_FROM_DECL_ARGS + +#define SWIG_AsVal(Type...) %symbol_name(AsVal, Type) SWIG_ASVAL_CALL_ARGS +#define SWIG_AsPtr(Type...) %symbol_name(AsPtr, Type) SWIG_ASPTR_CALL_ARGS +#define SWIG_From(Type...) %symbol_name(From, Type) SWIG_FROM_CALL_ARGS /* ------------------------------------------------------------ * common fragments diff --git a/SWIG/Lib/typemaps/inoutlist.swg b/SWIG/Lib/typemaps/inoutlist.swg index 8d53f739c..6ff80a939 100644 --- a/SWIG/Lib/typemaps/inoutlist.swg +++ b/SWIG/Lib/typemaps/inoutlist.swg @@ -70,7 +70,7 @@ or you can use the %apply directive : double fadd(double *a, double *b); */ -#ifdef SWIG_INPUT_ACCEPT_PTRS +#if defined(SWIG_INPUT_ACCEPT_PTRS) #define %check_input_ptr(input,arg,desc,disown) (SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown) == SWIG_OK) #else #define %check_input_ptr(input,arg,desc,disown) (0) diff --git a/SWIG/Lib/typemaps/strings.swg b/SWIG/Lib/typemaps/strings.swg index 3cb84b47a..35c5e9e3f 100644 --- a/SWIG/Lib/typemaps/strings.swg +++ b/SWIG/Lib/typemaps/strings.swg @@ -165,7 +165,9 @@ $result = buf; } -%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * const& (Char* buf = 0, int alloc = 0) { +%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) + Char * const& (Char* buf = 0, int alloc = 0), + Char const* const& (Char* buf = 0, int alloc = 0) { if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) { %dirout_fail(SWIG_TypeError, "$type"); } diff --git a/SWIG/Lib/typemaps/swigmacros.swg b/SWIG/Lib/typemaps/swigmacros.swg index e16afa9e7..1564a4487 100644 --- a/SWIG/Lib/typemaps/swigmacros.swg +++ b/SWIG/Lib/typemaps/swigmacros.swg @@ -111,9 +111,9 @@ nocppval * Casting operators * ----------------------------------------------------------------------------- */ -#ifdef SWIG_NO_CPLUSPLUS_CAST +#if defined(SWIG_NO_CPLUSPLUS_CAST) /* Disable 'modern' cplusplus casting operators */ -# ifdef SWIG_CPLUSPLUS_CAST +# if defined(SWIG_CPLUSPLUS_CAST) # undef SWIG_CPLUSPLUS_CAST # endif #endif @@ -159,9 +159,9 @@ nocppval * ----------------------------------------------------------------------------- */ #define %mangle(Type...) #@Type -#define %name_type(Name, Type...) SWIG_ ## Name ## _ ## #@Type -#define %string_type(Name, Type...) "SWIG_" #Name "_" {Type} -#define %checkcode(Code) %name_type(TYPECHECK, Code) +#define %string_name(Name) "SWIG_" %str(Name) +#define %symbol_name(Name, Type...) SWIG_ ## Name ## _ #@Type +#define %checkcode(Code) SWIG_TYPECHECK_ ## Code /* ----------------------------------------------------------------------------- diff --git a/SWIG/Lib/typemaps/swigtype.swg b/SWIG/Lib/typemaps/swigtype.swg index e5092402b..81767b86c 100644 --- a/SWIG/Lib/typemaps/swigtype.swg +++ b/SWIG/Lib/typemaps/swigtype.swg @@ -250,7 +250,7 @@ /* directorin */ -%typemap(directorin,noblock=1) SWIGTYPE* { +%typemap(directorin,noblock=1) SWIGTYPE*, SWIGTYPE* const& { $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); } diff --git a/SWIG/Lib/typemaps/typemaps.swg b/SWIG/Lib/typemaps/typemaps.swg index 55099de39..c20a2aacd 100644 --- a/SWIG/Lib/typemaps/typemaps.swg +++ b/SWIG/Lib/typemaps/typemaps.swg @@ -160,7 +160,7 @@ phased out in future releases. */ -#ifdef SWIG_INOUT_NODEF +#if defined(SWIG_INOUT_NODEF) %apply_checkctypes(%typemaps_inoutn) diff --git a/SWIG/Lib/typemaps/void.swg b/SWIG/Lib/typemaps/void.swg index 8f26264b3..b692e848e 100644 --- a/SWIG/Lib/typemaps/void.swg +++ b/SWIG/Lib/typemaps/void.swg @@ -48,6 +48,13 @@ #if defined(SWIG_DIRECTOR_TYPEMAPS) +/* directorin */ + +%typemap(directorin,noblock=1) void *, void const*, void *const, void const *const, + void const *&, void *const &, void const *const & { + $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); +} + /* directorout */ %typemap(directorout,noblock=1) void * (void *argp) { @@ -57,6 +64,14 @@ $result = %reinterpret_cast(argp, $ltype); } +%typemap(directorout,noblock=1) void * const& ($*ltype temp) { + if (SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown) != SWIG_OK) { + %dirout_fail(SWIG_TypeError,"$type"); + } + $result = &temp; +} + + #endif /* SWIG_DIRECTOR_TYPEMAPS */