|
| 1 | + |
| 2 | +// Copyright 2016-2019 Envoy Project Authors |
| 3 | +// Copyright 2020 Google LLC |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +// you may not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | + |
| 17 | +#include "src/common/types.h" |
| 18 | +#include "wasmtime/include/wasm.h" |
| 19 | +#include "wasmtime/include/wasmtime.h" |
| 20 | + |
| 21 | +namespace proxy_wasm { |
| 22 | +namespace wasmtime { |
| 23 | + |
| 24 | +using WasmEnginePtr = common::CSmartPtr<wasm_engine_t, wasm_engine_delete>; |
| 25 | +using WasmFuncPtr = common::CSmartPtr<wasm_func_t, wasm_func_delete>; |
| 26 | +using WasmStorePtr = common::CSmartPtr<wasm_store_t, wasm_store_delete>; |
| 27 | +using WasmModulePtr = common::CSmartPtr<wasm_module_t, wasm_module_delete>; |
| 28 | +using WasmSharedModulePtr = common::CSmartPtr<wasm_shared_module_t, wasm_shared_module_delete>; |
| 29 | +using WasmMemoryPtr = common::CSmartPtr<wasm_memory_t, wasm_memory_delete>; |
| 30 | +using WasmTablePtr = common::CSmartPtr<wasm_table_t, wasm_table_delete>; |
| 31 | +using WasmInstancePtr = common::CSmartPtr<wasm_instance_t, wasm_instance_delete>; |
| 32 | +using WasmFunctypePtr = common::CSmartPtr<wasm_functype_t, wasm_functype_delete>; |
| 33 | +using WasmTrapPtr = common::CSmartPtr<wasm_trap_t, wasm_trap_delete>; |
| 34 | +using WasmExternPtr = common::CSmartPtr<wasm_extern_t, wasm_extern_delete>; |
| 35 | + |
| 36 | +using WasmByteVec = common::DeleterType<wasm_byte_vec_t, wasm_byte_vec_delete>; |
| 37 | +using WasmImporttypeVec = common::DeleterType<wasm_importtype_vec_t, wasm_importtype_vec_delete>; |
| 38 | +using WasmExportTypeVec = common::DeleterType<wasm_exporttype_vec_t, wasm_exporttype_vec_delete>; |
| 39 | +using WasmExternVec = common::DeleterType<wasm_extern_vec_t, wasm_extern_vec_delete>; |
| 40 | +using WasmValtypeVec = common::DeleterType<wasm_valtype_vec_t, wasm_valtype_vec_delete>; |
| 41 | + |
| 42 | +class WasmExternPtrVector { |
| 43 | +public: |
| 44 | + ~WasmExternPtrVector() { |
| 45 | + // TODO: come back later |
| 46 | + for (auto it = vector.begin(); it < vector.end(); it++) { |
| 47 | + // wasm_extern_delete(*it); |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + wasm_extern_t **data() { return vector.data(); } |
| 52 | + void push_back(wasm_extern_t *item) { vector.push_back(item); } |
| 53 | + size_t size() { return vector.size(); } |
| 54 | + |
| 55 | +private: |
| 56 | + std::vector<wasm_extern_t *> vector; |
| 57 | +}; |
| 58 | + |
| 59 | +} // namespace wasmtime |
| 60 | + |
| 61 | +} // namespace proxy_wasm |
0 commit comments