Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use new indexed fields api #68

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ module(

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "ecsact_runtime", version = "0.6.9")
bazel_dep(name = "rules_ecsact", version = "0.5.1")
bazel_dep(name = "ecsact_runtime", version = "0.7.0")
bazel_dep(name = "rules_ecsact", version = "0.5.8")
bazel_dep(name = "docopt.cpp", version = "0.6.2")
bazel_dep(name = "magic_enum", version = "0.9.3")
bazel_dep(name = "rules_wasmer", version = "0.1.1")
bazel_dep(name = "ecsact_cli", version = "0.3.4")
bazel_dep(name = "ecsact_cli", version = "0.3.19")
bazel_dep(name = "platforms", version = "0.0.10")

bazel_dep(name = "toolchains_llvm", version = "1.0.0", dev_dependency = True)
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)

bazel_dep(name = "platforms", version = "0.0.10")

git_override(
module_name = "hedron_compile_commands",
commit = "204aa593e002cbd177d30f11f54cff3559110bb9",
Expand Down
20 changes: 12 additions & 8 deletions ecsact/wasm/detail/guest_imports/env.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ const auto guest_env_module_imports = allowed_guest_imports_t{
"ecsact_system_execution_context_get",
[]() -> minst_import_resolve_func {
return {
wasm_functype_new_3_0(
wasm_functype_new_4_0(
wasm_valtype_new(WASM_I32), // context
wasm_valtype_new(WASM_I32), // component_id
wasm_valtype_new(WASM_I32) // out_component_data
wasm_valtype_new(WASM_I32), // out_component_data
wasm_valtype_new(WASM_I32) // indexed_fields
),
&wasm_ecsact_system_execution_context_get,
};
Expand All @@ -61,10 +62,11 @@ const auto guest_env_module_imports = allowed_guest_imports_t{
"ecsact_system_execution_context_update",
[]() -> minst_import_resolve_func {
return {
wasm_functype_new_3_0(
wasm_functype_new_4_0(
wasm_valtype_new(WASM_I32), // context
wasm_valtype_new(WASM_I32), // component_id
wasm_valtype_new(WASM_I32) // component_data
wasm_valtype_new(WASM_I32), // component_data
wasm_valtype_new(WASM_I32) // indexed_fields
),
&wasm_ecsact_system_execution_context_update,
};
Expand All @@ -74,9 +76,10 @@ const auto guest_env_module_imports = allowed_guest_imports_t{
"ecsact_system_execution_context_has",
[]() -> minst_import_resolve_func {
return {
wasm_functype_new_2_0(
wasm_functype_new_3_0(
wasm_valtype_new(WASM_I32), // context
wasm_valtype_new(WASM_I32) // component_id
wasm_valtype_new(WASM_I32), // component_id
wasm_valtype_new(WASM_I32) // indexed_fields
),
&wasm_ecsact_system_execution_context_has,
};
Expand Down Expand Up @@ -113,9 +116,10 @@ const auto guest_env_module_imports = allowed_guest_imports_t{
"ecsact_system_execution_context_remove",
[]() -> minst_import_resolve_func {
return {
wasm_functype_new_2_0(
wasm_functype_new_3_0(
wasm_valtype_new(WASM_I32), // context
wasm_valtype_new(WASM_I32) // component_id
wasm_valtype_new(WASM_I32), // component_id
wasm_valtype_new(WASM_I32) // indexed_fields
),
&wasm_ecsact_system_execution_context_remove,
};
Expand Down
1 change: 1 addition & 0 deletions ecsact/wasm/detail/wasi_fs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstdint>
#include <cstdio>
#include <string_view>
#include <string>
#include "ecsact/wasm/detail/wasi.hh"

namespace ecsact::wasm::detail::wasi::fs {
Expand Down
22 changes: 16 additions & 6 deletions ecsact/wasm/detail/wasm_ecsact_system_execution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ wasm_trap_t* wasm_ecsact_system_execution_context_remove(
) {
debug_trace_method("ecsact_system_execution_context_remove");

auto ctx = get_execution_context(args->data[0]);
auto memory = get_execution_context_memory(args->data[0]);

ecsact_system_execution_context_remove(
get_execution_context(args->data[0]),
ecsact_id_from_wasm_i32<ecsact_component_like_id>(args->data[1])
ctx,
ecsact_id_from_wasm_i32<ecsact_component_like_id>(args->data[1]),
get_void_ptr(args->data[2], memory)
);
return nullptr;
}
Expand All @@ -130,7 +134,8 @@ wasm_trap_t* wasm_ecsact_system_execution_context_get(
ecsact_system_execution_context_get(
ctx,
ecsact_id_from_wasm_i32<ecsact_component_like_id>(args->data[1]),
get_void_ptr(args->data[2], memory)
get_void_ptr(args->data[2], memory),
get_void_ptr(args->data[3], memory)
);

return nullptr;
Expand All @@ -148,7 +153,8 @@ wasm_trap_t* wasm_ecsact_system_execution_context_update(
ecsact_system_execution_context_update(
ctx,
ecsact_id_from_wasm_i32<ecsact_component_like_id>(args->data[1]),
get_const_void_ptr(args->data[2], memory)
get_const_void_ptr(args->data[2], memory),
get_void_ptr(args->data[3], memory)
);

return nullptr;
Expand All @@ -160,9 +166,13 @@ wasm_trap_t* wasm_ecsact_system_execution_context_has(
) {
debug_trace_method("ecsact_system_execution_context_has");

auto ctx = get_execution_context(args->data[0]);
auto memory = get_execution_context_memory(args->data[0]);

bool has_component = ecsact_system_execution_context_has(
get_execution_context(args->data[0]),
ecsact_id_from_wasm_i32<ecsact_component_like_id>(args->data[1])
ctx,
ecsact_id_from_wasm_i32<ecsact_component_like_id>(args->data[1]),
get_void_ptr(args->data[2], memory)
);

results->data[0].kind = WASM_I32;
Expand Down
3 changes: 3 additions & 0 deletions test/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import %workspace%/../bazel/common.bazelrc

# emsdk needs 'py' in PATH
common:windows --action_env=PATH

common [email protected]//:use_std_fs
common [email protected]//:use_std_fs

Expand Down
12 changes: 6 additions & 6 deletions test/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module(name = "ecsact_si_wasm_test")

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "ecsact_runtime", version = "0.6.1")
bazel_dep(name = "ecsact_runtime", version = "0.7.0")
bazel_dep(name = "rules_wasmer", version = "0.1.1")
bazel_dep(name = "ecsact_rt_entt", version = "0.3.1")
bazel_dep(name = "ecsact_lang_cpp", version = "0.4.1")
bazel_dep(name = "ecsact_interpret", version = "0.6.0")
bazel_dep(name = "ecsact_parse", version = "0.4.0")
bazel_dep(name = "ecsact_codegen", version = "0.2.0")
bazel_dep(name = "ecsact_rt_entt", version = "0.3.8")
bazel_dep(name = "ecsact_lang_cpp", version = "0.4.9")
bazel_dep(name = "ecsact_parse", version = "0.5.4")
bazel_dep(name = "ecsact_codegen", version = "0.4.3")
bazel_dep(name = "ecsact_interpret", version = "0.6.6")
bazel_dep(name = "magic_enum", version = "0.9.3")
bazel_dep(name = "boost.mp11", version = "1.83.0.bzl.1")
bazel_dep(name = "boost.dll", version = "1.83.0.bzl.2")
Expand Down