feat: add a histrical wit-bindgen

This commit is contained in:
2023-01-01 00:25:48 +08:00
parent 01e8f5a959
commit aa50d63aec
419 changed files with 45283 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
#include <assert.h>
#include "smw/cx.h"
#include "jsapi.h"
namespace smw {
static JSContext* CONTEXT = nullptr;
void init_js_context(JSContext *cx) {
assert(!CONTEXT && "CONTEXT should only be initialized once");
CONTEXT = cx;
}
JSContext *get_js_context() {
assert(CONTEXT && "CONTEXT should be initialized");
return CONTEXT;
}
static JS::PersistentRooted<JSObject*> USER_MODULE;
void init_user_module(JSContext* cx, JSObject* user_module) {
assert(!USER_MODULE && "USER_MODULE should only be initialized once");
USER_MODULE.init(cx, user_module);
}
JSObject* get_user_module() {
assert(USER_MODULE && "USER_MODULE should be initialized");
return USER_MODULE;
}
} // namespace smw