From 7f74fe7bb20b1f7201781090857206ce105d17e1 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Mon, 10 Jun 2024 10:51:52 -0500 Subject: [PATCH] Fix undefined symbol error on Linux with virtual methods that take `Node *` arguments --- include/godot_cpp/classes/ref.hpp | 8 ++++---- include/godot_cpp/core/type_info.hpp | 20 ++++++++++---------- test/src/example.cpp | 1 + test/src/example.h | 1 + 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index c4682bcf..137b677b 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -261,8 +261,8 @@ struct PtrToArg &> { template struct GetTypeInfo, typename EnableIf::value>::type> { - static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; + static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); @@ -271,8 +271,8 @@ struct GetTypeInfo, typename EnableIf::value> template struct GetTypeInfo &, typename EnableIf::value>::type> { - static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; + static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index 096e0ecb..19f37250 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -208,8 +208,8 @@ struct GetTypeInfo { template struct GetTypeInfo::value>::type> { - static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; + static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } @@ -217,8 +217,8 @@ struct GetTypeInfo::value>::type> template struct GetTypeInfo::value>::type> { - static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; + static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } @@ -236,8 +236,8 @@ inline String enum_qualified_name_to_class_info_name(const String &p_qualified_n #define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \ template <> \ struct GetTypeInfo { \ - static const Variant::Type VARIANT_TYPE = Variant::INT; \ - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \ + static constexpr Variant::Type VARIANT_TYPE = Variant::INT; \ + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \ static inline PropertyInfo get_class_info() { \ return make_property_info(Variant::Type::INT, "", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, \ enum_qualified_name_to_class_info_name(#m_enum)); \ @@ -274,8 +274,8 @@ public: #define TEMPL_MAKE_BITFIELD_TYPE_INFO(m_enum, m_impl) \ template <> \ struct GetTypeInfo { \ - static const Variant::Type VARIANT_TYPE = Variant::INT; \ - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \ + static constexpr Variant::Type VARIANT_TYPE = Variant::INT; \ + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \ static inline PropertyInfo get_class_info() { \ return make_property_info(Variant::Type::INT, "", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \ enum_qualified_name_to_class_info_name(#m_enum)); \ @@ -283,8 +283,8 @@ public: }; \ template <> \ struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = Variant::INT; \ - static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \ + static constexpr Variant::Type VARIANT_TYPE = Variant::INT; \ + static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \ static inline PropertyInfo get_class_info() { \ return make_property_info(Variant::Type::INT, "", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \ enum_qualified_name_to_class_info_name(#m_enum)); \ diff --git a/test/src/example.cpp b/test/src/example.cpp index 78d70622..c4452681 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -239,6 +239,7 @@ void Example::_bind_methods() { GDVIRTUAL_BIND(_do_something_virtual, "name", "value"); ClassDB::bind_method(D_METHOD("test_virtual_implemented_in_script"), &Example::test_virtual_implemented_in_script); + GDVIRTUAL_BIND(_do_something_virtual_with_control, "control"); ClassDB::bind_method(D_METHOD("test_use_engine_singleton"), &Example::test_use_engine_singleton); diff --git a/test/src/example.h b/test/src/example.h index 1af4e5fa..9fa2b072 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -186,6 +186,7 @@ public: GDVIRTUAL2R(String, _do_something_virtual, String, int); String test_virtual_implemented_in_script(const String &p_name, int p_value); + GDVIRTUAL1(_do_something_virtual_with_control, Control *); String test_use_engine_singleton() const; };