From 0e324c444c98f0c67708bdb28caf215e7b187775 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:49:24 +0300 Subject: [PATCH] Add android gd string and comment out addresses for now --- codegen/src/AddressGen.cpp | 2 +- loader/src/platform/android/gdstdlib.cpp | 61 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 loader/src/platform/android/gdstdlib.cpp diff --git a/codegen/src/AddressGen.cpp b/codegen/src/AddressGen.cpp index bc154b1c..295ccbde 100644 --- a/codegen/src/AddressGen.cpp +++ b/codegen/src/AddressGen.cpp @@ -122,7 +122,7 @@ std::string generateAddressHeader(Root const& root) { } else if (codegen::getStatus(field) == BindStatus::Binded && fn->prototype.type == FunctionType::Normal) { address_str = fmt::format( - "addresser::get{}Virtual(Resolve<{}>::func(&{}::{}))", + "0/*addresser::get{}Virtual(Resolve<{}>::func(&{}::{}))*/", str_if("Non", !fn->prototype.is_virtual), codegen::getParameterTypes(fn->prototype), field.parent, diff --git a/loader/src/platform/android/gdstdlib.cpp b/loader/src/platform/android/gdstdlib.cpp new file mode 100644 index 00000000..d4ec8653 --- /dev/null +++ b/loader/src/platform/android/gdstdlib.cpp @@ -0,0 +1,61 @@ +#include + +#ifdef GEODE_IS_ANDROID + +namespace gd { + namespace { + static inline auto emptyInternalString() { + return reinterpret_cast<_internal_string*>( + *reinterpret_cast(geode::base::get() + 0x75fb24) + sizeof(_internal_string) + ); + } + } + + string::string() : m_data(nullptr) { + m_data = emptyInternalString(); + } + + string::string(char const* ok) : m_data(nullptr) { + reinterpret_cast(geode::base::get() + 0x506c08)(this, ok); + } + + string::string(string const& ok) : m_data(nullptr) { + if (*(string**)(&ok) == nullptr) return; + reinterpret_cast(geode::base::get() + 0x506634)(this, ok); + } + + string& string::operator=(char const* ok) { + this->~string(); + new (this) string(ok); + return *this; + } + + string& string::operator=(string const& ok) { + this->~string(); + new (this) string(ok); + return *this; + } + + string::~string() { + if (m_data == nullptr) return; + reinterpret_cast(geode::base::get() + 0x5054bc)( + &m_data[-1] + ); + } + + bool string::operator<(string const& other) const { + return std::string(*this) < std::string(other); + } + + bool string::operator==(string const& other) const { + return std::string(*this) == std::string(other); + } + + // TODO: these need to stay for old mods linking against geode <1.2.0, remove in 2.0.0 + template class map; + template class map; + template class map; + template class map; +} + +#endif \ No newline at end of file