Skip to content

Fix gd::vector and allow Android builds without pre-compiled headers #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions loader/include/Geode/c++stl/gnustl/stl_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
insert(const_iterator __position, size_type __n, const value_type& __x)
{
difference_type __offset = __position - cbegin();
_M_fill_insert(__position._M_const_cast(), __n, __x);
_M_fill_insert(begin() + __offset, __n, __x);
return begin() + __offset;
}
#else
Expand Down Expand Up @@ -1085,7 +1085,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_InputIterator __last)
{
difference_type __offset = __position - cbegin();
_M_insert_dispatch(__position._M_const_cast(),
_M_insert_dispatch(begin() + __offset,
__first, __last, __false_type());
return begin() + __offset;
}
Expand Down Expand Up @@ -1133,10 +1133,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
{ return _M_erase(begin() + (__position - cbegin())); }
#else
erase(iterator __position)
{ return _M_erase(__position); }
#endif
{ return _M_erase(__position._M_const_cast()); }

/**
* @brief Remove a range of elements.
Expand All @@ -1159,10 +1160,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
{
const auto __beg = begin();
const auto __cbeg = cbegin();
return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
}
#else
erase(iterator __first, iterator __last)
{ return _M_erase(__first, __last); }
#endif
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }

/**
* @brief Swaps data with another %vector.
Expand Down
9 changes: 6 additions & 3 deletions loader/include/Geode/c++stl/gnustl/vector.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
else
{
#if __cplusplus >= 201103L
const auto __pos = begin() + (__position - cbegin());
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{
_Tp __x_copy = __x;
_M_insert_aux(__position._M_const_cast(), std::move(__x_copy));
_M_insert_aux(__pos, std::move(__x_copy));
}
else
_M_insert_aux(__pos, __x);
#else
_M_insert_aux(__position, __x);
#endif
_M_insert_aux(__position._M_const_cast(), __x);
}
return iterator(this->_M_impl._M_start + __n);
}
Expand Down Expand Up @@ -320,7 +323,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
++this->_M_impl._M_finish;
}
else
_M_insert_aux(__position._M_const_cast(),
_M_insert_aux(begin() + (__position - cbegin()),
std::forward<_Args>(__args)...);
return iterator(this->_M_impl._M_start + __n);
}
Expand Down
3 changes: 1 addition & 2 deletions loader/src/platform/android/util.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using namespace geode::prelude;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite awesome

#include <Geode/utils/cocos.hpp>
#include <Geode/loader/Dirs.hpp>
#include <Geode/utils/file.hpp>
Expand All @@ -22,6 +20,7 @@ using namespace geode::prelude;
#include <Geode/cocos/platform/android/jni/JniHelper.h>

using geode::utils::permission::Permission;
using namespace geode::prelude;

bool utils::clipboard::write(std::string const& data) {
JniMethodInfo t;
Expand Down
Loading