aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-10-07 15:16:55 -0400
committerDavid Robillard <d@drobilla.net>2022-10-07 15:16:55 -0400
commited4c8a50505ab02a8f3a01e41f5f86acca04b81d (patch)
tree3c06732998db625fb771bbaeab69d249bf7ba517
parent92132eca5e75d3f95a3eb7e015c47765a79925cc (diff)
downloadpugl-ed4c8a50505ab02a8f3a01e41f5f86acca04b81d.tar.gz
pugl-ed4c8a50505ab02a8f3a01e41f5f86acca04b81d.tar.bz2
pugl-ed4c8a50505ab02a8f3a01e41f5f86acca04b81d.zip
Avoid C-style casts in C++ code
-rw-r--r--bindings/cpp/include/pugl/pugl.hpp12
-rw-r--r--examples/.clang-tidy1
-rw-r--r--examples/pugl_vulkan_cpp_demo.cpp10
-rw-r--r--examples/sybok.hpp2
4 files changed, 13 insertions, 12 deletions
diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp
index 87cd378..3f21dc6 100644
--- a/bindings/cpp/include/pugl/pugl.hpp
+++ b/bindings/cpp/include/pugl/pugl.hpp
@@ -205,7 +205,7 @@ enum class Status {
unsupported, ///< @copydoc PUGL_UNSUPPORTED
};
-static_assert(Status(PUGL_UNSUPPORTED) == Status::unsupported, "");
+static_assert(static_cast<Status>(PUGL_UNSUPPORTED) == Status::unsupported, "");
/// @copydoc puglStrerror
inline const char*
@@ -226,14 +226,15 @@ enum class WorldType {
module, ///< @copydoc PUGL_MODULE
};
-static_assert(WorldType(PUGL_MODULE) == WorldType::module, "");
+static_assert(static_cast<WorldType>(PUGL_MODULE) == WorldType::module, "");
/// @copydoc PuglWorldFlag
enum class WorldFlag {
threads = PUGL_WORLD_THREADS, ///< @copydoc PUGL_WORLD_THREADS
};
-static_assert(WorldFlag(PUGL_WORLD_THREADS) == WorldFlag::threads, "");
+static_assert(static_cast<WorldFlag>(PUGL_WORLD_THREADS) == WorldFlag::threads,
+ "");
using WorldFlags = PuglWorldFlags; ///< @copydoc PuglWorldFlags
@@ -363,7 +364,8 @@ enum class ViewHint {
refreshRate, ///< @copydoc PUGL_REFRESH_RATE
};
-static_assert(ViewHint(PUGL_REFRESH_RATE) == ViewHint::refreshRate, "");
+static_assert(static_cast<ViewHint>(PUGL_REFRESH_RATE) == ViewHint::refreshRate,
+ "");
using ViewHintValue = PuglViewHintValue; ///< @copydoc PuglViewHintValue
@@ -378,7 +380,7 @@ enum class Cursor {
upDown, ///< @copydoc PUGL_CURSOR_UP_DOWN
};
-static_assert(Cursor(PUGL_CURSOR_UP_DOWN) == Cursor::upDown, "");
+static_assert(static_cast<Cursor>(PUGL_CURSOR_UP_DOWN) == Cursor::upDown, "");
/// @copydoc PuglView
class View : protected detail::Wrapper<PuglView, puglFreeView>
diff --git a/examples/.clang-tidy b/examples/.clang-tidy
index bf9899a..819a16d 100644
--- a/examples/.clang-tidy
+++ b/examples/.clang-tidy
@@ -21,7 +21,6 @@ Checks: >
-fuchsia-default-arguments,
-fuchsia-default-arguments-calls,
-fuchsia-overloaded-operator,
- -google-readability-casting,
-google-runtime-references,
-hicpp-multiway-paths-covered,
-hicpp-no-array-decay,
diff --git a/examples/pugl_vulkan_cpp_demo.cpp b/examples/pugl_vulkan_cpp_demo.cpp
index c901de5..7e0bd38 100644
--- a/examples/pugl_vulkan_cpp_demo.cpp
+++ b/examples/pugl_vulkan_cpp_demo.cpp
@@ -272,7 +272,7 @@ selectPresentMode(const sk::VulkanApi& vk,
return r;
}
- const auto& tryModes = priorities[bool(multiBuffer)][bool(sync)];
+ const auto& tryModes = priorities[multiBuffer][sync];
for (const auto m : tryModes) {
if (std::find(modes.begin(), modes.end(), m) != modes.end()) {
presentMode = m;
@@ -896,8 +896,8 @@ RectPipeline::init(const sk::VulkanApi& vk,
const VkViewport viewport{0.0f,
0.0f,
- float(swapchain.extent.width),
- float(swapchain.extent.height),
+ static_cast<float>(swapchain.extent.width),
+ static_cast<float>(swapchain.extent.height),
0.0f,
1.0f};
@@ -1560,9 +1560,9 @@ update(PuglVulkanDemo& app, const double time)
UniformBufferObject ubo = {{}};
mat4Ortho(ubo.projection,
0.0f,
- float(app.renderer.swapchain.extent.width),
+ static_cast<float>(app.renderer.swapchain.extent.width),
0.0f,
- float(app.renderer.swapchain.extent.height),
+ static_cast<float>(app.renderer.swapchain.extent.height),
-1.0f,
1.0f);
diff --git a/examples/sybok.hpp b/examples/sybok.hpp
index 568e581..aad1b41 100644
--- a/examples/sybok.hpp
+++ b/examples/sybok.hpp
@@ -777,7 +777,7 @@ public:
}
if (!vkDestroyInstance) {
- vkDestroyInstance = PFN_vkDestroyInstance(
+ vkDestroyInstance = reinterpret_cast<PFN_vkDestroyInstance>(
getInstanceProcAddr(instance, "vkDestroyInstance"));
}