Fix SWIG_STD_VECTOR_ENHANCED macro used in C# std::vector to work with commas
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12081 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b802e37ad2
commit
d25121a0ed
5 changed files with 50 additions and 6 deletions
|
|
@ -4,6 +4,12 @@ Version 2.0.0 (in progress)
|
|||
See CHANGES for changes in older releases.
|
||||
See RELEASENOTES for a summary of changes in each release.
|
||||
|
||||
2010-06-02: wsfulton
|
||||
[C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with
|
||||
types containing commas, for example:
|
||||
|
||||
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
|
||||
|
||||
2010-06-01: wsfulton
|
||||
Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr
|
||||
macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be
|
||||
|
|
|
|||
31
Examples/test-suite/csharp/li_std_combinations_runme.cs
Normal file
31
Examples/test-suite/csharp/li_std_combinations_runme.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using li_std_combinationsNamespace;
|
||||
|
||||
public class li_std_combinations_runme {
|
||||
public static void Main() {
|
||||
VectorPairIntString vpis = new VectorPairIntString();
|
||||
vpis.Add(new PairIntString(123, "one hundred and twenty three"));
|
||||
|
||||
VectorString vs = new VectorString();
|
||||
vs.Add("hi");
|
||||
PairIntVectorString pivs = new PairIntVectorString(456, vs);
|
||||
if (pivs.second[0] != "hi")
|
||||
throw new ApplicationException("PairIntVectorString");
|
||||
|
||||
VectorVectorString vvs = new VectorVectorString();
|
||||
vvs.Add(vs);
|
||||
|
||||
PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4"));
|
||||
if (pipis.first != 12)
|
||||
throw new ApplicationException("PairIntPairIntString");
|
||||
|
||||
PairDoubleString pds = new PairDoubleString(12.34, "okay");
|
||||
VectorPairDoubleString vpds = new VectorPairDoubleString();
|
||||
vpds.Add(pds);
|
||||
|
||||
// Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method
|
||||
if (!vpds.Contains(pds))
|
||||
throw new ApplicationException("VectorPairDoubleString");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -13,3 +13,11 @@
|
|||
|
||||
%template(VectorVectorString) std::vector< std::vector<std::string> >;
|
||||
%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;
|
||||
|
||||
#if defined(SWIGCSHARP)
|
||||
// Checks macro containing a type with a comma
|
||||
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
|
||||
#endif
|
||||
%template(PairDoubleString) std::pair< double, std::string >;
|
||||
%template(VectorPairDoubleString) std::vector< std::pair<double, std::string> >;
|
||||
|
||||
|
|
|
|||
|
|
@ -963,6 +963,9 @@ using System.Runtime.InteropServices;
|
|||
// Default enum handling
|
||||
%include <enums.swg>
|
||||
|
||||
// For vararg handling in macros, from swigmacros.swg
|
||||
#define %arg(X...) X
|
||||
|
||||
/*
|
||||
// Alternative char * typemaps.
|
||||
%pragma(csharp) imclasscode=%{
|
||||
|
|
|
|||
|
|
@ -319,10 +319,6 @@
|
|||
}
|
||||
%enddef
|
||||
|
||||
%define SWIG_STD_VECTOR_MINIMUM(CTYPE...)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, CTYPE const&, CTYPE)
|
||||
%enddef
|
||||
|
||||
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
||||
// The class will then implement IList<>, which adds extra functionality
|
||||
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||
|
|
@ -359,7 +355,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, CTYPE const&, CTYPE)
|
|||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, CTYPE const&, CTYPE)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
|
|
@ -392,7 +388,7 @@ namespace std {
|
|||
// primary (unspecialized) class template for std::vector
|
||||
// does not require operator== to be defined
|
||||
template<class T> class vector {
|
||||
SWIG_STD_VECTOR_MINIMUM(T)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T)
|
||||
};
|
||||
// specialization for pointers
|
||||
template<class T> class vector<T *> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue