@@ -54,18 +54,34 @@ class WasmBase : public std::enable_shared_from_this<WasmBase> {
54
54
WasmBase (const std::shared_ptr<WasmHandleBase> &base_wasm_handle, const WasmVmFactory &factory);
55
55
virtual ~WasmBase ();
56
56
57
+ #ifdef PROXY_WASM_CPP_HOST_MORE_VIRTUAL_METHODS
58
+ virtual bool load (const std::string &code, bool allow_precompiled = false );
59
+ virtual bool initialize ();
60
+ virtual void startVm (ContextBase *root_context);
61
+ virtual bool configure (ContextBase *root_context, std::shared_ptr<PluginBase> plugin);
62
+ #else
57
63
bool load (const std::string &code, bool allow_precompiled = false );
58
64
bool initialize ();
59
65
void startVm (ContextBase *root_context);
60
66
bool configure (ContextBase *root_context, std::shared_ptr<PluginBase> plugin);
67
+ #endif
61
68
// Returns the root ContextBase or nullptr if onStart returns false.
69
+ #ifdef PROXY_WASM_CPP_HOST_MORE_VIRTUAL_METHODS
70
+ virtual ContextBase *start (const std::shared_ptr<PluginBase> &plugin);
71
+ #else
62
72
ContextBase *start (const std::shared_ptr<PluginBase> &plugin);
73
+ #endif
63
74
64
75
std::string_view vm_id () const { return vm_id_; }
65
76
std::string_view vm_key () const { return vm_key_; }
66
77
WasmVm *wasm_vm () const { return wasm_vm_.get (); }
78
+ #ifdef PROXY_WASM_CPP_HOST_MORE_VIRTUAL_METHODS
79
+ virtual ContextBase *vm_context () const { return vm_context_.get (); }
80
+ virtual ContextBase *getRootContext (const std::shared_ptr<PluginBase> &plugin, bool allow_closed);
81
+ #else
67
82
ContextBase *vm_context () const { return vm_context_.get (); }
68
83
ContextBase *getRootContext (const std::shared_ptr<PluginBase> &plugin, bool allow_closed);
84
+ #endif
69
85
ContextBase *getContext (uint32_t id) {
70
86
auto it = contexts_.find (id);
71
87
if (it != contexts_.end ())
@@ -321,14 +337,23 @@ using WasmHandleCloneFactory =
321
337
class WasmHandleBase : public std ::enable_shared_from_this<WasmHandleBase> {
322
338
public:
323
339
explicit WasmHandleBase (std::shared_ptr<WasmBase> wasm_base) : wasm_base_(wasm_base) {}
340
+ #ifdef PROXY_WASM_CPP_HOST_MORE_VIRTUAL_METHODS
341
+ virtual ~WasmHandleBase () {
342
+ #else
324
343
~WasmHandleBase () {
344
+ #endif
325
345
if (wasm_base_) {
326
346
wasm_base_->startShutdown ();
327
347
}
328
348
}
329
349
350
+ #ifdef PROXY_WASM_CPP_HOST_MORE_VIRTUAL_METHODS
351
+ virtual bool canary (const std::shared_ptr<PluginBase> &plugin,
352
+ const WasmHandleCloneFactory &clone_factory);
353
+ #else
330
354
bool canary (const std::shared_ptr<PluginBase> &plugin,
331
355
const WasmHandleCloneFactory &clone_factory);
356
+ #endif
332
357
333
358
void kill () { wasm_base_ = nullptr ; }
334
359
@@ -356,7 +381,11 @@ class PluginHandleBase : public std::enable_shared_from_this<PluginHandleBase> {
356
381
explicit PluginHandleBase (std::shared_ptr<WasmHandleBase> wasm_handle,
357
382
std::shared_ptr<PluginBase> plugin)
358
383
: plugin_(plugin), wasm_handle_(wasm_handle) {}
384
+ #ifdef PROXY_WASM_CPP_HOST_MORE_VIRTUAL_METHODS
385
+ virtual ~PluginHandleBase () {
386
+ #else
359
387
~PluginHandleBase () {
388
+ #endif
360
389
if (wasm_handle_) {
361
390
wasm_handle_->wasm ()->startShutdown (plugin_->key ());
362
391
}
0 commit comments