Skip to content

Commit

Permalink
Revert remove is_instance_valid()
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtonmeuser committed Sep 17, 2024
1 parent aee9f13 commit 94cf94a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ 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
#define PRINT(message) UtilityFunctions::print(String(message))
#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<Crypto> c;c.instantiate();return c->generate_random_bytes(n);}()
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 94cf94a

Please sign in to comment.