Skip to content

Commit

Permalink
Use default C++/WinRT settings (remove WINRT_NO_MAKE_DETECTION)
Browse files Browse the repository at this point in the history
WINRT_NO_MAKE_DETECTION ensure that winrt::make must be used, but prevent using final on the implementation classes.
As is not a default option, it may confuss others.
  • Loading branch information
vbaderks committed Apr 7, 2024
1 parent 53753e6 commit 9c269cf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 26 deletions.
16 changes: 5 additions & 11 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,13 @@
NOMINMAX: Prevent that the Windows SDK header files define the macros min and max (conflict with C++ std::min\max).
* WINRT *
WINRT_NO_MAKE_DETECTION: Enable making COM class implementation final
_SILENCE_CLANG_COROUTINE_MESSAGE: Supress warning that coroutine is not compatible wih clang (clang-tidy fix)
WINRT_LEAN_AND_MEAN: If defined, disables rarely-used WinRT features (in order to reduce compile times)
* C *
__STDC_WANT_SECURE_LIB__=1: Enable the secure methods of the C standard library.
-->
<PreprocessorDefinitions>
WIN32_LEAN_AND_MEAN;
NOSERVICE;
NOMCX;
NOIME;
NOMINMAX;
WINRT_NO_MAKE_DETECTION;
__STDC_WANT_SECURE_LIB__=1;
_SILENCE_CLANG_COROUTINE_MESSAGE;
%(PreprocessorDefinitions)
WIN32_LEAN_AND_MEAN;NOSERVICE;NOMCX;NOIME;NOMINMAX;WINRT_LEAN_AND_MEAN;__STDC_WANT_SECURE_LIB__=1;%(PreprocessorDefinitions)
</PreprocessorDefinitions>

<PrecompiledHeader>NotUsing</PrecompiledHeader>
Expand Down
1 change: 1 addition & 0 deletions jpegls-wic-codec.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClangTidyModernizeAvoidCArrays/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClangTidyReadabilityMagicNumbers/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClangTidyReadabilityNonConstParameter/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020methods/@EntryIndexedValue">&lt;NamingElement Priority="10"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="member function" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="False" Prefix="" Suffix="" Style="aa_bb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Local_0020variables/@EntryIndexedValue">&lt;NamingElement Priority="7"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="local variable" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="False" Prefix="" Suffix="" Style="aa_bb" /&gt;&lt;/NamingElement&gt;</s:String>
Expand Down
9 changes: 6 additions & 3 deletions src/jpegls_bitmap_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ using winrt::com_ptr;
using winrt::make;
using winrt::to_hresult;

namespace {

class jpegls_bitmap_decoder final : public winrt::implements<jpegls_bitmap_decoder, IWICBitmapDecoder>
struct jpegls_bitmap_decoder : winrt::implements<jpegls_bitmap_decoder, IWICBitmapDecoder>
{
public:
// IWICBitmapDecoder
HRESULT __stdcall QueryCapability(_In_ IStream* stream, _Out_ DWORD* capability) noexcept override
try
Expand Down Expand Up @@ -190,7 +190,8 @@ class jpegls_bitmap_decoder final : public winrt::implements<jpegls_bitmap_decod
HRESULT __stdcall GetFrame(const uint32_t index, _Outptr_ IWICBitmapFrameDecode** bitmap_frame_decode) noexcept override
try
{
TRACE("{} jpegls_bitmap_decoder::GetFrame, index={}, bitmap_frame_decode={}\n", fmt::ptr(this), index, fmt::ptr(bitmap_frame_decode));
TRACE("{} jpegls_bitmap_decoder::GetFrame, index={}, bitmap_frame_decode={}\n", fmt::ptr(this), index,
fmt::ptr(bitmap_frame_decode));

check_condition(index == 0, wincodec::error_frame_missing);

Expand Down Expand Up @@ -229,6 +230,8 @@ class jpegls_bitmap_decoder final : public winrt::implements<jpegls_bitmap_decod
com_ptr<IWICBitmapFrameDecode> bitmap_frame_decode_;
};

} // namespace

HRESULT create_jpegls_bitmap_decoder_factory(_In_ GUID const& interface_id, _Outptr_ void** result)
{
return make<class_factory<jpegls_bitmap_decoder>>()->QueryInterface(interface_id, result);
Expand Down
9 changes: 4 additions & 5 deletions src/jpegls_bitmap_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ void write_spiff_header(jpegls_encoder& encoder, const jpegls_bitmap_frame_encod
}
}

} // namespace

