js otxn_type

This commit is contained in:
Richard Holland
2024-05-09 11:15:18 +10:00
committed by RichardAH
parent f9137000e3
commit ec7d603bf9
3 changed files with 31 additions and 1 deletions

View File

@@ -108,6 +108,11 @@
extern WasmEdge_FunctionTypeContext* WasmFunctionType##F; \
extern WasmEdge_String WasmFunctionName##F;
#define DECLARE_JS_FUNCNARG(R, F, ...)\
extern JSValue JSFunction##F(JSContext *ctx, JSValueConst this_val,\
int argc, JSValueConst *argv);\
const int JSFunctionParamCount##F = 0;
#define DECLARE_JS_FUNCTION(R, F, ...)\
extern JSValue JSFunction##F(JSContext *ctx, JSValueConst this_val,\
int argc, JSValueConst *argv);\
@@ -191,6 +196,13 @@
#define VAR_JSASSIGN(T, V) T& V = argv[_stack++]
#define DEFINE_JS_FUNCNARG(R, F, ...)\
JSValue hook_api::JSFunction##F(JSContext *ctx, JSValueConst this_val,\
int argc, JSValueConst *argv)\
{
#define DEFINE_JS_FUNCTION(R, F, ...)\
JSValue hook_api::JSFunction##F(JSContext *ctx, JSValueConst this_val,\
int argc, JSValueConst *argv)\

View File

@@ -455,6 +455,9 @@ DECLARE_JS_FUNCTION(
flags);
DECLARE_WASM_FUNCNARG(int64_t, otxn_type);
DECLARE_JS_FUNCNARG(int64_t, otxn_type);
DECLARE_WASM_FUNCTION(int64_t, otxn_slot, uint32_t slot_no);
DECLARE_WASM_FUNCTION(
int64_t,
@@ -1053,8 +1056,8 @@ public:
ADD_JS_FUNCTION(otxn_field, ctx);
*/
ADD_JS_FUNCTION(otxn_id, ctx);
/*
ADD_JS_FUNCTION(otxn_type, ctx);
/*
ADD_JS_FUNCTION(otxn_slot, ctx);
ADD_JS_FUNCTION(otxn_param, ctx);

View File

@@ -2528,6 +2528,21 @@ DEFINE_WASM_FUNCNARG(int64_t, otxn_type)
WASM_HOOK_TEARDOWN();
}
DEFINE_JS_FUNCNARG(
JSValue,
otxn_type)
{
JS_HOOK_SETUP();
if (hookCtx.emitFailure)
returnJS(safe_cast<TxType>(
hookCtx.emitFailure->getFieldU16(sfTransactionType)));
returnJS(applyCtx.tx.getTxnType());
JS_HOOK_TEARDOWN();
}
DEFINE_WASM_FUNCTION(int64_t, otxn_slot, uint32_t slot_into)
{
WASM_HOOK_SETUP(); // populates memory_ctx, memory, memory_length, applyCtx,