Add back support for Godot 4.3
This commit is contained in:
@ -110,6 +110,7 @@ protected:
|
||||
::godot::List<::godot::PropertyInfo> plist_owned;
|
||||
|
||||
void _postinitialize();
|
||||
virtual void _notificationv(int32_t p_what, bool p_reversed = false) {}
|
||||
|
||||
Wrapped(const StringName &p_godot_class);
|
||||
Wrapped(GodotObject *p_godot_object);
|
||||
@ -404,6 +405,11 @@ public:
|
||||
_gde_binding_reference_callback, \
|
||||
}; \
|
||||
\
|
||||
protected: \
|
||||
virtual void _notificationv(int32_t p_what, bool p_reversed = false) override { \
|
||||
m_class::notification_bind(this, p_what, p_reversed); \
|
||||
} \
|
||||
\
|
||||
private:
|
||||
|
||||
// Don't use this for your classes, use GDCLASS() instead.
|
||||
|
||||
@ -111,13 +111,21 @@ private:
|
||||
static void _register_class(bool p_virtual = false, bool p_exposed = true, bool p_runtime = false);
|
||||
|
||||
template <typename T>
|
||||
#if GODOT_VERSION_MINOR >= 4
|
||||
static GDExtensionObjectPtr _create_instance_func(void *data, GDExtensionBool p_notify_postinitialize) {
|
||||
#else
|
||||
static GDExtensionObjectPtr _create_instance_func(void *data) {
|
||||
#endif // GODOT_VERSION_MINOR >= 4
|
||||
if constexpr (!std::is_abstract_v<T>) {
|
||||
Wrapped::_set_construct_info<T>();
|
||||
#if GODOT_VERSION_MINOR >= 4
|
||||
T *new_object = new ("", "") T;
|
||||
if (p_notify_postinitialize) {
|
||||
new_object->_postinitialize();
|
||||
}
|
||||
#else
|
||||
T *new_object = memnew(T);
|
||||
#endif // GODOT_VERSION_MINOR >= 4
|
||||
return new_object->_owner;
|
||||
} else {
|
||||
return nullptr;
|
||||
@ -195,7 +203,12 @@ public:
|
||||
|
||||
static MethodBind *get_method(const StringName &p_class, const StringName &p_method);
|
||||
|
||||
#if GODOT_VERSION_MINOR >= 4
|
||||
static GDExtensionClassCallVirtual get_virtual_func(void *p_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash);
|
||||
#else
|
||||
static GDExtensionClassCallVirtual get_virtual_func(void *p_userdata, GDExtensionConstStringNamePtr p_name);
|
||||
#endif // GODOT_VERSION_MINOR >= 4
|
||||
|
||||
static const GDExtensionInstanceBindingCallbacks *get_instance_binding_callbacks(const StringName &p_class);
|
||||
|
||||
static void initialize(GDExtensionInitializationLevel p_level);
|
||||
@ -244,14 +257,18 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
|
||||
// Register this class with Godot
|
||||
#if GODOT_VERSION_MINOR >= 5
|
||||
GDExtensionClassCreationInfo5 class_info = {
|
||||
#else
|
||||
#elif GODOT_VERSION_MINOR >= 4
|
||||
GDExtensionClassCreationInfo4 class_info = {
|
||||
#else
|
||||
GDExtensionClassCreationInfo3 class_info = {
|
||||
#endif
|
||||
p_virtual, // GDExtensionBool is_virtual;
|
||||
is_abstract, // GDExtensionBool is_abstract;
|
||||
p_exposed, // GDExtensionBool is_exposed;
|
||||
p_runtime, // GDExtensionBool is_runtime;
|
||||
#if GODOT_VERSION_MINOR >= 4
|
||||
nullptr, // GDExtensionConstStringPtr icon_path;
|
||||
#endif // GODOT_VERSION_MINOR >= 4
|
||||
T::set_bind, // GDExtensionClassSet set_func;
|
||||
T::get_bind, // GDExtensionClassGet get_func;
|
||||
T::has_get_property_list() ? T::get_property_list_bind : nullptr, // GDExtensionClassGetPropertyList get_property_list_func;
|
||||
@ -269,13 +286,18 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
|
||||
&ClassDB::get_virtual_func, // GDExtensionClassGetVirtual get_virtual_func;
|
||||
nullptr, // GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
|
||||
nullptr, // GDExtensionClassCallVirtualWithData call_virtual_func;
|
||||
#if GODOT_VERSION_MINOR <= 3
|
||||
nullptr, // GDExtensionClassGetRID get_rid;
|
||||
#endif // GODOT_VERSION_MINOR <= 3
|
||||
(void *)&T::get_class_static(), // void *class_userdata;
|
||||
};
|
||||
|
||||
#if GODOT_VERSION_MINOR >= 5
|
||||
::godot::gdextension_interface::classdb_register_extension_class5(::godot::gdextension_interface::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||
#else
|
||||
#elif GODOT_VERSION_MINOR >= 4
|
||||
::godot::gdextension_interface::classdb_register_extension_class4(::godot::gdextension_interface::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||
#else
|
||||
::godot::gdextension_interface::classdb_register_extension_class3(::godot::gdextension_interface::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||
#endif
|
||||
|
||||
// call bind_methods etc. to register all members of the class
|
||||
|
||||
@ -30,6 +30,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <godot_cpp/core/version.hpp>
|
||||
|
||||
#if GODOT_VERSION_MINOR >= 4
|
||||
|
||||
#include <godot_cpp/core/type_info.hpp>
|
||||
#include <godot_cpp/templates/pair.hpp>
|
||||
#include <godot_cpp/variant/dictionary.hpp>
|
||||
@ -463,3 +467,7 @@ MAKE_TYPED_DICTIONARY_INFO(IPAddress, Variant::STRING)
|
||||
#undef MAKE_TYPED_DICTIONARY_INFO_WITH_OBJECT
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#else
|
||||
#error "TypedDictionary is only supported when targeting Godot 4.4+"
|
||||
#endif // GODOT_VERSION_MINOR >= 4
|
||||
|
||||
@ -411,10 +411,11 @@ Array::ConstIterator Array::end() const {
|
||||
Array::Array(std::initializer_list<Variant> p_init) :
|
||||
Array() {
|
||||
ERR_FAIL_COND(resize(p_init.size()) != 0);
|
||||
Variant *variant_ptr = ptrw();
|
||||
|
||||
size_t i = 0;
|
||||
for (const Variant &element : p_init) {
|
||||
set(i++, element);
|
||||
variant_ptr[i++] = element;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <godot_cpp/core/version.hpp>
|
||||
|
||||
#if GODOT_VERSION_MINOR >= 4
|
||||
|
||||
#include <gdextension_interface.h>
|
||||
#include <godot_cpp/variant/variant.hpp>
|
||||
|
||||
@ -504,3 +508,5 @@ struct VariantDefaultInitializer {
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#endif // GODOT_VERSION_MINOR >= 4
|
||||
|
||||
Reference in New Issue
Block a user