Skip to content

Commit a374efd

Browse files
authored
Feat: Add additional virtual keywords to wasm base. (#444)
* Feat: Add additional virtual keywords to wasm base. Signed-off-by: Rachel Green <rachgreen@google.com>
1 parent 74f8572 commit a374efd

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

‎include/proxy-wasm/context.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ class ContextBase : public RootInterface,
150150
const std::shared_ptr<PluginHandleBase> &plugin_handle); // Stream context.
151151
virtual ~ContextBase();
152152

153-
WasmBase *wasm() const { return wasm_; }
153+
virtual WasmBase *wasm() const { return wasm_; }
154154
uint32_t id() const { return id_; }
155155
// The VM Context used for calling "malloc" has an id_ == 0.
156156
bool isVmContext() const { return id_ == 0; }
157157
// Root Contexts have the VM Context as a parent.
158158
bool isRootContext() const { return parent_context_id_ == 0; }
159-
ContextBase *parent_context() const { return parent_context_; }
160-
ContextBase *root_context() const {
159+
virtual ContextBase *parent_context() const { return parent_context_; }
160+
virtual ContextBase *root_context() const {
161161
const ContextBase *previous = this;
162162
ContextBase *parent = parent_context_;
163163
while (parent != previous) {
@@ -170,7 +170,7 @@ class ContextBase : public RootInterface,
170170
std::string_view log_prefix() const {
171171
return isRootContext() ? root_log_prefix_ : plugin_->log_prefix();
172172
}
173-
WasmVm *wasmVm() const;
173+
virtual WasmVm *wasmVm() const;
174174

175175
// Called before deleting the context.
176176
virtual void destroy();

‎include/proxy-wasm/wasm.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ class WasmBase : public std::enable_shared_from_this<WasmBase> {
5454
WasmBase(const std::shared_ptr<WasmHandleBase> &base_wasm_handle, const WasmVmFactory &factory);
5555
virtual ~WasmBase();
5656

57-
bool load(const std::string &code, bool allow_precompiled = false);
58-
bool initialize();
59-
void startVm(ContextBase *root_context);
60-
bool configure(ContextBase *root_context, std::shared_ptr<PluginBase> plugin);
57+
virtual bool load(const std::string &code, bool allow_precompiled = false);
58+
virtual bool initialize();
59+
virtual void startVm(ContextBase *root_context);
60+
virtual bool configure(ContextBase *root_context, std::shared_ptr<PluginBase> plugin);
6161
// Returns the root ContextBase or nullptr if onStart returns false.
62-
ContextBase *start(const std::shared_ptr<PluginBase> &plugin);
62+
virtual ContextBase *start(const std::shared_ptr<PluginBase> &plugin);
6363

6464
std::string_view vm_id() const { return vm_id_; }
6565
std::string_view vm_key() const { return vm_key_; }
6666
WasmVm *wasm_vm() const { return wasm_vm_.get(); }
67-
ContextBase *vm_context() const { return vm_context_.get(); }
68-
ContextBase *getRootContext(const std::shared_ptr<PluginBase> &plugin, bool allow_closed);
67+
virtual ContextBase *vm_context() const { return vm_context_.get(); }
68+
virtual ContextBase *getRootContext(const std::shared_ptr<PluginBase> &plugin, bool allow_closed);
6969
ContextBase *getContext(uint32_t id) {
7070
auto it = contexts_.find(id);
7171
if (it != contexts_.end())
@@ -321,14 +321,14 @@ using WasmHandleCloneFactory =
321321
class WasmHandleBase : public std::enable_shared_from_this<WasmHandleBase> {
322322
public:
323323
explicit WasmHandleBase(std::shared_ptr<WasmBase> wasm_base) : wasm_base_(wasm_base) {}
324-
~WasmHandleBase() {
324+
virtual ~WasmHandleBase() {
325325
if (wasm_base_) {
326326
wasm_base_->startShutdown();
327327
}
328328
}
329329

330-
bool canary(const std::shared_ptr<PluginBase> &plugin,
331-
const WasmHandleCloneFactory &clone_factory);
330+
virtual bool canary(const std::shared_ptr<PluginBase> &plugin,
331+
const WasmHandleCloneFactory &clone_factory);
332332

333333
void kill() { wasm_base_ = nullptr; }
334334

@@ -356,7 +356,7 @@ class PluginHandleBase : public std::enable_shared_from_this<PluginHandleBase> {
356356
explicit PluginHandleBase(std::shared_ptr<WasmHandleBase> wasm_handle,
357357
std::shared_ptr<PluginBase> plugin)
358358
: plugin_(plugin), wasm_handle_(wasm_handle) {}
359-
~PluginHandleBase() {
359+
virtual ~PluginHandleBase() {
360360
if (wasm_handle_) {
361361
wasm_handle_->wasm()->startShutdown(plugin_->key());
362362
}

0 commit comments

Comments
 (0)