Skip to content

Commit

Permalink
compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
PraneethJain committed Jul 19, 2024
1 parent 62bf792 commit 1ff2ad8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/jlcxx/stl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class JLCXX_API StlWrappers
TypeWrapper1 multiset;
TypeWrapper1 unordered_set;
TypeWrapper1 unordered_multiset;
TypeWrapper1 list_iterator;
TypeWrapper1 list;
TypeWrapper1 forward_list;

Expand All @@ -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();
Expand Down Expand Up @@ -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<T>{v.begin()}; });
wrapped.method("iteratorend", [] (WrappedT& v) { return DequeIteratorWrapper<T>{v.begin()}; });
wrapped.method("iteratorend", [] (WrappedT& v) { return DequeIteratorWrapper<T>{v.end()}; });
wrapped.module().unset_override_module();
}
};
Expand Down Expand Up @@ -394,6 +396,9 @@ struct WrapMultisetType
}
};

template <typename valueT>
struct ListIteratorWrapper : IteratorWrapper<valueT, std::list> {};

struct WrapList
{
template<typename TypeWrapperT>
Expand All @@ -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<T>{v.begin()}; });
wrapped.method("iteratorend", [] (WrappedT& v) { return ListIteratorWrapper<T>{v.end()}; });
wrapped.module().unset_override_module();
}
};
Expand Down Expand Up @@ -506,6 +513,7 @@ inline void apply_stl(jlcxx::Module& mod)
TypeWrapper1(mod, StlWrappers::instance().unordered_set).apply<std::unordered_set<T>>(WrapSetType());
TypeWrapper1(mod, StlWrappers::instance().unordered_multiset).apply<std::unordered_multiset<T>>(WrapMultisetType());
}
TypeWrapper1(mod, StlWrappers::instance().list_iterator).apply<stl::ListIteratorWrapper<T>>(WrapIterator());
TypeWrapper1(mod, StlWrappers::instance().list).apply<std::list<T>>(WrapList());
TypeWrapper1(mod, StlWrappers::instance().forward_list).apply<std::forward_list<T>>(WrapForwardList());
}
Expand Down
2 changes: 2 additions & 0 deletions src/stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -63,6 +64,7 @@ JLCXX_API StlWrappers::StlWrappers(Module& stl) :
multiset(stl.add_type<Parametric<TypeVar<1>>>("StdMultiset")),
unordered_set(stl.add_type<Parametric<TypeVar<1>>>("StdUnorderedSet")),
unordered_multiset(stl.add_type<Parametric<TypeVar<1>>>("StdUnorderedMultiset")),
list_iterator(stl.add_type<Parametric<TypeVar<1>>>("StdListIterator")),
list(stl.add_type<Parametric<TypeVar<1>>>("StdList")),
forward_list(stl.add_type<Parametric<TypeVar<1>>>("StdForwardList"))
{
Expand Down
5 changes: 5 additions & 0 deletions src/stl_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace jlcxx
namespace stl
{

void apply_list_iterator(TypeWrapper1& list_iterator)
{
list_iterator.apply_combination<stl::ListIteratorWrapper, stltypes>(stl::WrapIterator());
}

void apply_list(TypeWrapper1& list)
{
list.apply_combination<std::list, stltypes>(stl::WrapList());
Expand Down

0 comments on commit 1ff2ad8

Please sign in to comment.