class jpegls_bitmap_encoder final : public implements<jpegls_bitmap_encoder, IWICBitmapEncoder>
struct jpegls_bitmap_encoder : implements<jpegls_bitmap_encoder, IWICBitmapEncoder>
{
public:
// IWICBitmapEncoder
HRESULT __stdcall Initialize(_In_ IStream* destination,
[[maybe_unused]] const WICBitmapEncoderCacheOption cache_option) noexcept override
Expand Down Expand Up @@ -192,7 +189,7 @@ class jpegls_bitmap_encoder final : public implements<jpegls_bitmap_encoder, IWI
TRACE("{} jpegls_bitmap_encoder::GetMetadataQueryWriter, metadata_query_writer={}\n", fmt::ptr(this),
fmt::ptr(metadata_query_writer));

// Note: the current implementation doesn't writing metadata to the JPEG-LS stream.
// Note: the current implementation doesn't write metadata to the JPEG-LS stream.
// The SPIFF header can be used to store metadata items.
constexpr HRESULT result = wincodec::error_unsupported_operation;
return result;
Expand Down Expand Up @@ -226,6 +223,8 @@ class jpegls_bitmap_encoder final : public implements<jpegls_bitmap_encoder, IWI
com_ptr<jpegls_bitmap_frame_encode> bitmap_frame_encode_;
};

} // namespace

HRESULT create_jpegls_bitmap_encoder_factory(GUID const& interface_id, void** result)
{
return make<class_factory<jpegls_bitmap_encoder>>()->QueryInterface(interface_id, result);
Expand Down
5 changes: 2 additions & 3 deletions src/jpegls_bitmap_frame_decode.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import "std.h";
import "win.h";
import winrt;

export class jpegls_bitmap_frame_decode final
: public winrt::implements<jpegls_bitmap_frame_decode, IWICBitmapFrameDecode, IWICBitmapSource>
export struct jpegls_bitmap_frame_decode
: winrt::implements<jpegls_bitmap_frame_decode, IWICBitmapFrameDecode, IWICBitmapSource>
{
public:
jpegls_bitmap_frame_decode(IStream* stream, IWICImagingFactory* factory);

// IWICBitmapSource
Expand Down
3 changes: 1 addition & 2 deletions src/jpegls_bitmap_frame_encode.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import "win.h";
import winrt;
import charls;

export class jpegls_bitmap_frame_encode final : public winrt::implements<jpegls_bitmap_frame_encode, IWICBitmapFrameEncode>
export struct jpegls_bitmap_frame_encode : winrt::implements<jpegls_bitmap_frame_encode, IWICBitmapFrameEncode>
{
public:
[[nodiscard]]
const charls::frame_info& frame_info() const noexcept
{
Expand Down
3 changes: 1 addition & 2 deletions test/test_stream.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import errors;
import winrt;
import "win.h";

export class test_stream final : public winrt::implements<test_stream, IStream>
export struct test_stream : winrt::implements<test_stream, IStream>
{
public:
test_stream(const bool fail_on_read, const int fail_on_seek_counter) noexcept :
fail_on_read_{fail_on_read}, fail_on_seek_counter_{fail_on_seek_counter}
{
Expand Down

0 comments on commit 9c269cf

Please sign in to comment.