Skip to content

Commit

Permalink
Add getContext in null_plugin (envoyproxy#447) (envoyproxy#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
gargnupur authored Mar 4, 2020
1 parent c90c744 commit 759e9e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions source/extensions/common/wasm/null/null_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ Plugin::RootContext* nullVmGetRoot(absl::string_view root_id) {
return static_cast<NullPlugin*>(null_vm->plugin_.get())->getRoot(root_id);
}

Plugin::Context* nullVmGetContext(uint32_t context_id) {
auto null_vm = static_cast<NullVm*>(current_context_->wasmVm());
return static_cast<NullPlugin*>(null_vm->plugin_.get())->getContext(context_id);
}

} // namespace Null
} // namespace Wasm
} // namespace Common
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/common/wasm/null/null_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class NullPlugin : public NullVmPlugin {
void onDelete(uint64_t context_id);

Plugin::RootContext* getRoot(absl::string_view root_id);
Plugin::Context* getContext(uint64_t context_id);

private:
Plugin::Context* ensureContext(uint64_t context_id, uint64_t root_context_id);
Plugin::RootContext* ensureRootContext(uint64_t context_id);
Plugin::Context* getContext(uint64_t context_id);
Plugin::RootContext* getRootContext(uint64_t context_id);
Plugin::ContextBase* getContextBase(uint64_t context_id);

Expand Down
5 changes: 4 additions & 1 deletion source/extensions/common/wasm/null/wasm_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ extern thread_local Envoy::Extensions::Common::Wasm::Context* current_context_;
namespace Null {
namespace Plugin {
class RootContext;
}
class Context;
} // namespace Plugin

Plugin::RootContext* nullVmGetRoot(absl::string_view root_id);
Plugin::Context* nullVmGetContext(uint32_t context_id);

namespace Plugin {

Expand Down Expand Up @@ -255,6 +257,7 @@ inline WasmResult proxy_call_foreign_function(const char* function_name, size_t
#undef WR

inline RootContext* getRoot(StringView root_id) { return nullVmGetRoot(root_id); }
inline Plugin::Context* getContext(uint32_t context_id) { return nullVmGetContext(context_id); }

} // namespace Plugin
} // namespace Null
Expand Down

0 comments on commit 759e9e1

Please sign in to comment.