diff --git a/include/jlcxx/stl.hpp b/include/jlcxx/stl.hpp index fb76a55..9ed1c22 100644 --- a/include/jlcxx/stl.hpp +++ b/include/jlcxx/stl.hpp @@ -62,6 +62,7 @@ class JLCXX_API StlWrappers TypeWrapper1 multiset; TypeWrapper1 unordered_set; TypeWrapper1 unordered_multiset; + TypeWrapper1 list_iterator; TypeWrapper1 list; TypeWrapper1 forward_list; @@ -86,6 +87,7 @@ void apply_set(TypeWrapper1& set); void apply_multiset(TypeWrapper1& multiset); void apply_unordered_set(TypeWrapper1& unordered_set); void apply_unordered_multiset(TypeWrapper1& unordered_multiset); +void apply_list_iterator(TypeWrapper1& list_iterator); void apply_list(TypeWrapper1& list); void apply_forward_list(TypeWrapper1& forward_list); void apply_shared_ptr(); @@ -256,7 +258,7 @@ struct WrapDeque wrapped.method("pop_back!", [] (WrappedT& v) { v.pop_back(); }); wrapped.method("pop_front!", [] (WrappedT& v) { v.pop_front(); }); wrapped.method("iteratorbegin", [] (WrappedT& v) { return DequeIteratorWrapper{v.begin()}; }); - wrapped.method("iteratorend", [] (WrappedT& v) { return DequeIteratorWrapper{v.begin()}; }); + wrapped.method("iteratorend", [] (WrappedT& v) { return DequeIteratorWrapper{v.end()}; }); wrapped.module().unset_override_module(); } }; @@ -394,6 +396,9 @@ struct WrapMultisetType } }; +template +struct ListIteratorWrapper : IteratorWrapper {}; + struct WrapList { template @@ -413,6 +418,8 @@ struct WrapList wrapped.method("list_push_front!", [] (WrappedT& v, const T& val) { v.push_front(val); }); wrapped.method("list_pop_back!", [] (WrappedT& v) { v.pop_back(); }); wrapped.method("list_pop_front!", [] (WrappedT& v) { v.pop_front(); }); + wrapped.method("iteratorbegin", [] (WrappedT& v) { return ListIteratorWrapper{v.begin()}; }); + wrapped.method("iteratorend", [] (WrappedT& v) { return ListIteratorWrapper{v.end()}; }); wrapped.module().unset_override_module(); } }; @@ -506,6 +513,7 @@ inline void apply_stl(jlcxx::Module& mod) TypeWrapper1(mod, StlWrappers::instance().unordered_set).apply>(WrapSetType()); TypeWrapper1(mod, StlWrappers::instance().unordered_multiset).apply>(WrapMultisetType()); } + TypeWrapper1(mod, StlWrappers::instance().list_iterator).apply>(WrapIterator()); TypeWrapper1(mod, StlWrappers::instance().list).apply>(WrapList()); TypeWrapper1(mod, StlWrappers::instance().forward_list).apply>(WrapForwardList()); } diff --git a/src/stl.cpp b/src/stl.cpp index 6c53867..856910f 100644 --- a/src/stl.cpp +++ b/src/stl.cpp @@ -28,6 +28,7 @@ JLCXX_API void StlWrappers::instantiate(Module& mod) apply_multiset(m_instance->multiset); apply_unordered_set(m_instance->unordered_set); apply_unordered_multiset(m_instance->unordered_multiset); + apply_list_iterator(m_instance->list_iterator); apply_list(m_instance->list); apply_forward_list(m_instance->forward_list); apply_shared_ptr(); @@ -63,6 +64,7 @@ JLCXX_API StlWrappers::StlWrappers(Module& stl) : multiset(stl.add_type>>("StdMultiset")), unordered_set(stl.add_type>>("StdUnorderedSet")), unordered_multiset(stl.add_type>>("StdUnorderedMultiset")), + list_iterator(stl.add_type>>("StdListIterator")), list(stl.add_type>>("StdList")), forward_list(stl.add_type>>("StdForwardList")) { diff --git a/src/stl_list.cpp b/src/stl_list.cpp index fd9fe91..a39e26c 100644 --- a/src/stl_list.cpp +++ b/src/stl_list.cpp @@ -6,6 +6,11 @@ namespace jlcxx namespace stl { +void apply_list_iterator(TypeWrapper1& list_iterator) +{ + list_iterator.apply_combination(stl::WrapIterator()); +} + void apply_list(TypeWrapper1& list) { list.apply_combination(stl::WrapList());