Wasmtime
component/types/module.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_COMPONENT_TYPES_MODULE_HH
6#define WASMTIME_COMPONENT_TYPES_MODULE_HH
7
8#include <wasmtime/conf.h>
9
10#ifdef WASMTIME_FEATURE_COMPONENT_MODEL
11
12#include <memory>
13#include <optional>
14#include <string>
15#include <wasm.h>
17#include <wasmtime/engine.hh>
18#include <wasmtime/helpers.hh>
22
23namespace wasmtime {
24namespace component {
25
30 WASMTIME_CLONE_WRAPPER(ModuleType, wasmtime_module_type)
31
32
33 size_t import_count(const Engine &engine) const {
34 return wasmtime_module_type_import_count(ptr.get(), engine.capi());
35 }
36
38 std::optional<ImportType> import_nth(const Engine &engine, size_t nth) const {
39 auto ret = wasmtime_module_type_import_nth(ptr.get(), engine.capi(), nth);
40 if (ret)
41 return ImportType(ret);
42 return std::nullopt;
43 }
44
46 size_t export_count(const Engine &engine) const {
47 return wasmtime_module_type_export_count(ptr.get(), engine.capi());
48 }
49
51 std::optional<ExportType> export_nth(const Engine &engine, size_t nth) const {
52 auto ret = wasmtime_module_type_export_nth(ptr.get(), engine.capi(), nth);
53 if (ret)
54 return ExportType(ret);
55 return std::nullopt;
56 }
57};
58
59} // namespace component
60} // namespace wasmtime
61
62#endif // WASMTIME_FEATURE_COMPONENT_MODEL
63
64#endif // WASMTIME_COMPONENT_TYPES_MODULE_HH
Global compilation state in Wasmtime.
Definition: engine.hh:22
Type information about a WebAssembly export.
Definition: export.hh:17
Type information about a WebAssembly import.
Definition: import.hh:17
Represents the type of a module.
Definition: component/types/module.hh:29
WASM_API_EXTERN size_t wasmtime_module_type_export_count(const wasmtime_module_type_t *ty, const wasm_engine_t *engine)
Returns the number of exports of a module type.
WASM_API_EXTERN wasm_importtype_t * wasmtime_module_type_import_nth(const wasmtime_module_type_t *ty, const wasm_engine_t *engine, size_t nth)
Retrieves the nth import.
WASM_API_EXTERN size_t wasmtime_module_type_import_count(const wasmtime_module_type_t *ty, const wasm_engine_t *engine)
Returns the number of imports of a module type.
WASM_API_EXTERN wasm_exporttype_t * wasmtime_module_type_export_nth(const wasmtime_module_type_t *ty, const wasm_engine_t *engine, size_t nth)
Retrieves the nth export.
Build-time defines for how the C API was built.