summaryrefslogtreecommitdiff
path: root/Lib/csharp
diff options
context:
space:
mode:
authorVadim Zeitlin <vz-swig@zeitlins.org>2019-07-11 12:58:10 +0200
committerVadim Zeitlin <vz-swig@zeitlins.org>2019-07-11 13:09:46 +0200
commit28c6140c56c8a16f9e562370b0b7451a3b760858 (patch)
tree1dd875ac703c2adcbd3b52dbaa11647fb6e321ed /Lib/csharp
parent53d75dc133f9fb3fb36cb5bc53c0a2d2b135da9f (diff)
downloadswig-28c6140c56c8a16f9e562370b0b7451a3b760858.tar.gz
Allow std::set<> C# typemaps to work for non-nullable types too
Notably make them work for primitive types, such as "int". Doing this requires using "object" instead of the actual C# type of the variable to store the current value in the iterator, as we don't currently have a "csnullabletype" typemap that would expand to "T" for nullable types and "T?" for the other ones. This is a bit ugly, but it shouldn't matter much for the generated code and is already done in std::vector<> typemaps. Also add a simple unit test verifying the basic functionality for such vectors. Closes #1568.
Diffstat (limited to 'Lib/csharp')
-rw-r--r--Lib/csharp/std_set.i4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i
index 1d946e644..82f010aff 100644
--- a/Lib/csharp/std_set.i
+++ b/Lib/csharp/std_set.i
@@ -192,7 +192,7 @@ class set {
private $csclassname collectionRef;
private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection;
private int currentIndex;
- private $typemap(cstype, T) currentObject;
+ private object currentObject;
private int currentSize;
public $csclassnameEnumerator($csclassname collection) {
@@ -212,7 +212,7 @@ class set {
throw new global::System.InvalidOperationException("Enumeration finished.");
if (currentObject == null)
throw new global::System.InvalidOperationException("Collection modified.");
- return currentObject;
+ return ($typemap(cstype, T))currentObject;
}
}