Skip to content

Commit

Permalink
Godot 3 compatibility with target IDs
Browse files Browse the repository at this point in the history
Fix defines
Update test project
  • Loading branch information
ashtonmeuser committed Jun 13, 2024
1 parent 5669511 commit 6050d35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions examples/wasm-test/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://utils/GodotWasmTestSuite.gd"
}, {
"base": "Object",
"class": "ImportTarget",
"language": "GDScript",
"path": "res://utils/ImportTarget.gd"
}, {
"base": "Node",
"class": "TestRunner",
"language": "GDScript",
Expand Down Expand Up @@ -41,6 +46,7 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"GodotWasmTestSuite": "",
"ImportTarget": "",
"TestRunner": "",
"TestSuite": "",
"Utils": "",
Expand Down
7 changes: 4 additions & 3 deletions src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 INSTANCE_VALIDATE(id) ObjectDB::instance_validate(id)
#define REGISTRATION_METHOD _bind_methods
#define RANDOM_BYTES(n) Crypto::create()->generate_random_bytes(n)
#else
Expand All @@ -34,8 +34,9 @@ Useful for minimizing changes to implementation files between targets e.g. GDExt
#define ERR_PARAMETER_RANGE_ERROR GODOT_ERR_PARAMETER_RANGE_ERROR
#define PRINT(message) Godot::print(String(message))
#define PRINT_ERROR(message) Godot::print_error("Godot Wasm: " + String(message), __func__, __FILE__, __LINE__)
#define INSTANCE_FROM_ID(id) ObjectDB::get_instance(id)
#define INSTANCE_VALIDATE(id) UtilityFunctions::is_instance_valid(id)
#define ObjectID int64_t
#define INSTANCE_FROM_ID(id) godot::core_1_2_api->godot_instance_from_id(id) == nullptr ? nullptr : godot::detail::get_wrapper<Object>(godot::core_1_2_api->godot_instance_from_id(id))
#define INSTANCE_VALIDATE(id) godot::core_1_1_api->godot_is_instance_valid((godot_object*)id)
#define GDCLASS GODOT_CLASS
#define REGISTRATION_METHOD _register_methods
#define RANDOM_BYTES(n) Crypto::_new()->generate_random_bytes(n)
Expand Down
2 changes: 1 addition & 1 deletion src/godot-library.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef GODOT_MODULE

#include "godot-wasm.h"
#include "wasm.h"
#include "wasm-memory.h"

extern "C" void GDN_EXPORT wasm_gdnative_init(godot_gdnative_init_options *o) {
Expand Down

0 comments on commit 6050d35

Please sign in to comment.