Skip to content

Commit

Permalink
Merge pull request #699 from wasmx/capi-simplify
Browse files Browse the repository at this point in the history
capi: Random minor simplifications
  • Loading branch information
gumb0 authored Jan 27, 2021
2 parents 48c2b50 + 5f14d14 commit c38917f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/fizzy/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,18 @@ inline fizzy::ValType unwrap(FizzyValueType value_type) noexcept
return static_cast<fizzy::ValType>(value_type);
}

inline FizzyFunctionType wrap(const fizzy::FuncType& type) noexcept
{
return {(type.outputs.empty() ? FizzyValueTypeVoid : wrap(type.outputs[0])),
(type.inputs.empty() ? nullptr : wrap(&type.inputs[0])), type.inputs.size()};
}

inline FizzyFunctionType wrap(fizzy::span<const fizzy::ValType> input_types,
fizzy::span<const fizzy::ValType> output_types) noexcept
{
return {(output_types.empty() ? FizzyValueTypeVoid : wrap(output_types[0])),
(input_types.empty() ? nullptr : wrap(&input_types[0])), input_types.size()};
}

inline FizzyFunctionType wrap(const fizzy::FuncType& type) noexcept
{
return wrap(type.inputs, type.outputs);
}

inline FizzyValue wrap(fizzy::Value value) noexcept
{
return fizzy::bit_cast<FizzyValue>(value);
Expand Down Expand Up @@ -162,9 +161,8 @@ inline std::vector<fizzy::ExternalFunction> unwrap(
inline fizzy::ImportedFunction unwrap(const FizzyImportedFunction& c_imported_func)
{
fizzy::ImportedFunction imported_func;
imported_func.module =
c_imported_func.module ? std::string{c_imported_func.module} : std::string{};
imported_func.name = c_imported_func.name ? std::string{c_imported_func.name} : std::string{};
imported_func.module = c_imported_func.module;
imported_func.name = c_imported_func.name;

const auto& c_type = c_imported_func.external_function.type;
imported_func.inputs.resize(c_type.inputs_size);
Expand Down

0 comments on commit c38917f

Please sign in to comment.