Skip to content

Commit 7f0729a

Browse files
authored
Update project to C++23 and ensure REUSE compatibility (#69)
1 parent 6a20a24 commit 7f0729a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+498
-382
lines changed

.github/workflows/reuse.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-FileCopyrightText: © 2024 Team CharLS
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
name: REUSE Compliance Check
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
reuse-compliance-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: REUSE Compliance Check
16+
uses: fsfe/reuse-action@v5

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# SPDX-FileCopyrightText: © 2018 Team CharLS
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
14
[submodule "charls"]
25
path = charls
36
url = https://github.com/team-charls/charls.git

Directory.Build.props

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<!--
2+
SPDX-FileCopyrightText: © 2019 Team CharLS
3+
SPDX-License-Identifier: BSD-3-Clause
4+
-->
5+
26
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
37
<PropertyGroup>
48
<!-- Build to a folder outside the source folders, making it easier to clean. -->
@@ -28,15 +32,19 @@
2832
<!-- Use all cores to speed up the compilation (MS recommended best practice). -->
2933
<MultiProcessorCompilation>true</MultiProcessorCompilation>
3034

31-
<!-- Explicit define that all projects are compiled according the C++20 standard -->
32-
<LanguageStandard>stdcpp20</LanguageStandard>
35+
<!-- Explicit define that all projects are compiled according the draft C++23 standard -->
36+
<LanguageStandard>stdcpplatest</LanguageStandard>
3337
<UseStandardPreprocessor>true</UseStandardPreprocessor> <!-- Needed as stdcpp20 doesn't enable it by default. -->
3438

3539
<!-- To ensure high quality C++ code use Warning level 4 and treat warnings as errors to ensure warnings are fixed promptly. -->
3640
<WarningLevel>Level4</WarningLevel>
3741
<TreatWarningAsError>true</TreatWarningAsError>
3842
<UseFullPaths>true</UseFullPaths>
3943

44+
<!-- Enables recommended Security Development Lifecycle (SDL) checks.
45+
These checks change security-relevant warnings into errors, and set additional secure code-generation features. -->
46+
<SDLCheck>true</SDLCheck>
47+
4048
<!-- Explicit set the 'external' warning level to off (Supported since Visual Studio 2019 16.10) -->
4149
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
4250
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
@@ -95,22 +103,32 @@
95103
96104
* WINRT *
97105
WINRT_LEAN_AND_MEAN: If defined, disables rarely-used WinRT features (in order to reduce compile times)
106+
WINRT_NO_SOURCE_LOCATION (prevents full namespace names in the binary).
98107
99108
* C *
100109
__STDC_WANT_SECURE_LIB__=1: Enable the secure methods of the C standard library.
110+
111+
* Microsoft STL *
112+
_USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION=0: Keep function name info short to reduce binary size.
101113
-->
102114
<PreprocessorDefinitions>
103-
WIN32_LEAN_AND_MEAN;NOSERVICE;NOMCX;NOIME;NOMINMAX;WINRT_LEAN_AND_MEAN;__STDC_WANT_SECURE_LIB__=1;%(PreprocessorDefinitions)
115+
WIN32_LEAN_AND_MEAN;NOSERVICE;NOMCX;NOIME;NOMINMAX;WINRT_LEAN_AND_MEAN;WINRT_NO_SOURCE_LOCATION;__STDC_WANT_SECURE_LIB__=1;_USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION=0;%(PreprocessorDefinitions)
104116
</PreprocessorDefinitions>
105117

106118
<PrecompiledHeader>NotUsing</PrecompiledHeader>
119+
120+
<!-- Add metadata about valid EH handler, prevent IP hijacking -->
121+
<GuardEHContMetadata Condition="'$(Platform)'=='x64'">true</GuardEHContMetadata>
107122
</ClCompile>
108123

109124
<Link>
110125
<SubSystem>Windows</SubSystem>
111126
<GenerateDebugInformation>true</GenerateDebugInformation>
112127
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
113128
<MinimumRequiredVersion>10</MinimumRequiredVersion>
129+
130+
<!-- Indicate DLL is compatible with Hardware supported Shadow stack (requires Zen3+ or Intel 11th Gen CPU) -->
131+
<CETCompat Condition="'$(Platform)'!='ARM64'">true</CETCompat>
114132
</Link>
115133
</ItemDefinitionGroup>
116134

LICENSES/BSD-3-Clause.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright (c) <year> <owner>.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
<!--
2+
SPDX-FileCopyrightText: © 2019 Team CharLS
3+
SPDX-License-Identifier: BSD-3-Clause
4+
-->
5+
16
# JPEG-LS Windows Imaging Component Codec
27

38
This Windows Imaging Component (WIC) codec makes it possible to decode and encode JPEG-LS (.jls) files with Windows applications that can leverage WIC codecs. It makes it possible to view JPEG-LS encoded images in Windows PhotoViewer, Windows Explorer and import JPEG-LS images in Microsoft Office documents.
49

510
[![Build Status](https://dev.azure.com/team-charls/jpegls-wic-codec/_apis/build/status/team-charls.jpegls-wic-codec?branchName=main)](https://dev.azure.com/team-charls/jpegls-wic-codec/_build/latest?definitionId=1&branchName=main)
11+
[![REUSE status](https://api.reuse.software/badge/github.com/team-charls/jpegls-wic-codec)](https://api.reuse.software/info/github.com/team-charls/jpegls-wic-codec)
612
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=team-charls_jpegls-wic-codec&metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=team-charls_jpegls-wic-codec)
713

814
## Introduction

REUSE.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: © 2024 Team CharLS
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
# This is a configuration file for the reuse lint tool. It allows specifing license info
5+
# for files that cannot be extended with such info.
6+
7+
version = 1
8+
9+
[[annotations]]
10+
path = [
11+
"**.pgm",
12+
"**.ppm",
13+
"**.jls",
14+
"**.vcxproj",
15+
"**.filters",
16+
"**/packages.config",
17+
"spelling.dic",
18+
"default.ruleset",
19+
"jpegls-wic-codec.sln",
20+
"setup/global.json",
21+
"setup/setup.sln",
22+
"jpegls-wic-codec.sln.DotSettings",
23+
"restore-windows-photo-viewer.reg",
24+
"test/CodeCoverage.runsettings"
25+
]
26+
precedence = "aggregate"
27+
SPDX-FileCopyrightText = "© 2024 Team CharLS"
28+
SPDX-License-Identifier = "BSD-3-Clause"

create-setup.cmd

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:: SPDX-FileCopyrightText: © 2020 Team CharLS
2+
:: SPDX-License-Identifier: BSD-3-Clause
13

24
REM a WixProj cannot access Visual Studio C++ environment variables: copy merge modules:
35
copy "%VCINSTALLDIR%Redist\MSVC\v142\MergeModules\Microsoft_VC142_CRT_x86.msm" bin\x64\Release\

default.ruleset.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Comments on disabled Microsoft C++ Code Analysis Rules
1+
<!--
2+
SPDX-FileCopyrightText: © 2020 Team CharLS
3+
SPDX-License-Identifier: BSD-3-Clause
4+
-->
5+
6+
# Comments on disabled Microsoft C++ Code Analysis Rules
27

38
This document contains the rationales why Microsoft
49
C++ warnings are disabled in the file default.ruleset

jpegls-wic-codec.sln.DotSettings

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lossless/@EntryIndexedValue">True</s:Boolean>
4646
<s:Boolean x:Key="/Default/UserDictionary/Words/=MIDLRT/@EntryIndexedValue">True</s:Boolean>
4747
<s:Boolean x:Key="/Default/UserDictionary/Words/=Multiframe/@EntryIndexedValue">True</s:Boolean>
48+
<s:Boolean x:Key="/Default/UserDictionary/Words/=subsampled/@EntryIndexedValue">True</s:Boolean>
4849
<s:Boolean x:Key="/Default/UserDictionary/Words/=TARGETDIR/@EntryIndexedValue">True</s:Boolean>
4950
<s:Boolean x:Key="/Default/UserDictionary/Words/=Undefine/@EntryIndexedValue">True</s:Boolean>
5051
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unregister/@EntryIndexedValue">True</s:Boolean>

setup/Product.wxs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
1+
<!--
2+
SPDX-FileCopyrightText: © 2020 Team CharLS
3+
SPDX-License-Identifier: BSD-3-Clause
4+
-->
5+
6+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
27
<Package Name="CharLS JPEG-LS WIC Codec" Language="1033" Version="0.1.0.0" Manufacturer="Team CharLS" UpgradeCode="c713c1c4-ab72-4546-b96c-68c89236291b">
38

49
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

setup/setup.wixproj

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<!--
2+
SPDX-FileCopyrightText: © 2020 Team CharLS
3+
SPDX-License-Identifier: BSD-3-Clause
4+
-->
5+
16
<Project Sdk="WixToolset.Sdk">
27
<PropertyGroup>
38
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>

setup/wic_registration.wxi

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
1+
<!--
2+
SPDX-FileCopyrightText: © 2020 Team CharLS
3+
SPDX-License-Identifier: BSD-3-Clause
4+
-->
5+
6+
<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
27
<Class Id="$(var.CLSID_JpegLSEncoder)" Context="InprocServer32" Server="$(var.ComServerFileId)" ThreadingModel="both" />
38

49
<RegistryKey Root="HKCR" Key="CLSID\$(var.CLSID_JpegLSEncoder)">

spelling.dic

+7
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@
1919
jlsfile
2020
fccd
2121
fmtlib
22+
Multiframe
23+
inproc
24+
jpegls
25+
fmtlib
26+
jlsfile
27+
fccd
28+
bugprone

src/class_factory.ixx

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Copyright (c) Team CharLS.
1+
// SPDX-FileCopyrightText: © 2019 Team CharLS
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
export module class_factory;
55

6-
import "win.h";
7-
import errors;
6+
import <win.hpp>;
87
import winrt;
98

9+
import hresults;
10+
1011
export template<typename Class>
1112
struct class_factory : winrt::implements<class_factory<Class>, IClassFactory>
1213
{
@@ -32,6 +33,6 @@ struct class_factory : winrt::implements<class_factory<Class>, IClassFactory>
3233

3334
HRESULT __stdcall LockServer(BOOL /*lock*/) noexcept override
3435
{
35-
return error_ok;
36+
return success_ok;
3637
}
3738
};

src/cpp.hint

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// SPDX-FileCopyrightText: © 2019 Team CharLS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
14
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
25
// such as names of functions and macros.
36
// For more information see https://go.microsoft.com/fwlink/?linkid=865984

src/dllmain.cpp src/dll_main.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// Copyright (c) Team CharLS.
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
#include "macros.h"
5-
#include "version.h"
4+
#include "macros.hpp"
5+
#include "intellisense.hpp"
6+
#include "version.hpp"
67

7-
import "std.h";
8-
import "win.h";
8+
import std;
9+
import <win.hpp>;
910

1011
import guids;
1112
import util;
12-
import errors;
13+
import hresults;
1314
import jpegls_bitmap_decoder;
1415
import jpegls_bitmap_encoder;
1516

@@ -71,9 +72,9 @@ void register_decoder()
7172
registry::set_value(patterns_sub_key, L"Position", 0U);
7273

7374
constexpr array mask{0xFF_byte, 0xFF_byte, 0xFF_byte};
74-
registry::set_value(patterns_sub_key, L"Mask", mask.data(), static_cast<DWORD>(mask.size()));
75+
registry::set_value(patterns_sub_key, L"Mask", mask);
7576
constexpr array pattern{0xFF_byte, 0xD8_byte, 0xFF_byte};
76-
registry::set_value(patterns_sub_key, L"Pattern", pattern.data(), static_cast<DWORD>(pattern.size()));
77+
registry::set_value(patterns_sub_key, L"Pattern", pattern);
7778

7879
registry::set_value(LR"(SOFTWARE\Classes\.jls\)", L"", L"jlsfile");
7980
registry::set_value(LR"(SOFTWARE\Classes\.jls\)", L"Content Type", L"image/jls");
@@ -120,12 +121,12 @@ HRESULT unregister(const GUID& class_id, const GUID& wic_category_id)
120121
// ReSharper disable CppInconsistentNaming
121122
// ReSharper disable CppParameterNamesMismatch
122123

123-
BOOL __stdcall DllMain(const HMODULE module, const DWORD reason_for_call, void* /*reserved*/) noexcept
124+
BOOL __stdcall DllMain(const HMODULE dll_module, const DWORD reason_for_call, void* /*reserved*/) noexcept
124125
{
125126
switch (reason_for_call)
126127
{
127128
case DLL_PROCESS_ATTACH:
128-
VERIFY(DisableThreadLibraryCalls(module));
129+
VERIFY(DisableThreadLibraryCalls(dll_module));
129130
break;
130131

131132
case DLL_THREAD_ATTACH:
@@ -174,7 +175,7 @@ try
174175

175176
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr);
176177

177-
return error_ok;
178+
return success_ok;
178179
}
179180
catch (...)
180181
{

src/guids.ixx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
export module guids;
55

6-
import "win.h";
6+
import <win.hpp>;
77

88
export namespace id {
99

src/errors.ixx src/hresults.ixx

+5-29
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
// Copyright (c) Team CharLS.
1+
// SPDX-FileCopyrightText: © 2020 Team CharLS
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
module;
55

6-
#include "macros.h"
6+
#include "intellisense.hpp"
77

8-
export module errors;
8+
export module hresults;
99

10-
import "win.h";
10+
import <win.hpp>;
1111
import winrt;
1212

1313
export {
1414

15-
inline constexpr HRESULT error_ok{S_OK};
15+
inline constexpr HRESULT success_ok{S_OK};
1616
inline constexpr HRESULT error_fail{E_FAIL};
1717
inline constexpr HRESULT error_pointer{E_POINTER};
1818
inline constexpr HRESULT error_no_aggregation{CLASS_E_NOAGGREGATION};
@@ -35,28 +35,4 @@ inline constexpr HRESULT error_bad_image{WINCODEC_ERR_BADIMAGE};
3535

3636
} // namespace wincodec
3737

38-
template<typename T>
39-
T* check_in_pointer(_In_ T* pointer)
40-
{
41-
if (!pointer)
42-
winrt::throw_hresult(error_invalid_argument);
43-
44-
return pointer;
45-
}
46-
47-
template<typename T>
48-
T* check_out_pointer(T* pointer)
49-
{
50-
if (!pointer)
51-
winrt::throw_hresult(error_pointer);
52-
53-
return pointer;
54-
}
55-
56-
inline void check_condition(const bool condition, const winrt::hresult result_to_throw)
57-
{
58-
if (!condition)
59-
throw_hresult(result_to_throw);
60-
}
61-
6238
}

src/intellisense.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-FileCopyrightText: © 2024 Team CharLS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
#pragma once
5+
6+
// Include explicit headers as workaround that IntelliSense (VS 2022 17.12)
7+
// and ReSharper (2024.2.5) fail to parse #import <win.hpp>
8+
#if defined(__INTELLISENSE__) || defined(__RESHARPER__)
9+
// ReSharper disable once CppInconsistentNaming
10+
#define _AMD64_
11+
#include <combaseapi.h>
12+
#include <libloaderapi.h>
13+
#include <sal.h>
14+
#include <wincodec.h>
15+
#include <winreg.h>
16+
#include <propkey.h>
17+
#endif

src/jpegls-wic-codec.def

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
; SPDX-FileCopyrightText: © 2019 Team CharLS
2+
; SPDX-License-Identifier: BSD-3-Clause
3+
14
EXPORTS
25
DllCanUnloadNow PRIVATE
36
DllGetClassObject PRIVATE

0 commit comments

Comments
 (0)