Deprecate SWIG_STD_VECTOR_SPECIALIZE_MINIMUM. Deprecate SWIG_STD_VECTOR_SPECIALIZE and replace with SWIG_STD_VECTOR_ENHANCED
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11493 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9444f2cebe
commit
31ad548c6b
4 changed files with 74 additions and 70 deletions
|
|
@ -1,6 +1,23 @@
|
||||||
Version 1.3.40 (in progress)
|
Version 1.3.40 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2009-08-03: wsfulton
|
||||||
|
[C#] The std::vector<T> implementation is improved and now uses $typemap such
|
||||||
|
that the proxy class for T no longer has to be specified in some macros
|
||||||
|
for correct C# compilation; the following macros are deprecated, where
|
||||||
|
CSTYPE was the C# type for the C++ class CTYPE:
|
||||||
|
|
||||||
|
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE)
|
||||||
|
usage should be removed altogether
|
||||||
|
|
||||||
|
SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE)
|
||||||
|
should be replaced with:
|
||||||
|
SWIG_STD_VECTOR_ENHANCED(CTYPE)
|
||||||
|
|
||||||
|
Some more details in csharp/std_vector.i
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
2009-07-31: olly
|
2009-07-31: olly
|
||||||
[Python] Fix indentation so that we give a useful error if the
|
[Python] Fix indentation so that we give a useful error if the
|
||||||
module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.
|
module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,6 @@ public:
|
||||||
|
|
||||||
%include "std_vector.i"
|
%include "std_vector.i"
|
||||||
|
|
||||||
#if defined(SWIGCSHARP)
|
|
||||||
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Flow, Space::Flow)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
|
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
|
||||||
#define SWIG_GOOD_VECTOR
|
#define SWIG_GOOD_VECTOR
|
||||||
%ignore std::vector<Space::Flow>::vector(size_type);
|
%ignore std::vector<Space::Flow>::vector(size_type);
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,7 @@ const std::vector<const Struct *> & vecstructconstptr(const std::vector<const St
|
||||||
%}
|
%}
|
||||||
|
|
||||||
#if defined(SWIGCSHARP)
|
#if defined(SWIGCSHARP)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(Struct, Struct *)
|
// Also test const and non-const pointers, but not strictly necessary since std::vector was enhanced in swig-1.3.40
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(Struct, const Struct *)
|
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, int *)
|
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
|
|
||||||
|
|
||||||
// Also test non-specialized versions
|
|
||||||
%template(StructurePtrVector) std::vector<Structure *>;
|
%template(StructurePtrVector) std::vector<Structure *>;
|
||||||
%template(StructureConstPtrVector) std::vector<const Structure *>;
|
%template(StructureConstPtrVector) std::vector<const Structure *>;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -93,10 +88,6 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
|
||||||
%template(StructPtrVector) std::vector<Struct *>;
|
%template(StructPtrVector) std::vector<Struct *>;
|
||||||
%template(StructConstPtrVector) std::vector<const Struct *>;
|
%template(StructConstPtrVector) std::vector<const Struct *>;
|
||||||
|
|
||||||
#if defined(SWIGCSHARP)
|
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(MyClass, MyClass *)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(SWIGTCL)
|
#if !defined(SWIGTCL)
|
||||||
%inline {
|
%inline {
|
||||||
struct MyClass {};
|
struct MyClass {};
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,20 @@
|
||||||
*
|
*
|
||||||
* std_vector.i
|
* std_vector.i
|
||||||
*
|
*
|
||||||
* SWIG typemaps for std::vector
|
* SWIG typemaps for std::vector<T>
|
||||||
* C# implementation
|
* C# implementation
|
||||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
|
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
|
||||||
* For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is
|
* For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is
|
||||||
* made to look and feel like a typesafe C# System.Collections.ArrayList. All the methods in IList
|
* made to look and feel like a typesafe C# System.Collections.ArrayList.
|
||||||
* are defined, but we don't derive from IList as this is a typesafe collection and the C++ operator==
|
|
||||||
* must always be defined for the collection type (which it isn't).
|
|
||||||
*
|
|
||||||
* Very often the C# generated code will not compile as the C++ template type is not the same as the C#
|
|
||||||
* proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg
|
|
||||||
*
|
|
||||||
* SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass)
|
|
||||||
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
|
|
||||||
*
|
*
|
||||||
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
|
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
|
||||||
* C++ std::vector wrappers. IEnumerable<> is replaced by IList<> wherever we are confident that the
|
* C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality
|
||||||
* required C++ operator== is available for correct compilation.
|
* whenever we are confident that the required C++ operator== is available. This is the case for when
|
||||||
|
* T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED
|
||||||
|
* macro to obtain this enhanced functionality, for example:
|
||||||
|
*
|
||||||
|
* SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass)
|
||||||
|
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
|
||||||
*
|
*
|
||||||
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
|
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -31,14 +28,14 @@
|
||||||
%include <std_common.i>
|
%include <std_common.i>
|
||||||
|
|
||||||
// MACRO for use within the std::vector class body
|
// 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(CSINTERFACE, CONST_REFERENCE_TYPE, CSTYPE, CTYPE...)
|
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...)
|
||||||
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<CSTYPE>\n#endif\n";
|
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
|
||||||
%typemap(cscode) std::vector<CTYPE > %{
|
%typemap(cscode) std::vector<CTYPE > %{
|
||||||
public $csclassname(System.Collections.ICollection c) : this() {
|
public $csclassname(System.Collections.ICollection c) : this() {
|
||||||
if (c == null)
|
if (c == null)
|
||||||
throw new ArgumentNullException("c");
|
throw new ArgumentNullException("c");
|
||||||
foreach (CSTYPE element in c) {
|
foreach ($typemap(cstype, CTYPE) element in c) {
|
||||||
this.Add(element);
|
this.Add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +52,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CSTYPE this[int index] {
|
public $typemap(cstype, CTYPE) this[int index] {
|
||||||
get {
|
get {
|
||||||
return getitem(index);
|
return getitem(index);
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +87,7 @@
|
||||||
#if SWIG_DOTNET_1
|
#if SWIG_DOTNET_1
|
||||||
public void CopyTo(System.Array array)
|
public void CopyTo(System.Array array)
|
||||||
#else
|
#else
|
||||||
public void CopyTo(CSTYPE[] array)
|
public void CopyTo($typemap(cstype, CTYPE)[] array)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
CopyTo(0, array, 0, this.Count);
|
CopyTo(0, array, 0, this.Count);
|
||||||
|
|
@ -99,7 +96,7 @@
|
||||||
#if SWIG_DOTNET_1
|
#if SWIG_DOTNET_1
|
||||||
public void CopyTo(System.Array array, int arrayIndex)
|
public void CopyTo(System.Array array, int arrayIndex)
|
||||||
#else
|
#else
|
||||||
public void CopyTo(CSTYPE[] array, int arrayIndex)
|
public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
CopyTo(0, array, arrayIndex, this.Count);
|
CopyTo(0, array, arrayIndex, this.Count);
|
||||||
|
|
@ -108,7 +105,7 @@
|
||||||
#if SWIG_DOTNET_1
|
#if SWIG_DOTNET_1
|
||||||
public void CopyTo(int index, System.Array array, int arrayIndex, int count)
|
public void CopyTo(int index, System.Array array, int arrayIndex, int count)
|
||||||
#else
|
#else
|
||||||
public void CopyTo(int index, CSTYPE[] array, int arrayIndex, int count)
|
public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (array == null)
|
if (array == null)
|
||||||
|
|
@ -128,7 +125,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SWIG_DOTNET_1
|
#if !SWIG_DOTNET_1
|
||||||
System.Collections.Generic.IEnumerator<CSTYPE> System.Collections.Generic.IEnumerable<CSTYPE>.GetEnumerator() {
|
System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
|
||||||
return new $csclassnameEnumerator(this);
|
return new $csclassnameEnumerator(this);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -148,7 +145,7 @@
|
||||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||||
public sealed class $csclassnameEnumerator : System.Collections.IEnumerator
|
public sealed class $csclassnameEnumerator : System.Collections.IEnumerator
|
||||||
#if !SWIG_DOTNET_1
|
#if !SWIG_DOTNET_1
|
||||||
, System.Collections.Generic.IEnumerator<CSTYPE>
|
, System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
private $csclassname collectionRef;
|
private $csclassname collectionRef;
|
||||||
|
|
@ -164,7 +161,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type-safe iterator Current
|
// Type-safe iterator Current
|
||||||
public CSTYPE Current {
|
public $typemap(cstype, CTYPE) Current {
|
||||||
get {
|
get {
|
||||||
if (currentIndex == -1)
|
if (currentIndex == -1)
|
||||||
throw new InvalidOperationException("Enumeration not started.");
|
throw new InvalidOperationException("Enumeration not started.");
|
||||||
|
|
@ -172,7 +169,7 @@
|
||||||
throw new InvalidOperationException("Enumeration finished.");
|
throw new InvalidOperationException("Enumeration finished.");
|
||||||
if (currentObject == null)
|
if (currentObject == null)
|
||||||
throw new InvalidOperationException("Collection modified.");
|
throw new InvalidOperationException("Collection modified.");
|
||||||
return (CSTYPE)currentObject;
|
return ($typemap(cstype, CTYPE))currentObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,14 +323,13 @@
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
|
%define SWIG_STD_VECTOR_MINIMUM(CTYPE...)
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE)
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
// 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
|
// The class will then implement IList<>, which adds extra functionality
|
||||||
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...)
|
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||||
%extend {
|
%extend {
|
||||||
bool Contains(const value_type& value) {
|
bool Contains(const value_type& value) {
|
||||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||||
|
|
@ -364,22 +360,24 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE)
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
// Macros for std::vector class specializations
|
// Macros for std::vector class specializations
|
||||||
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
|
//
|
||||||
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
|
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||||
namespace std {
|
namespace std {
|
||||||
template<> class vector<CTYPE > {
|
template<> class vector<CTYPE > {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CSTYPE, CTYPE)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CTYPE)
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
|
// Legacy macros
|
||||||
|
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
|
||||||
|
#warning SWIG_STD_VECTOR_SPECIALIZE macro deprecated, please see csharp/std_vector.i and switch to SWIG_STD_VECTOR_ENHANCED
|
||||||
|
SWIG_STD_VECTOR_ENHANCED(CTYPE)
|
||||||
|
%enddef
|
||||||
|
|
||||||
%define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...)
|
%define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...)
|
||||||
namespace std {
|
#warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required
|
||||||
template<> class vector<CTYPE > {
|
|
||||||
SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
@ -399,36 +397,38 @@ namespace std {
|
||||||
// primary (unspecialized) class template for std::vector
|
// primary (unspecialized) class template for std::vector
|
||||||
// does not require operator== to be defined
|
// does not require operator== to be defined
|
||||||
template<class T> class vector {
|
template<class T> class vector {
|
||||||
SWIG_STD_VECTOR_MINIMUM(T, T)
|
SWIG_STD_VECTOR_MINIMUM(T)
|
||||||
};
|
};
|
||||||
// specializations for pointers
|
// specializations for pointers
|
||||||
template<class T> class vector<T*> {
|
template<class T> class vector<T*> {
|
||||||
SWIG_STD_VECTOR_MINIMUM(T, T*)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T*)
|
||||||
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T*)
|
||||||
};
|
};
|
||||||
template<class T> class vector<const T*> {
|
template<class T> class vector<const T*> {
|
||||||
SWIG_STD_VECTOR_MINIMUM(T, const T*)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, const T*)
|
||||||
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(const T*)
|
||||||
};
|
};
|
||||||
// bool is a bit different in the C++ standard
|
// bool is a bit different in the C++ standard
|
||||||
template<> class vector<bool> {
|
template<> class vector<bool> {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool, bool)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool)
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// template specializations for std::vector
|
// template specializations for std::vector
|
||||||
// these provide extra collections methods as operator== is defined
|
// these provide extra collections methods as operator== is defined
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(char, char)
|
SWIG_STD_VECTOR_ENHANCED(char)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char)
|
SWIG_STD_VECTOR_ENHANCED(signed char)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char)
|
SWIG_STD_VECTOR_ENHANCED(unsigned char)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(short, short)
|
SWIG_STD_VECTOR_ENHANCED(short)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(ushort, unsigned short)
|
SWIG_STD_VECTOR_ENHANCED(unsigned short)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(int, int)
|
SWIG_STD_VECTOR_ENHANCED(int)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned int)
|
SWIG_STD_VECTOR_ENHANCED(unsigned int)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(int, long)
|
SWIG_STD_VECTOR_ENHANCED(long)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned long)
|
SWIG_STD_VECTOR_ENHANCED(unsigned long)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(long, long long)
|
SWIG_STD_VECTOR_ENHANCED(long long)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(ulong, unsigned long long)
|
SWIG_STD_VECTOR_ENHANCED(unsigned long long)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(float, float)
|
SWIG_STD_VECTOR_ENHANCED(float)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(double, double)
|
SWIG_STD_VECTOR_ENHANCED(double)
|
||||||
SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include <std_string.i>
|
SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include <std_string.i>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue