Skip to content

Commit

Permalink
c++ abi can go burn in gaseous tungsten
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Oct 1, 2023
1 parent b0ab2f9 commit fc58ab7
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 16 deletions.
14 changes: 7 additions & 7 deletions bindings/GeometryDash.bro
Original file line number Diff line number Diff line change
Expand Up @@ -3611,7 +3611,7 @@ class GameObject : CCSpritePlus {
bool m_unk3D9;
bool m_isSelected;
int m_globalClickCounter;
PAD = mac 0x8, win 0x8;
PAD = mac 0x8, win 0x8, android 0x8;
bool m_shouldUpdateColorSprite;
float m_multiScaleMultiplier;
bool m_isGroupParent;
Expand All @@ -3624,20 +3624,20 @@ class GameObject : CCSpritePlus {
int m_editorLayer;
int m_editorLayer2;
int m_unk414;
PAD = mac 0xc, win 0xc;
PAD = mac 0xc, win 0xc, android 0xc;
cocos2d::CCPoint m_firstPosition;
bool m_unk42C;
bool m_unk42D;
PAD = mac 0x6, win 0x6;
PAD = mac 0x6, win 0x6, android 0x6;
bool m_isAnimated;
PAD = mac 0x7, win 0x7;
PAD = mac 0x7, win 0x7, android 0x7;
bool m_hasEffectLine;
bool m_specialUnk43d;
PAD = mac 0x1, win 0x1;
PAD = mac 0x1, win 0x1, android 0x1;
bool m_hasDurationLine;
bool m_isTriggerable;
bool m_triggeredInEditor;
PAD = mac 0x6, win 0x6;
PAD = mac 0x6, win 0x6, android 0x6;
bool m_highDetail;
ColorActionSprite* m_colorActionSpriteBase;
ColorActionSprite* m_colorActionSpriteDetail;
Expand All @@ -3646,7 +3646,7 @@ class GameObject : CCSpritePlus {
bool m_unk459;
bool m_unk45A;
bool m_wasForcedRotatedPositionUpdateIdk;
PAD = mac 0x8, win 0x8;
PAD = mac 0x8, win 0x8, android 0x8;
bool m_orbMultiActivate;
}

Expand Down
18 changes: 15 additions & 3 deletions codegen/src/AndroidSymbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <string>
#include <string_view>

std::string mangleIdent(std::string_view str) {
std::string mangleIdent(std::string_view str, bool ne = true) {
if (str.find("::") != -1) {
std::string result = "N";
std::string result = ne ? "N" : "";
auto s = str;
do {
const auto i = s.find("::");
Expand All @@ -19,7 +19,7 @@ std::string mangleIdent(std::string_view str) {
else
s = s.substr(i + 2);
} while(s.size());
return result + "E";
return result + (ne ? "E" : "");
} else {
return std::to_string(str.size()) + std::string(str);
}
Expand Down Expand Up @@ -125,6 +125,18 @@ std::string mangleType(std::vector<std::string>& seen, std::string name, bool su
std::string generateAndroidSymbol(const Class& clazz, const FunctionBindField* fn) {
auto& decl = fn->prototype;

if (decl.type != FunctionType::Normal) {
// ctor and dtor
switch (decl.type) {
case FunctionType::Ctor:
return "_ZN" + mangleIdent(clazz.name, false) + "C2Ev";
case FunctionType::Dtor:
return "_ZN" + mangleIdent(clazz.name, false) + "D2Ev";
default:
throw std::runtime_error("Unknown function type");
}
}

std::string mangledSymbol = "_Z" + mangleIdent(clazz.name + "::" + decl.name);
if (decl.args.empty()) {
mangledSymbol += "v";
Expand Down
1 change: 1 addition & 0 deletions codegen/src/Shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ namespace codegen {

inline bool shouldAndroidBind(const FunctionBindField* fn) {
if (codegen::platform == Platform::Android) {
if (fn->prototype.type != FunctionType::Normal) return true;
for (auto& [type, name] : fn->prototype.args) {
if (can_find(type.name, "gd::")) return true;
}
Expand Down
10 changes: 5 additions & 5 deletions loader/include/Geode/DefaultInclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ namespace geode {
GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) \
GEODE_WINDOWS(Class_(geode::CutoffConstructorType, size_t fill) \
: Class_() {}) \
GEODE_ANDROID(Class_(geode::CutoffConstructorType, size_t fill) \
: Class_() {})
GEODE_ANDROID(GEODE_FILL_CONSTRUCTOR(Class_, 0){})

#define GEODE_CUTOFF_CONSTRUCTOR_COCOS(Class_, Base_) \
GEODE_MACOS(Class_(geode::CutoffConstructorType, size_t fill) \
Expand All @@ -91,8 +90,8 @@ namespace geode {
: Base_(geode::CutoffConstructor, fill){}) \
GEODE_WINDOWS(Class_(geode::CutoffConstructorType, size_t fill) \
: Class_() {}) \
GEODE_ANDROID(Class_(geode::CutoffConstructorType, size_t fill) \
: Class_() {})
GEODE_ANDROID(Class_(geode::CutoffConstructorType, size_t fill) \
: Base_(geode::CutoffConstructor, fill){})

#define GEODE_CUTOFF_CONSTRUCTOR_GD(Class_, Base_) \
GEODE_WINDOWS(Class_(geode::CutoffConstructorType, size_t fill) \
Expand All @@ -106,7 +105,8 @@ namespace geode {

#define GEODE_CUTOFF_CONSTRUCTOR_CUTOFF(Class_, Base_) \
GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_(){}) \
GEODE_ANDROID(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_(){}) \
GEODE_ANDROID(Class_(geode::CutoffConstructorType, size_t fill) \
: Base_(geode::CutoffConstructor, fill){}) \
GEODE_MACOS(Class_(geode::CutoffConstructorType, size_t fill) \
: Base_(geode::CutoffConstructor, fill){}) \
GEODE_IOS(Class_(geode::CutoffConstructorType, size_t fill) \
Expand Down
2 changes: 2 additions & 0 deletions loader/include/Geode/cocos/platform/android/CCEGLView.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class CC_DLL CCEGLView : public CCEGLViewProtocol
{
GEODE_FRIEND_MODIFY
public:
GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCEGLView, CCEGLViewProtocol)

CCEGLView();
virtual ~CCEGLView();

Expand Down
2 changes: 1 addition & 1 deletion loader/include/Geode/modify/Field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace geode::modifier {
using Intermediate = Modify<Parent, Base>;
// Padding used for guaranteeing any member of parents
// will be in between sizeof(Intermediate) and sizeof(Parent)
uintptr_t m_padding;
alignas(Base) uintptr_t m_padding;

public:
// the constructor that constructs the fields.
Expand Down
21 changes: 21 additions & 0 deletions loader/src/hooks/LoadingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,25 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
}
this->updateLoadingBar();
}
};

#include <Geode/modify/PlayLayer.hpp>
struct FieldTest : Modify<FieldTest, PlayLayer> {
int field = 0x10101010;

bool init(GJGameLevel* level) {
if (!PlayLayer::init(level)) return false;
log::debug("GameManager 1 {}", GameManager::sharedState());
log::debug("PlayLayer 1 {}", PlayLayer::get());
m_fields->field += 0x20202020;
log::debug("GameManager 2 {}", GameManager::sharedState());
log::debug("PlayLayer 2 {}", PlayLayer::get());
return true;
}

void update(float dt) {
log::debug("GameManager {}", GameManager::sharedState());
log::debug("PlayLayer {}", PlayLayer::get());
PlayLayer::update(dt);
}
};
4 changes: 4 additions & 0 deletions loader/src/platform/android/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ extern "C" [[gnu::visibility("default")]] jint JNI_OnLoad(JavaVM* vm, void* rese
return JNI_VERSION_1_1;
}

extern "C" [[gnu::visibility("default")]] void emptyFunction(void*) {
// empty
}

#endif
2 changes: 2 additions & 0 deletions loader/test/members/Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ GEODE_MEMBER_CHECK(PlayLayer, m_bottomGround, 0x37c);
GEODE_MEMBER_CHECK(PlayLayer, m_topGround, 0x380);
GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x470);

static_assert(sizeof(GameObject) == 0x42c);

#endif

0 comments on commit fc58ab7

Please sign in to comment.