diff --git a/include/proxy-wasm/null_plugin.h b/include/proxy-wasm/null_plugin.h index 18a567054..ab1f5e3d1 100644 --- a/include/proxy-wasm/null_plugin.h +++ b/include/proxy-wasm/null_plugin.h @@ -107,13 +107,13 @@ class NullPlugin : public NullVmPlugin { void onDelete(uint64_t context_id); null_plugin::RootContext *getRoot(string_view root_id); + null_plugin::Context *getContext(uint64_t context_id); void error(string_view message) { wasm_vm_->error(message); } private: null_plugin::Context *ensureContext(uint64_t context_id, uint64_t root_context_id); null_plugin::RootContext *ensureRootContext(uint64_t context_id); - null_plugin::Context *getContext(uint64_t context_id); null_plugin::RootContext *getRootContext(uint64_t context_id); null_plugin::ContextBase *getContextBase(uint64_t context_id); diff --git a/include/proxy-wasm/wasm_api_impl.h b/include/proxy-wasm/wasm_api_impl.h index a0b72b1e1..95286a9e2 100644 --- a/include/proxy-wasm/wasm_api_impl.h +++ b/include/proxy-wasm/wasm_api_impl.h @@ -20,9 +20,11 @@ namespace proxy_wasm { namespace null_plugin { class RootContext; +class Context; } // namespace null_plugin null_plugin::RootContext *nullVmGetRoot(string_view root_id); +null_plugin::Context *nullVmGetContext(uint32_t context_id); namespace null_plugin { @@ -263,6 +265,7 @@ inline WasmResult proxy_call_foreign_function(const char *function_name, size_t #undef WR inline RootContext *getRoot(string_view root_id) { return nullVmGetRoot(root_id); } +inline Context *getContext(uint32_t context_id) { return nullVmGetContext(context_id); } } // namespace null_plugin } // namespace proxy_wasm diff --git a/src/null/null_plugin.cc b/src/null/null_plugin.cc index b232f4643..b394c8719 100644 --- a/src/null/null_plugin.cc +++ b/src/null/null_plugin.cc @@ -459,4 +459,9 @@ null_plugin::RootContext *nullVmGetRoot(string_view root_id) { return static_cast(null_vm->plugin_.get())->getRoot(root_id); } +null_plugin::Context *nullVmGetContext(uint32_t context_id) { + auto null_vm = static_cast(current_context_->wasmVm()); + return static_cast(null_vm->plugin_.get())->getContext(context_id); +} + } // namespace proxy_wasm