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.
This commit is contained in:
parent
53d75dc133
commit
28c6140c56
3 changed files with 15 additions and 2 deletions
|
|
@ -92,5 +92,14 @@ public class runme
|
|||
checkThat(fooISet.Count == 0, "is initially empty");
|
||||
checkThat(fooISet.Add(new Foo(17)), "added successfully");
|
||||
checkThat(fooISet.Count == 1, "is not empty any more");
|
||||
|
||||
// And a set of primitive type.
|
||||
IntSet intSet = new IntSet();
|
||||
checkThat(intSet.Count == 0, "is initially empty");
|
||||
checkThat(intSet.Add(17), "17 added successfully");
|
||||
checkThat(!intSet.Add(17), "17 not added again");
|
||||
checkThat(intSet.Count == 1, "not empty any more");
|
||||
checkThat(intSet.Add(289), "289 added successfully");
|
||||
checkThat(intSet.Count == 2, "even less empty now");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@
|
|||
};
|
||||
%}
|
||||
|
||||
// This one doesn't work in Java correctly yet.
|
||||
#ifdef SWIGCSHARP
|
||||
%template(IntSet) std::set<int>;
|
||||
#endif
|
||||
%template(StringSet) std::set<std::string>;
|
||||
%template(FooSet) std::set<Foo>;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue