static int l_ffi_layer_begin(knot_layer_t *ctx, void *module_param) { ctx->data = module_param; LAYER_FFI_CALL(ctx, "begin"); lua_pushlightuserdata(L, module_param); return l_ffi_call(L, 2); }
static int l_ffi_layer_fail(knot_layer_t *ctx, knot_pkt_t *pkt) { LAYER_FFI_CALL(ctx, "fail"); lua_pushlightuserdata(L, ctx->data); lua_pushlightuserdata(L, pkt); set_metatable(L, META_PKT); return l_ffi_call(L, 3); }
static int l_ffi_layer_finish(knot_layer_t *ctx) { struct kr_request *req = ctx->data; LAYER_FFI_CALL(ctx, finish); lua_pushlightuserdata(L, req); lua_pushlightuserdata(L, req->answer); return l_ffi_call(L, 3); }
static int l_ffi_layer_produce(knot_layer_t *ctx, knot_pkt_t *pkt) { if (ctx->state & (KNOT_STATE_FAIL)) { return ctx->state; /* Already failed or done, skip */ } LAYER_FFI_CALL(ctx, produce); lua_pushlightuserdata(L, ctx->data); lua_pushlightuserdata(L, pkt); return l_ffi_call(L, 3); }
static int l_ffi_layer_consume(knot_layer_t *ctx, knot_pkt_t *pkt) { if (ctx->state & KNOT_STATE_FAIL) { return ctx->state; /* Already failed, skip */ } LAYER_FFI_CALL(ctx, "consume"); lua_pushlightuserdata(L, ctx->data); lua_pushlightuserdata(L, pkt); set_metatable(L, META_PKT); return l_ffi_call(L, 3); }
static int l_ffi_layer_reset(knot_layer_t *ctx) { LAYER_FFI_CALL(ctx, "reset"); lua_pushlightuserdata(L, ctx->data); return l_ffi_call(L, 2); }