From 2ebc99bd9c34d95943420939bd43cb0e05919dc6 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Tue, 24 Nov 2020 14:42:35 +0100 Subject: [PATCH 1/2] capi: Simplify unwrap function for FizzyImportedFunction --- lib/fizzy/capi.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fizzy/capi.cpp b/lib/fizzy/capi.cpp index f2245f1a9..7112ce6a7 100644 --- a/lib/fizzy/capi.cpp +++ b/lib/fizzy/capi.cpp @@ -162,9 +162,8 @@ inline std::vector 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); From 5f14d1437f081acf3f5dbcc7f411c835a2a292e1 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Thu, 21 Jan 2021 13:26:04 +0100 Subject: [PATCH 2/2] capi: Simplify wrap(const fizzy::FuncType& type) implementation --- lib/fizzy/capi.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/fizzy/capi.cpp b/lib/fizzy/capi.cpp index 7112ce6a7..890d0c616 100644 --- a/lib/fizzy/capi.cpp +++ b/lib/fizzy/capi.cpp @@ -43,12 +43,6 @@ inline fizzy::ValType unwrap(FizzyValueType value_type) noexcept return static_cast(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 input_types, fizzy::span output_types) noexcept { @@ -56,6 +50,11 @@ inline FizzyFunctionType wrap(fizzy::span input_types, (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(value);