Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cppwinrt/cmd_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ namespace cppwinrt

bool exists(std::string_view const& name) const noexcept
{
return m_options.count(name);
return m_options.count(name) != 0;
}

auto const& values(std::string_view const& name) const noexcept
Expand Down
4 changes: 4 additions & 0 deletions cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ namespace cppwinrt
w.write("%.size(), put_abi(%)", param_name, param_name);
}
break;
case param_category::generic_type:
case param_category::object_type:
case param_category::string_type:
case param_category::struct_type:
default:
w.write("impl::bind_out(%)", param_name);
break;
Expand Down
12 changes: 12 additions & 0 deletions cppwinrt/type_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ namespace cppwinrt
case ConstantType::UInt32:
write_value(value.ValueUInt32());
break;
case ConstantType::Boolean:
case ConstantType::Char:
case ConstantType::Int8:
case ConstantType::UInt8:
case ConstantType::Int16:
case ConstantType::UInt16:
case ConstantType::Int64:
case ConstantType::UInt64:
case ConstantType::Float32:
case ConstantType::Float64:
case ConstantType::String:
case ConstantType::Class:
default:
throw std::invalid_argument("Unexpected constant type");
}
Expand Down
2 changes: 1 addition & 1 deletion strings/base_fast_forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ WINRT_EXPORT namespace winrt::impl
std::uint8_t Data4[8];
inline bool operator!=(guid const& right) const noexcept
{
return std::memcmp(this, &right, sizeof(guid));
return std::memcmp(this, &right, sizeof(guid)) != 0;
}
};

Expand Down
7 changes: 3 additions & 4 deletions strings/base_implements.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ WINRT_EXPORT namespace winrt
template <typename I, typename D>
impl::abi_t<I>* to_abi(impl::producer<D, I> const* from) noexcept
{
return impl::abi_cast<impl::abi_t<I>>(const_cast<impl::producer<D, I>*>(from));
return const_cast<impl::abi_t<I>*>(impl::abi_cast<impl::abi_t<I> const>(from));
}

template <typename I, typename D>
impl::abi_t<I>* to_abi(impl::producer_convert<D, I> const* from) noexcept
{
return impl::abi_cast<impl::abi_t<I>>(const_cast<impl::producer<D, default_interface<I>>*>(static_cast<impl::producer<D, default_interface<I>> const*>(from)));
return const_cast<impl::abi_t<I>*>(impl::abi_cast<impl::abi_t<I> const>(from));
}
}

Expand Down Expand Up @@ -1281,8 +1281,7 @@ WINRT_EXPORT namespace winrt::impl
static bool is_weak_ref(std::uintptr_t const value) noexcept
{
static_assert(is_weak_ref_source::value, "Weak references are not supported because no_weak_ref was specified.");
constexpr std::uintptr_t pointer_flag = static_cast<std::uintptr_t>(1) << ((sizeof(std::uintptr_t) * 8) - 1);
return (value & pointer_flag) != 0;
return static_cast<std::intptr_t>(value) < 0;
}

static weak_ref_t* decode_weak_ref(std::uintptr_t const value) noexcept
Expand Down
2 changes: 1 addition & 1 deletion strings/base_reference_produce.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ WINRT_EXPORT namespace winrt::impl

if (is_guid_of<IAgileObject>(id))
{
auto unknown = reinterpret_cast<unknown_abi*>(to_abi<Interface>(derived()));
auto unknown = abi_cast<unknown_abi>(to_abi<Interface>(derived()));
unknown->AddRef();
*object = unknown;
return error_ok;
Expand Down
2 changes: 1 addition & 1 deletion test/old_tests/UnitTests/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <crtdbg.h>
#include "pch.h"
#include <crtdbg.h>

#define CATCH_CONFIG_RUNNER

Expand Down
2 changes: 1 addition & 1 deletion test/old_tests/UnitTests/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST_CASE("Parameters")

std::array<int, 3> view;
params.CopyInt32Array(view);
REQUIRE(view == std::array<int, 3>{1, 2, 3});
REQUIRE(view == std::array<int, 3>{{ 1, 2, 3 }});
}

{
Expand Down
8 changes: 4 additions & 4 deletions test/test/GetMany.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ TEST_CASE("GetMany")
REQUIRE(buffer[0] == 1);
REQUIRE(buffer[1] == 2);
REQUIRE(buffer[2] == 3);
buffer = { 0xCC, 0xCC, 0xCC };
buffer = {{ 0xCC, 0xCC, 0xCC }};
REQUIRE(1 == pos.GetMany(buffer));
REQUIRE(buffer[0] == 4);
REQUIRE(buffer[1] == 0xCC);
REQUIRE(buffer[2] == 0xCC);
buffer = { 0xCC, 0xCC, 0xCC };
buffer = {{ 0xCC, 0xCC, 0xCC }};
REQUIRE(0 == pos.GetMany(buffer));
REQUIRE(buffer[0] == 0xCC);
REQUIRE(buffer[1] == 0xCC);
Expand Down Expand Up @@ -278,12 +278,12 @@ TEST_CASE("GetMany")
REQUIRE(buffer[0] == 1);
REQUIRE(buffer[1] == 2);
REQUIRE(buffer[2] == 3);
buffer = { 0xCC, 0xCC, 0xCC };
buffer = {{ 0xCC, 0xCC, 0xCC }};
REQUIRE(2 == v.GetMany(buffer));
REQUIRE(buffer[0] == 4);
REQUIRE(buffer[1] == 5);
REQUIRE(buffer[2] == 0xCC);
buffer = { 0xCC, 0xCC, 0xCC };
buffer = {{ 0xCC, 0xCC, 0xCC }};
REQUIRE(0 == v.GetMany(buffer));
REQUIRE(buffer[0] == 0xCC);
REQUIRE(buffer[1] == 0xCC);
Expand Down
17 changes: 0 additions & 17 deletions test/test/return_params_abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@ namespace winrt

using namespace winrt;

namespace
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
hstring to_hstring(::IInspectable* raw)
{
winrt::IInspectable object;
copy_from_abi(object, raw);
return object.as<IStringable>().ToString();
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}

TEST_CASE("return_params_abi")
{
Class object;
Expand Down
9 changes: 1 addition & 8 deletions test/test_component/Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,7 @@ namespace winrt::test_component::implementation

namespace
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
void ValidateStaticEventAutoRevoke() {
[[maybe_unused]] void ValidateStaticEventAutoRevoke() {
auto x = winrt::test_component::Simple::StaticEvent(winrt::auto_revoke, [](auto&&, auto&&) {});
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
Loading