From e8c03fea091eabc75e902ed23c5b9d50038c3e26 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Sat, 18 Mar 2023 22:22:09 +0300 Subject: [PATCH] add isBinded to codegen --- codegen/src/Shared.hpp | 44 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/codegen/src/Shared.hpp b/codegen/src/Shared.hpp index e6dcffaa..bd314975 100644 --- a/codegen/src/Shared.hpp +++ b/codegen/src/Shared.hpp @@ -84,6 +84,36 @@ namespace codegen { inline uintptr_t platformNumber(PlatformNumber const& p) { return platformNumberWithPlatform(codegen::platform, p); } + + inline bool isBindedWithPlatform(Platform p, FunctionBegin const* fb) { + if (p == Platform::Android) { + for (auto& [type, name] : fb->args) { + if (type.name.find("gd::") != std::string::npos) return false; + } + + if (field.parent.rfind("cocos2d::CCEGLView", 0) == 0) return false; + + return true; + } + + if (fb->type == FunctionType::Normal) { + if (field.parent.rfind("fmod::", 0) == 0) return true; + if (field.parent.rfind("cocos2d::", 0) == 0 && p == Platform::Windows) + return true; + } + return false; + } + + inline bool isBinded(FunctionBegin const* fb) { + return isBindedWithPlatform(codegen::platform, fb); + } + + inline bool isBinded(Field const& field) { + if (auto fn = field.get_as<FunctionBindField>()) { + return isBinded(&fn->beginning); + } + return false; + } inline BindStatus getStatusWithPlatform(Platform p, Field const& field) { FunctionBegin const* fb; @@ -100,22 +130,10 @@ namespace codegen { // if (field.parent.rfind("GDString", 0) == 0) return BindStatus::NeedsBinding; - if (p == Platform::Android) { - for (auto& [type, name] : fb->args) { - if (type.name.find("gd::") != std::string::npos) return BindStatus::NeedsBinding; - } - - if (field.parent.rfind("cocos2d::CCEGLView", 0) == 0) return BindStatus::Unbindable; - + if (isBindedWithPlatform(p, fb)) { return BindStatus::Binded; } - if (fb->type == FunctionType::Normal) { - if (field.parent.rfind("fmod::", 0) == 0) return BindStatus::Binded; - if (field.parent.rfind("cocos2d::", 0) == 0 && p == Platform::Windows) - return BindStatus::Binded; - } - return BindStatus::Unbindable; }