feat: add a histrical wit-bindgen
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef _smw_abort_h
|
||||
#define _smw_abort_h
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace smw {
|
||||
|
||||
/**
|
||||
* Print the given error message and abort.
|
||||
*/
|
||||
void abort(const char* msg);
|
||||
void abort(JSContext *cx, const char* msg);
|
||||
|
||||
}
|
||||
|
||||
#endif // _smw_abort_h
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _smw_bindgen_h
|
||||
#define _smw_bindgen_h
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace smw {
|
||||
|
||||
void init_operands(JSContext* cx);
|
||||
|
||||
}
|
||||
|
||||
#endif // _smw_bindgen_h
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _smw_cx_h
|
||||
#define _smw_cx_h
|
||||
|
||||
struct JSContext;
|
||||
class JSObject;
|
||||
|
||||
namespace smw {
|
||||
|
||||
void init_js_context(JSContext* cx);
|
||||
JSContext* get_js_context();
|
||||
|
||||
void init_user_module(JSContext* cx, JSObject* user_module);
|
||||
JSObject* get_user_module();
|
||||
|
||||
}
|
||||
|
||||
#endif // _smw_cx_h
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef _smw_dump_h
|
||||
#define _smw_dump_h
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winvalid-offsetof"
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Value.h"
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
namespace smw {
|
||||
|
||||
/**
|
||||
* Dump a human-readable representation of the given JS value to the given file.
|
||||
*/
|
||||
bool dump_value(JSContext *cx, JS::HandleValue val, FILE* fp);
|
||||
|
||||
/**
|
||||
* Dump a human-readable representation of the given JS exception stack to the
|
||||
* given file.
|
||||
*/
|
||||
bool dump_stack(JSContext *cx, JS::HandleObject stack, FILE* fp);
|
||||
|
||||
}
|
||||
|
||||
#endif // _smw_dump_h
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef _smw_logging_h
|
||||
#define _smw_logging_h
|
||||
|
||||
#if LOGGING==1
|
||||
|
||||
#include <stdio.h>
|
||||
#define SMW_LOG(msg, ...) fprintf(stderr, msg, ##__VA_ARGS__)
|
||||
|
||||
#else // LOGGING==1
|
||||
|
||||
#define SMW_LOG(msg, ...) do { } while(false)
|
||||
|
||||
#endif // LOGGING==1
|
||||
|
||||
#endif // _smw_logging_h
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _smw_wasm_h
|
||||
#define _smw_wasm_h
|
||||
|
||||
/**
|
||||
* An attribute for making a function exported from the final Wasm binary.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* WASM_EXPORT
|
||||
* int add(int a, int b) {
|
||||
* return a + b;
|
||||
* }
|
||||
*/
|
||||
#define WASM_EXPORT \
|
||||
__attribute__((visibility("default"))) \
|
||||
extern "C"
|
||||
|
||||
#endif // _smw_wasm_h
|
||||
Reference in New Issue
Block a user