Skip to content

Commit

Permalink
fix(cpp): update to const pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
zshipko committed Jan 4, 2023
1 parent 6ccdd1f commit b72bf8d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cpp/extism.hpp
Expand Up @@ -205,6 +205,8 @@ class Function {
this->func = std::shared_ptr<ExtismFunction>(ptr, extism_function_free);
}

Function(const Function &f) { this->func = f.func; }

ExtismFunction *get() { return this->func.get(); }
};

Expand All @@ -218,7 +220,7 @@ class Plugin {
ExtismSize length, bool with_wasi = false,
std::vector<Function> functions = std::vector<Function>())
: functions(functions) {
std::vector<ExtismFunction *> ptrs;
std::vector<const ExtismFunction *> ptrs;
for (auto i : this->functions) {
ptrs.push_back(i.get());
}
Expand All @@ -234,7 +236,7 @@ class Plugin {
#ifndef EXTISM_NO_JSON
Plugin(std::shared_ptr<ExtismContext> ctx, const Manifest &manifest,
bool with_wasi = false, std::vector<Function> functions = {}) {
std::vector<ExtismFunction *> ptrs;
std::vector<const ExtismFunction *> ptrs;
for (auto i : this->functions) {
ptrs.push_back(i.get());
}
Expand Down Expand Up @@ -263,7 +265,7 @@ class Plugin {
void update(const uint8_t *wasm, size_t length, bool with_wasi = false,
std::vector<Function> functions = {}) {
this->functions = functions;
std::vector<ExtismFunction *> ptrs;
std::vector<const ExtismFunction *> ptrs;
for (auto i : this->functions) {
ptrs.push_back(i.get());
}
Expand All @@ -279,7 +281,7 @@ class Plugin {
void update(const Manifest &manifest, bool with_wasi = false,
std::vector<Function> functions = {}) {
this->functions = functions;
std::vector<ExtismFunction *> ptrs;
std::vector<const ExtismFunction *> ptrs;
for (auto i : this->functions) {
ptrs.push_back(i.get());
}
Expand Down

0 comments on commit b72bf8d

Please sign in to comment.