-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
544 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <utility> | ||
|
||
#ifndef defer | ||
struct deferred_invoker {}; | ||
|
||
template<typename F> | ||
struct deferred { | ||
F _defer_fn; | ||
|
||
~deferred() { | ||
_defer_fn(); | ||
} | ||
}; | ||
|
||
template<typename F> | ||
deferred<F> operator*(deferred_invoker, F&& f) { | ||
return {std::forward<F>(f)}; | ||
} | ||
|
||
/** | ||
* USAGE: defer { statements; } | ||
*/ | ||
# define defer auto _deferred##__LINE__ = deferred_invoker{}* [&]() | ||
#endif // defer | ||
|
||
template<typename... Ts> | ||
struct overloaded : Ts... { | ||
using Ts::operator()...; | ||
}; | ||
template<typename... Ts> | ||
overloaded(Ts...) -> overloaded<Ts...>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "ecsact/wasm/detail/globals.hh" | ||
|
||
namespace { | ||
wasm_engine_t* _engine = nullptr; | ||
} | ||
|
||
auto ecsact::wasm::detail::engine() -> wasm_engine_t* { | ||
if(!_engine) { | ||
_engine = wasm_engine_new(); | ||
} | ||
return _engine; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include <wasm.h> | ||
|
||
namespace ecsact::wasm::detail { | ||
auto engine() -> wasm_engine_t*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <string_view> | ||
#include <functional> | ||
#include <map> | ||
#include <wasm.h> | ||
#include "ecsact/wasm/detail/minst/minst.hh" | ||
|
||
namespace ecsactsi_wasm::detail { | ||
namespace ecsact::wasm::detail { | ||
using allowed_guest_imports_t = std::unordered_map< | ||
std::string, // Function name | ||
std::function<wasm_func_t*(wasm_store_t*)>>; | ||
std::string_view, // Function name | ||
std::function<minst_import_resolve_func()>>; | ||
|
||
using allowed_guest_modules_t = std::unordered_map< | ||
std::string, // Module name | ||
std::string_view, // Module name | ||
allowed_guest_imports_t>; | ||
} // namespace ecsactsi_wasm::detail |
Oops, something went wrong.