diff --git a/binding_generator.py b/binding_generator.py index de428bc46..42ed0a735 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -376,8 +376,8 @@ def generate_gdextension_interface_loader_header(data): versions = sorted(data.keys()) for version in versions: (major, minor) = version.split(".") - result.append(f"// Godot 4.{minor} or newer.") - result.append(f"#if GODOT_VERSION_MINOR >= {minor}") + result.append(f"// Godot {major}.{minor} or newer.") + result.append(f"#if GODOT_VERSION >= 0x{major.zfill(2)}{minor.zfill(2)}00") for func in data[version]: name = func["name"] @@ -385,14 +385,16 @@ def generate_gdextension_interface_loader_header(data): if "deprecated" in func: (deprecated_major, deprecated_minor) = func["deprecated"]["since"].split(".") - result.append(f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION_MINOR < {deprecated_minor}") + result.append( + f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION < 0x{deprecated_major.zfill(2)}{deprecated_minor.zfill(2)}00" + ) result.append(f'extern "C" {fn} {name};') if "deprecated" in func: result.append("#endif") - result.append(f"#endif // GODOT_VERSION_MINOR >= {minor}") + result.append(f"#endif // GODOT_VERSION >= 0x{major.zfill(2)}{minor.zfill(2)}00") result.append("") result.append("} // namespace gdextension_interface") @@ -426,8 +428,8 @@ def generate_gdextension_interface_loader_source(data): for version in versions: (major, minor) = version.split(".") - result.append(f"// Godot 4.{minor} or newer.") - result.append(f"#if GODOT_VERSION_MINOR >= {minor}") + result.append(f"// Godot {major}.{minor} or newer.") + result.append(f"#if GODOT_VERSION >= 0x{major.zfill(2)}{minor.zfill(2)}00") for func in data[version]: name = func["name"] @@ -435,14 +437,16 @@ def generate_gdextension_interface_loader_source(data): if "deprecated" in func: (deprecated_major, deprecated_minor) = func["deprecated"]["since"].split(".") - result.append(f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION_MINOR < {deprecated_minor}") + result.append( + f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION < 0x{deprecated_major.zfill(2)}{deprecated_minor.zfill(2)}00" + ) result.append(f"{fn} {name} = nullptr;") if "deprecated" in func: result.append("#endif") - result.append(f"#endif // GODOT_VERSION_MINOR >= {minor}") + result.append(f"#endif // GODOT_VERSION >= 0x{major.zfill(2)}{minor.zfill(2)}00") result.append("") result.append("} // namespace gdextension_interface") @@ -454,8 +458,8 @@ def generate_gdextension_interface_loader_source(data): for version in versions: (major, minor) = version.split(".") - result.append(f"\t// Godot 4.{minor} or newer.") - result.append(f"#if GODOT_VERSION_MINOR >= {minor}") + result.append(f"\t// Godot {major}.{minor} or newer.") + result.append(f"#if GODOT_VERSION >= 0x{major.zfill(2)}{minor.zfill(2)}00") for func in data[version]: name = func["name"] @@ -466,14 +470,16 @@ def generate_gdextension_interface_loader_source(data): if "deprecated" in func: (deprecated_major, deprecated_minor) = func["deprecated"]["since"].split(".") - result.append(f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION_MINOR < {deprecated_minor}") + result.append( + f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION < 0x{deprecated_major.zfill(2)}{deprecated_minor.zfill(2)}00" + ) result.append(f"\tLOAD_PROC_ADDRESS({name}, {fn});") if "deprecated" in func: result.append("#endif") - result.append(f"#endif // GODOT_VERSION_MINOR >= {minor}") + result.append(f"#endif // GODOT_VERSION >= 0x{major.zfill(2)}{minor.zfill(2)}00") result.append("") result.append("\treturn true;") @@ -1138,7 +1144,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl if class_name == "Dictionary": result.append("\tconst Variant &operator[](const Variant &p_key) const;") result.append("\tVariant &operator[](const Variant &p_key);") - result.append("#if GODOT_VERSION_MINOR >= 4") + result.append("#if GODOT_VERSION >= 0x040400") result.append( "\tvoid set_typed(uint32_t p_key_type, const StringName &p_key_class_name, const Variant &p_key_script, uint32_t p_value_type, const StringName &p_value_class_name, const Variant &p_value_script);" ) @@ -2332,6 +2338,10 @@ def generate_version_header(api, output_dir): header.append("") + header.append( + "#define GODOT_VERSION 0x10000 * GODOT_VERSION_MAJOR + 0x100 * GODOT_VERSION_MINOR + GODOT_VERSION_PATCH" + ) + with header_file_path.open("w+", encoding="utf-8") as header_file: header_file.write("\n".join(header)) diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 749e47504..42d15593a 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -111,21 +111,21 @@ class ClassDB { static void _register_class(bool p_virtual = false, bool p_exposed = true, bool p_runtime = false); template -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 static GDExtensionObjectPtr _create_instance_func(void *data, GDExtensionBool p_notify_postinitialize) { #else static GDExtensionObjectPtr _create_instance_func(void *data) { -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 if constexpr (!std::is_abstract_v) { Wrapped::_set_construct_info(); -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 T *new_object = new ("", "") T; if (p_notify_postinitialize) { new_object->_postinitialize(); } #else T *new_object = memnew(T); -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 return new_object->_owner; } else { return nullptr; @@ -203,11 +203,11 @@ class ClassDB { static MethodBind *get_method(const StringName &p_class, const StringName &p_method); -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 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 +#endif // GODOT_VERSION >= 0x040400 static const GDExtensionInstanceBindingCallbacks *get_instance_binding_callbacks(const StringName &p_class); @@ -255,9 +255,9 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { class_register_order.push_back(cl.name); // Register this class with Godot -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 GDExtensionClassCreationInfo5 class_info = { -#elif GODOT_VERSION_MINOR >= 4 +#elif GODOT_VERSION >= 0x040400 GDExtensionClassCreationInfo4 class_info = { #else GDExtensionClassCreationInfo3 class_info = { @@ -266,9 +266,9 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { is_abstract, // GDExtensionBool is_abstract; p_exposed, // GDExtensionBool is_exposed; p_runtime, // GDExtensionBool is_runtime; -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 nullptr, // GDExtensionConstStringPtr icon_path; -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 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; @@ -286,15 +286,15 @@ 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 +#if GODOT_VERSION <= 0x040300 nullptr, // GDExtensionClassGetRID get_rid; -#endif // GODOT_VERSION_MINOR <= 3 +#endif // GODOT_VERSION <= 0x040300 (void *)&T::get_class_static(), // void *class_userdata; }; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 ::godot::gdextension_interface::classdb_register_extension_class5(::godot::gdextension_interface::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info); -#elif GODOT_VERSION_MINOR >= 4 +#elif GODOT_VERSION >= 0x040400 ::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); diff --git a/include/godot_cpp/godot.hpp b/include/godot_cpp/godot.hpp index 9c4f4ebf8..26616d2bd 100644 --- a/include/godot_cpp/godot.hpp +++ b/include/godot_cpp/godot.hpp @@ -40,7 +40,7 @@ extern "C" GDExtensionInterfaceGetProcAddress get_proc_address; extern "C" GDExtensionClassLibraryPtr library; extern "C" void *token; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 extern "C" GDExtensionGodotVersion2 godot_version; #else extern "C" GDExtensionGodotVersion godot_version; @@ -73,7 +73,7 @@ class GDExtensionBinding { GDExtensionInitializationLevel minimum_initialization_level = GDEXTENSION_INITIALIZATION_CORE; Callback init_callback = nullptr; Callback terminate_callback = nullptr; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 GDExtensionMainLoopCallbacks main_loop_callbacks = {}; inline bool has_main_loop_callbacks() const { @@ -114,7 +114,7 @@ class GDExtensionBinding { void register_terminator(Callback p_init) const; void set_minimum_library_initialization_level(ModuleInitializationLevel p_level) const; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 // Register a callback that is called after all initialization levels when Godot is fully initialized. void register_startup_callback(GDExtensionMainLoopStartupCallback p_callback) const; // Register a callback that is called for every process frame. This will run after all `_process()` methods on Node, and before `ScriptServer::frame()`. diff --git a/include/godot_cpp/variant/typed_dictionary.hpp b/include/godot_cpp/variant/typed_dictionary.hpp index 0b8547147..dd94c1e30 100644 --- a/include/godot_cpp/variant/typed_dictionary.hpp +++ b/include/godot_cpp/variant/typed_dictionary.hpp @@ -32,7 +32,7 @@ #include -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 #include #include @@ -470,4 +470,4 @@ MAKE_TYPED_DICTIONARY_INFO(IPAddress, Variant::STRING) #else #error "TypedDictionary is only supported when targeting Godot 4.4+" -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 diff --git a/include/godot_cpp/variant/variant_internal.hpp b/include/godot_cpp/variant/variant_internal.hpp index 711029ec2..5e6a0229c 100644 --- a/include/godot_cpp/variant/variant_internal.hpp +++ b/include/godot_cpp/variant/variant_internal.hpp @@ -32,7 +32,7 @@ #include -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 #include #include @@ -509,4 +509,4 @@ struct VariantDefaultInitializer { } // namespace godot -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp index 38b485de4..c37e184ec 100644 --- a/src/classes/wrapped.cpp +++ b/src/classes/wrapped.cpp @@ -60,7 +60,7 @@ void Wrapped::_postinitialize() { Wrapped::_constructing_mutex.unlock(); #endif -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 Object *obj = dynamic_cast(this); if (obj) { obj->notification(Object::NOTIFICATION_POSTINITIALIZE); @@ -70,7 +70,7 @@ void Wrapped::_postinitialize() { if (_is_extension_class()) { _notificationv(Object::NOTIFICATION_POSTINITIALIZE); } -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 } Wrapped::Wrapped(const StringName &p_godot_class) { @@ -81,7 +81,7 @@ Wrapped::Wrapped(const StringName &p_godot_class) { } else #endif { -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 _owner = ::godot::gdextension_interface::classdb_construct_object2(reinterpret_cast(p_godot_class._native_ptr())); #else _owner = ::godot::gdextension_interface::classdb_construct_object(reinterpret_cast(p_godot_class._native_ptr())); diff --git a/src/core/class_db.cpp b/src/core/class_db.cpp index 2f5b3177d..98c74267b 100644 --- a/src/core/class_db.cpp +++ b/src/core/class_db.cpp @@ -284,11 +284,11 @@ void ClassDB::bind_integer_constant(const StringName &p_class_name, const String ::godot::gdextension_interface::classdb_register_extension_class_integer_constant(::godot::gdextension_interface::library, p_class_name._native_ptr(), p_enum_name._native_ptr(), p_constant_name._native_ptr(), p_constant_value, p_is_bitfield); } -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 GDExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash) { #else GDExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDExtensionConstStringNamePtr p_name) { -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 // This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance. // Because of this, it can happen from different threads at once. // It should be ok not using any mutex as long as we only READ data. @@ -304,11 +304,11 @@ GDExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDExtens while (type != nullptr) { AHashMap::ConstIterator method_it = type->virtual_methods.find(*name); -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 if (method_it != type->virtual_methods.end() && method_it->value.hash == p_hash) { #else if (method_it != type->virtual_methods.end()) { -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 return method_it->value.func; } diff --git a/src/core/memory.cpp b/src/core/memory.cpp index e24f98a89..4b4179ce2 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -35,7 +35,7 @@ namespace godot { void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { -#if GODOT_VERSION_MINOR >= 6 +#if GODOT_VERSION >= 0x040600 return ::godot::gdextension_interface::mem_alloc2(p_bytes, p_pad_align); #else void *mem = ::godot::gdextension_interface::mem_alloc(p_bytes + (p_pad_align ? DATA_OFFSET : 0)); @@ -58,7 +58,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { return nullptr; } -#if GODOT_VERSION_MINOR >= 6 +#if GODOT_VERSION >= 0x040600 return ::godot::gdextension_interface::mem_realloc2(p_memory, p_bytes, p_pad_align); #else uint8_t *mem = (uint8_t *)p_memory; @@ -74,7 +74,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { } void Memory::free_static(void *p_ptr, bool p_pad_align) { -#if GODOT_VERSION_MINOR >= 6 +#if GODOT_VERSION >= 0x040600 ::godot::gdextension_interface::mem_free2(p_ptr, p_pad_align); #else uint8_t *mem = (uint8_t *)p_ptr; diff --git a/src/godot.cpp b/src/godot.cpp index c1b27790d..f10fc0e8e 100644 --- a/src/godot.cpp +++ b/src/godot.cpp @@ -50,7 +50,7 @@ GDExtensionInterfaceGetProcAddress get_proc_address = nullptr; GDExtensionClassLibraryPtr library = nullptr; void *token = nullptr; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 GDExtensionGodotVersion2 godot_version = {}; #else GDExtensionGodotVersion godot_version = {}; @@ -146,7 +146,7 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge ::godot::gdextension_interface::library = p_library; ::godot::gdextension_interface::token = p_library; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 LOAD_PROC_ADDRESS(get_godot_version2, GDExtensionInterfaceGetGodotVersion2); ::godot::gdextension_interface::get_godot_version2(&::godot::gdextension_interface::godot_version); #else @@ -213,14 +213,14 @@ void GDExtensionBinding::initialize_level(void *p_userdata, GDExtensionInitializ } level_initialized[p_level]++; -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_CORE && init_data && init_data->has_main_loop_callbacks()) { ::godot::gdextension_interface::register_main_loop_callbacks(::godot::gdextension_interface::library, &init_data->main_loop_callbacks); } #endif if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) { -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 ::godot::gdextension_interface::editor_register_get_classes_used_callback(::godot::gdextension_interface::library, &ClassDB::_editor_get_classes_used_callback); #endif @@ -291,7 +291,7 @@ void GDExtensionBinding::InitObject::set_minimum_library_initialization_level(Mo init_data->minimum_initialization_level = static_cast(p_level); } -#if GODOT_VERSION_MINOR >= 5 +#if GODOT_VERSION >= 0x040500 void GDExtensionBinding::InitObject::register_startup_callback(GDExtensionMainLoopStartupCallback p_callback) const { init_data->main_loop_callbacks.startup_func = p_callback; } diff --git a/src/variant/packed_arrays.cpp b/src/variant/packed_arrays.cpp index c5c9c7871..bdf6b11f7 100644 --- a/src/variant/packed_arrays.cpp +++ b/src/variant/packed_arrays.cpp @@ -250,12 +250,12 @@ Variant &Dictionary::operator[](const Variant &p_key) { return *var; } -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 void Dictionary::set_typed(uint32_t p_key_type, const StringName &p_key_class_name, const Variant &p_key_script, uint32_t p_value_type, const StringName &p_value_class_name, const Variant &p_value_script) { // p_key_type/p_value_type are not Variant::Type so that header doesn't depend on . ::godot::gdextension_interface::dictionary_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_key_type, (GDExtensionConstStringNamePtr)&p_key_class_name, (GDExtensionConstVariantPtr)&p_key_script, (GDExtensionVariantType)p_value_type, (GDExtensionConstStringNamePtr)&p_value_class_name, (GDExtensionConstVariantPtr)&p_value_script); } -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 } // namespace godot diff --git a/src/variant/variant.cpp b/src/variant/variant.cpp index 884513b9d..287bcefd3 100644 --- a/src/variant/variant.cpp +++ b/src/variant/variant.cpp @@ -51,9 +51,9 @@ void Variant::init_bindings() { to_type_constructor[i] = ::godot::gdextension_interface::get_variant_to_type_constructor((GDExtensionVariantType)i); } -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 VariantInternal::init_bindings(); -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 StringName::init_bindings(); String::init_bindings(); @@ -453,7 +453,7 @@ Variant::operator ObjectID() const { if (get_type() == Type::INT) { return ObjectID(operator uint64_t()); } else if (get_type() == Type::OBJECT) { -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 return ObjectID(::godot::gdextension_interface::variant_get_object_instance_id(_native_ptr())); #else // Note: This isn't safe, because the object may have already been freed, but it's the best we @@ -464,7 +464,7 @@ Variant::operator ObjectID() const { } else { return ObjectID(); } -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 } else { return ObjectID(); } @@ -527,12 +527,12 @@ Variant::operator PackedVector4Array() const { } Object *Variant::get_validated_object() const { -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 return ObjectDB::get_instance(operator ObjectID()); #else // Note: This isn't actually validated, but we can't do any better in Godot 4.3 or earlier. return operator Object *(); -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 } Variant &Variant::operator=(const Variant &other) { diff --git a/src/variant/variant_internal.cpp b/src/variant/variant_internal.cpp index 120bf0151..4b22e3e9b 100644 --- a/src/variant/variant_internal.cpp +++ b/src/variant/variant_internal.cpp @@ -30,7 +30,7 @@ #include -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 namespace godot { @@ -44,4 +44,4 @@ void VariantInternal::init_bindings() { } // namespace godot -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 diff --git a/test/src/example.cpp b/test/src/example.cpp index f1bc687e5..702a20e76 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -209,10 +209,10 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("test_tarray"), &Example::test_tarray); ClassDB::bind_method(D_METHOD("test_dictionary"), &Example::test_dictionary); -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 ClassDB::bind_method(D_METHOD("test_tdictionary_arg", "dictionary"), &Example::test_tdictionary_arg); ClassDB::bind_method(D_METHOD("test_tdictionary"), &Example::test_tdictionary); -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 ClassDB::bind_method(D_METHOD("test_node_argument"), &Example::test_node_argument); ClassDB::bind_method(D_METHOD("test_string_ops"), &Example::test_string_ops); @@ -257,9 +257,9 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind); ClassDB::bind_method(D_METHOD("test_post_initialize"), &Example::test_post_initialize); -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 ClassDB::bind_method(D_METHOD("test_get_internal", "a"), &Example::test_get_internal); -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 GDVIRTUAL_BIND(_do_something_virtual, "name", "value"); ClassDB::bind_method(D_METHOD("test_virtual_implemented_in_script"), &Example::test_virtual_implemented_in_script); @@ -574,7 +574,7 @@ Dictionary Example::test_dictionary() const { return dict; } -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 int Example::test_tdictionary_arg(const TypedDictionary &p_dictionary) { int sum = 0; TypedArray values = p_dictionary.values(); @@ -591,7 +591,7 @@ TypedDictionary Example::test_tdictionary() const { return dict; } -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 Example *Example::test_node_argument(Example *p_node) const { return p_node; @@ -774,7 +774,7 @@ Ref Example::test_get_internal_class() const { return it; } -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 int64_t Example::test_get_internal(const Variant &p_input) const { if (p_input.get_type() != Variant::INT) { return -1; @@ -782,7 +782,7 @@ int64_t Example::test_get_internal(const Variant &p_input) const { return *VariantInternal::get_int(&p_input); } -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 void ExampleRuntime::_bind_methods() { ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value); diff --git a/test/src/example.h b/test/src/example.h index 4e6208361..36892a49a 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -24,9 +24,9 @@ #include #include -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 #include -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 #include #include @@ -139,10 +139,10 @@ class Example : public Control { TypedArray test_tarray() const; Dictionary test_dictionary() const; -#if GODOT_VERSION_MINOR >= 4 +#if GODOT_VERSION >= 0x040400 int test_tdictionary_arg(const TypedDictionary &p_dictionary); TypedDictionary test_tdictionary() const; -#endif // GODOT_VERSION_MINOR >= 4 +#endif // GODOT_VERSION >= 0x040400 Example *test_node_argument(Example *p_node) const; String test_string_ops() const;