Skip to content

Commit ae9bb27

Browse files
authored
Update dependencies and build jobs (#25)
* Update dependencies * Update build jobs * Updates for most recent toolchain
1 parent 96c86a9 commit ae9bb27

29 files changed

+335
-394
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ updates:
33
- package-ecosystem: github-actions
44
directory: /
55
schedule:
6-
interval: monthly
6+
interval: weekly

.github/workflows/build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ on:
55
branches: [ master, 'feature**' ]
66
pull_request:
77
branches: [ master ]
8-
paths-ignore:
9-
- '**/*.md'
10-
- '**/*.txt'
8+
9+
permissions: {}
1110

1211
jobs:
1312
build:
13+
name: Build
1414
uses: mbeckh/cmake-utils/.github/workflows/run-build.yml@v1
1515
secrets: inherit
16+
permissions:
17+
actions: write
18+
contents: read
19+
packages: write
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8-
paths-ignore:
9-
- '**/*.md'
10-
- '**/*.txt'
11-
schedule:
12-
- cron: '21 8 4 * *'
8+
workflow_dispatch:
9+
10+
permissions: {}
1311

1412
jobs:
15-
build:
13+
codeql:
14+
name: CodeQL
1615
uses: mbeckh/cmake-utils/.github/workflows/run-codeql.yml@v1
1716
secrets: inherit
17+
permissions:
18+
actions: write
19+
contents: read
20+
packages: write
21+
security-events: write

.github/workflows/msvc-analysis.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
14+
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
1515

1616
project("common-cpp" VERSION 0.1.3
1717
DESCRIPTION "Common C++ library"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A collection of common classes for C++ programming, particularly for targeting Windows API and COM.
33

44
[![Release](https://img.shields.io/github/v/release/mbeckh/common-cpp?display_name=tag&sort=semver&label=Release&style=flat-square)](https://github.com/mbeckh/common-cpp/releases/)
5-
[![Tests](https://img.shields.io/github/workflow/status/mbeckh/common-cpp/Build/master?label=Tests&logo=GitHub&style=flat-square)](https://github.com/mbeckh/common-cpp/actions)
5+
[![Tests](https://img.shields.io/github/actions/workflow/status/mbeckh/common-cpp/build.yml?branch=master&label=Tests&logo=GitHub&style=flat-square)](https://github.com/mbeckh/common-cpp/actions)
66
[![Coverage](https://img.shields.io/codecov/c/gh/mbeckh/common-cpp/master?label=Coverage&logo=codecov&style=flat-square)](https://codecov.io/gh/mbeckh/common-cpp)
77
[![Codacy Grade](https://img.shields.io/codacy/grade/d1c1975989c642f2817ffc7160ff6f92?label=Code%20Quality&logo=codacy&style=flat-square)](https://www.codacy.com/manual/mbeckh/common-cpp?utm_source=github.com&utm_medium=referral&utm_content=mbeckh/SystemTools&utm_campaign=Badge_Grade)
88
[![License](https://img.shields.io/github/license/mbeckh/common-cpp?label=License&style=flat-square)](https://github.com/mbeckh/common-cpp/blob/master/LICENSE)

cmake/EventLog.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@ function(common_cpp_target_events target events #[[ [ DESTINATION <path> ] [ LEV
123123
install(FILES "${man_file}" TYPE DATA)
124124
endif()
125125

126-
if(NOT TARGET "generated-sources")
127-
add_custom_target("generated-sources")
128-
endif()
129-
if(NOT TARGET "${target}-generated-sources")
130-
add_custom_target("${target}-generated-sources" DEPENDS "${man_file}" "${cpp_file}" "${rc_file}" "${h_file}")
131-
add_dependencies("generated-sources" "${target}-generated-sources")
132-
endif()
133-
134126
target_include_directories("${target}" SYSTEM PRIVATE "${bin_dir}")
135127
string(TOUPPER "${arg_LEVEL}" arg_LEVEL)
136128
if(arg_LEVEL STREQUAL "CRITICAL")

include/m3c/ComObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ template <std::derived_from<IUnknown> T>
3838
class com_ptr;
3939

4040
template <typename T, std::derived_from<internal::AbstractComObject> C, typename... Args>
41-
com_ptr<T> make_com(Args&&... args);
41+
[[nodiscard]] com_ptr<T> make_com(Args&&... args);
4242

4343

4444
namespace internal {

include/m3c/com_ptr.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ limitations under the License.
3434

3535
namespace m3c {
3636

37+
template <typename T, std::derived_from<internal::AbstractComObject> C, typename... Args>
38+
[[nodiscard]] com_ptr<T> make_com(Args&&... args);
39+
3740
namespace internal {
3841

3942
/// @brief Base class with common static helper methods.
@@ -56,6 +59,21 @@ class com_ptr_base {
5659
static void QueryInterface(_In_ IUnknown* pUnknown, const IID& iid, _Outptr_ void** p);
5760
};
5861

62+
/// @brief Marker class for restricting access to private constructor of com_ptr.
63+
struct com_ptr_private {
64+
private:
65+
constexpr com_ptr_private() noexcept = default;
66+
com_ptr_private(const com_ptr_private&) = delete;
67+
com_ptr_private(com_ptr_private&&) = delete;
68+
constexpr ~com_ptr_private() noexcept = default;
69+
70+
com_ptr_private operator=(const com_ptr_private&) = delete;
71+
com_ptr_private operator=(com_ptr_private&&) = delete;
72+
73+
template <typename T, std::derived_from<internal::AbstractComObject> C, typename... Args>
74+
friend com_ptr<T> m3c::make_com(Args&&... args);
75+
};
76+
5977
} // namespace internal
6078

6179

@@ -99,11 +117,10 @@ class com_ptr final : private internal::com_ptr_base {
99117
com_add_ref();
100118
}
101119

102-
private:
103120
/// @brief Assigns an interface pointer without increasing the reference count.
104121
/// This constructor is required for `make_com`.
105122
/// @param p The native pointer.
106-
[[nodiscard]] explicit com_ptr(_In_ internal::AbstractComObject* const p)
123+
[[nodiscard]] explicit com_ptr(const internal::com_ptr_private /* unused*/, _In_ internal::AbstractComObject* const p)
107124
: m_ptr(p->QueryInterface<T>()) {
108125
// empty
109126
}
@@ -282,9 +299,6 @@ class com_ptr final : private internal::com_ptr_base {
282299
private:
283300
T* m_ptr = nullptr; ///< @brief The native pointer wrapped by this class.
284301

285-
template <typename P, std::derived_from<internal::AbstractComObject> C, typename... Args>
286-
friend com_ptr<P> make_com(Args&&...);
287-
288302
template <typename P>
289303
friend void operator>>(const com_ptr<P>&, _Inout_ LogFormatArgs&);
290304

@@ -417,7 +431,7 @@ template <typename T, std::derived_from<internal::AbstractComObject> C, typename
417431
});
418432
// constructor calls QueryInterface internally so that the correct COM pointer is stored.
419433
// Please note: COM interface inheritance is somewhat different from usual OO inheritance.
420-
return com_ptr<T>(pObject);
434+
return com_ptr<T>({}, pObject);
421435
}
422436

423437

include/m3c/format.h

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,6 @@ limitations under the License.
4444

4545
namespace m3c {
4646

47-
#ifdef __clang_analyzer__
48-
49-
namespace internal {
50-
51-
template <typename... Args>
52-
inline auto IwyuFormatWorkaround(const char* pattern, Args&&... args) {
53-
return fmt::format(fmt::runtime(pattern), std::forward<Args>(args)...);
54-
}
55-
56-
template <typename T, typename... Args>
57-
inline auto IwyuFormatWorkaround(T&& pattern, Args&&... args) {
58-
return fmt::format(std::forward<T>(pattern), std::forward<Args>(args)...);
59-
}
60-
61-
} // namespace internal
62-
63-
/// @brief Replace literal format strings for fmt compile with runtime strings.
64-
/// @details clang-tidy and include-what-you-use have problems parsing and diagnose false positives or hang/crash.
65-
#define FMT_FORMAT(...) m3c::internal::IwyuFormatWorkaround(__VA_ARGS__)
66-
#else
67-
/// @brief Replace literal format strings for fmt compile with runtime strings.
68-
/// @details clang-tidy and include-what-you-use have problems parsing and diagnose false positives or hang/crash.
69-
#define FMT_FORMAT(...) fmt::format(__VA_ARGS__)
70-
#endif
71-
72-
7347
//
7448
// String encoding
7549
//
@@ -573,7 +547,7 @@ struct fmt::formatter<m3c::fmt_ptr<IUnknown>, CharT> {
573547
// AddRef to get the ref count
574548
const ULONG ref = ptr ? (ptr->AddRef(), ptr->Release()) : 0;
575549
if (std::holds_alternative<fmt::formatter<std::basic_string<CharT>, CharT>>(m_formatter)) {
576-
std::basic_string<CharT> value = FMT_FORMAT(
550+
const std::basic_string<CharT> value = fmt::format(
577551
m3c::SelectString<CharT>(M3C_SELECT_STRING("(ptr={}, ref={})")),
578552
fmt::ptr(ptr), ref);
579553
return std::get<fmt::formatter<std::basic_string<CharT>, CharT>>(m_formatter).format(value, ctx);
@@ -652,7 +626,7 @@ struct fmt::formatter<m3c::fmt_ptr<IStream>, CharT> : fmt::formatter<m3c::fmt_pt
652626

653627
// AddRef to get the ref count
654628
const ULONG ref = ptr ? (ptr->AddRef(), ptr->Release()) : 0;
655-
std::basic_string<CharT> value = FMT_FORMAT(
629+
const std::basic_string<CharT> value = fmt::format(
656630
m3c::SelectString<CharT>(M3C_SELECT_STRING("({}, ptr={}, ref={})")),
657631
m3c::fmt_encode(name), fmt::ptr(ptr), ref);
658632
return std::get<fmt::formatter<std::basic_string<CharT>, CharT>>(m_formatter).format(value, ctx);
@@ -895,7 +869,8 @@ struct ConvertibleToCStrTraits {
895869
/// @brief Calculate the length for objects having a `length()` method.
896870
/// @param arg The object.
897871
/// @return The number of characters excluding the terminating null character.
898-
static constexpr auto length(const T& arg) noexcept(noexcept(arg.length())) requires requires {
872+
static constexpr auto length(const T& arg) noexcept(noexcept(arg.length()))
873+
requires requires {
899874
{ arg.length() } -> StringLength;
900875
}
901876
{
@@ -905,7 +880,8 @@ struct ConvertibleToCStrTraits {
905880
/// @brief Calculate the length for objects having no `length()` but a `size()` method.
906881
/// @param arg The object.
907882
/// @return The number of characters excluding the terminating null character.
908-
static constexpr auto length(const T& arg) noexcept(noexcept(arg.size())) requires requires {
883+
static constexpr auto length(const T& arg) noexcept(noexcept(arg.size()))
884+
requires requires {
909885
{ arg.size() } -> StringLength;
910886
requires !requires {
911887
{ arg.length() } -> StringLength;
@@ -919,7 +895,8 @@ struct ConvertibleToCStrTraits {
919895
/// @details The string length is calculated using `std::char_traits`.
920896
/// @param arg The object.
921897
/// @return The number of characters excluding the terminating null character.
922-
static constexpr auto length(const T& arg) noexcept(noexcept(std::char_traits<CharT>::length(arg))) requires requires {
898+
static constexpr auto length(const T& arg) noexcept(noexcept(std::char_traits<CharT>::length(arg)))
899+
requires requires {
923900
requires !requires {
924901
{ arg.length() } -> StringLength;
925902
};

0 commit comments

Comments
 (0)