From 94cf94adc887eb500504dab3587cdd54d070b53c Mon Sep 17 00:00:00 2001 From: Ashton Meuser Date: Tue, 17 Sep 2024 09:25:11 -0700 Subject: [PATCH] Revert remove is_instance_valid() See https://github.com/godotengine/godot-cpp/issues/1587 --- src/defs.h | 2 ++ src/wasm.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/defs.h b/src/defs.h index a5196d4..b2e9feb 100644 --- a/src/defs.h +++ b/src/defs.h @@ -26,6 +26,7 @@ Useful for minimizing changes to implementation files between targets e.g. GDExt #define PRINT_ERROR(message) print_error("Godot Wasm: " + String(message)) #define godot_error Error #define INSTANCE_FROM_ID(id) ObjectDB::get_instance(id) + #define INSTANCE_VALIDATE(id) VariantUtilityFunctions::is_instance_valid(id) #define REGISTRATION_METHOD _bind_methods #define RANDOM_BYTES(n) Crypto::create()->generate_random_bytes(n) #else @@ -33,6 +34,7 @@ Useful for minimizing changes to implementation files between targets e.g. GDExt #define PRINT_ERROR(message) _err_print_error(__FUNCTION__, __FILE__, __LINE__, "Godot Wasm: " + String(message)) #define godot_error Error #define INSTANCE_FROM_ID(id) ObjectDB::get_instance(id) + #define INSTANCE_VALIDATE(id) UtilityFunctions::is_instance_valid(id) #define REGISTRATION_METHOD _bind_methods #define RANDOM_BYTES(n) [n]()->PackedByteArray{Ref c;c.instantiate();return c->generate_random_bytes(n);}() #endif diff --git a/src/wasm.cpp b/src/wasm.cpp index 900c9e7..b67eb02 100644 --- a/src/wasm.cpp +++ b/src/wasm.cpp @@ -335,7 +335,7 @@ namespace godot { const Array& import = dict_safe_get(functions, it.first, Array()); FAIL_IF(import.size() != 2, "Invalid import function " + it.first, ERR_CANT_CREATE); FAIL_IF(import[0].get_type() != Variant::OBJECT, "Invalid import target " + it.first, ERR_CANT_CREATE); - FAIL_IF(!INSTANCE_FROM_ID(import[0]), "Invalid import target " + it.first, ERR_CANT_CREATE); + FAIL_IF(!INSTANCE_VALIDATE(import[0]), "Invalid import target " + it.first, ERR_CANT_CREATE); FAIL_IF(import[1].get_type() != Variant::STRING, "Invalid import method " + it.first, ERR_CANT_CREATE); godot_wasm::ContextFuncImport* context = (godot_wasm::ContextFuncImport*)&it.second; context->target = import[0].operator Object*()->get_instance_id();