diff --git a/CHANGES.current b/CHANGES.current index 3bf9ac866..99f219372 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-31: wsfulton + [Python] #1319 C++11 hash tables support: + std::unordered_map + std::unordered_set + std::unordered_multimap + std::unordered_multiset + is now compiling and working (sorting using -builtin not fully functional yet though). + 2018-08-20: wkalinin #1305 Fix nested structure symbol tables in C mode to fix member name conflicts in different structs with the same nested struct member name. diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 6ad3b634f..1402239b9 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -85,6 +85,10 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ cpp11_shared_ptr_upcast \ + cpp11_std_unordered_map \ + cpp11_std_unordered_multimap \ + cpp11_std_unordered_multiset \ + cpp11_std_unordered_set \ C_TEST_CASES += \ file_test \ diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index bec7d165d..959f303a3 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -1,8 +1,59 @@ /* Unordered Maps */ +%include -%fragment("StdUnorderedMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdUnorderedMapForwardIteratorTraits","header") +{ + namespace swig { + template + struct SwigPyMapForwardIterator_T : SwigPyForwardIteratorClosed_T + { + SwigPyMapForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyForwardIteratorClosed_T(curr, first, last, seq) + { + } + }; + + + template > + struct SwigPyMapKeyForwardIterator_T : SwigPyMapForwardIterator_T + { + SwigPyMapKeyForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapForwardIterator_T(curr, first, last, seq) + { + } + }; + + template + inline SwigPyIterator* + make_output_key_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapKeyForwardIterator_T(current, begin, end, seq); + } + + template > + struct SwigPyMapValueForwardIterator_T : SwigPyMapForwardIterator_T + { + SwigPyMapValueForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapForwardIterator_T(curr, first, last, seq) + { + } + }; + + + template + inline SwigPyIterator* + make_output_value_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapValueForwardIterator_T(current, begin, end, seq); + } + } +} + +%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { template @@ -73,51 +124,6 @@ } } }; - - template - struct SwigPyMapForwardIterator_T : SwigPyForwardIteratorClosed_T - { - SwigPyMapForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyForwardIteratorClosed_T(curr, first, last, seq) - { - } - }; - - - template > - struct SwigPyMapKeyForwardIterator_T : SwigPyMapForwardIterator_T - { - SwigPyMapKeyForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapForwardIterator_T(curr, first, last, seq) - { - } - }; - - template - inline SwigPyIterator* - make_output_key_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapKeyForwardIterator_T(current, begin, end, seq); - } - - template > - struct SwigPyMapValueForwardIterator_T : SwigPyMapForwardIterator_T - { - SwigPyMapValueForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapForwardIterator_T(curr, first, last, seq) - { - } - }; - - - template - inline SwigPyIterator* - make_output_value_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapValueForwardIterator_T(current, begin, end, seq); - } } } diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index 6d7def900..aa29a7cff 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -3,7 +3,7 @@ */ %include -%fragment("StdUnorderedMultimapTraits","header",fragment="StdSequenceTraits") +%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { template