From 7ee8aee5add8d0c5b1a9e912a7043b2da4bb7453 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 12 Dec 2021 15:30:12 +0000 Subject: Move generic constexpr_strlen to lib --- gfx/gl/shader-source.h | 10 ---------- lib/embed-glsl.cpp.m4 | 1 + lib/strings.hpp | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 lib/strings.hpp diff --git a/gfx/gl/shader-source.h b/gfx/gl/shader-source.h index f22cc3b..524025c 100644 --- a/gfx/gl/shader-source.h +++ b/gfx/gl/shader-source.h @@ -14,14 +14,4 @@ struct GLsource { [[nodiscard]] ShaderRef compile() const; }; -constexpr auto -constexpr_strlen(const GLchar * const s) -{ - std::size_t ch {}; - while (s[ch]) { - ch++; - } - return ch; -} - #endif diff --git a/lib/embed-glsl.cpp.m4 b/lib/embed-glsl.cpp.m4 index 9e4c6d4..d820756 100644 --- a/lib/embed-glsl.cpp.m4 +++ b/lib/embed-glsl.cpp.m4 @@ -3,6 +3,7 @@ changecom()dnl #include "substr(TYPE,1)-NAME.h" #include #include "gfx/gl/shader-source.h" +#include "lib/strings.hpp" constexpr const GLchar * src { R"GLSL-EMBED(dnl include(SOURCE))GLSL-EMBED" }; diff --git a/lib/strings.hpp b/lib/strings.hpp new file mode 100644 index 0000000..ee0db95 --- /dev/null +++ b/lib/strings.hpp @@ -0,0 +1,14 @@ +#ifndef STRINGS_HPP +#define STRINGS_HPP + +constexpr auto +constexpr_strlen(const GLchar * const s) +{ + std::size_t ch {}; + while (s[ch]) { + ch++; + } + return ch; +} + +#endif -- cgit v1.2.3