Skip to content

Commit 2e1cfac

Browse files
authored
add getContext function to the Null Vm (proxy-wasm#14)
* add getContext function to the Null Vm * format
1 parent c842ff0 commit 2e1cfac

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

include/proxy-wasm/null_plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ class NullPlugin : public NullVmPlugin {
107107
void onDelete(uint64_t context_id);
108108

109109
null_plugin::RootContext *getRoot(string_view root_id);
110+
null_plugin::Context *getContext(uint64_t context_id);
110111

111112
void error(string_view message) { wasm_vm_->error(message); }
112113

113114
private:
114115
null_plugin::Context *ensureContext(uint64_t context_id, uint64_t root_context_id);
115116
null_plugin::RootContext *ensureRootContext(uint64_t context_id);
116-
null_plugin::Context *getContext(uint64_t context_id);
117117
null_plugin::RootContext *getRootContext(uint64_t context_id);
118118
null_plugin::ContextBase *getContextBase(uint64_t context_id);
119119

include/proxy-wasm/wasm_api_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
namespace proxy_wasm {
2121
namespace null_plugin {
2222
class RootContext;
23+
class Context;
2324
} // namespace null_plugin
2425

2526
null_plugin::RootContext *nullVmGetRoot(string_view root_id);
27+
null_plugin::Context *nullVmGetContext(uint32_t context_id);
2628

2729
namespace null_plugin {
2830

@@ -263,6 +265,7 @@ inline WasmResult proxy_call_foreign_function(const char *function_name, size_t
263265
#undef WR
264266

265267
inline RootContext *getRoot(string_view root_id) { return nullVmGetRoot(root_id); }
268+
inline Context *getContext(uint32_t context_id) { return nullVmGetContext(context_id); }
266269

267270
} // namespace null_plugin
268271
} // namespace proxy_wasm

src/null/null_plugin.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,9 @@ null_plugin::RootContext *nullVmGetRoot(string_view root_id) {
459459
return static_cast<NullPlugin *>(null_vm->plugin_.get())->getRoot(root_id);
460460
}
461461

462+
null_plugin::Context *nullVmGetContext(uint32_t context_id) {
463+
auto null_vm = static_cast<NullVm *>(current_context_->wasmVm());
464+
return static_cast<NullPlugin *>(null_vm->plugin_.get())->getContext(context_id);
465+
}
466+
462467
} // namespace proxy_wasm

0 commit comments

Comments
 (0)