diff --git a/CHANGES.current b/CHANGES.current index 506ba08be..4ddef0fee 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-05-11: wsfulton + [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These + implement IList<> instead of IEnumerable<> where possible. + 2009-04-29: wsfulton [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps. When this attribute is set, the typemap will not apply to classes that are derived diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index f4ad88bae..07a24dfd6 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -19,7 +19,8 @@ * %template(VectKlass) std::vector; * * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with - * C++ std::vector wrappers. + * C++ std::vector wrappers. IEnumerable<> is replaced by IList<> wherever we are confident that the + * required C++ operator== is available for correct compilation. * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ @@ -31,8 +32,8 @@ // MACRO for use within the std::vector class body // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps -%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) -%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IEnumerable\n#endif\n"; +%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) +%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE\n#endif\n"; %typemap(cscode) std::vector %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) @@ -325,10 +326,9 @@ %enddef %define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) -SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) +SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE) %enddef - // Extra methods added to the collection class if operator== is defined for the class being wrapped // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps // The class will then implement IList<>, which adds extra functionality @@ -367,7 +367,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) %define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) namespace std { template<> class vector { - SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CSTYPE, CTYPE) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE) }; } @@ -409,7 +409,7 @@ namespace std { }; // bool is a bit different in the C++ standard template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool, bool) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool) }; }