diff --git a/core/src/main/cpp/main/include/base/object.h b/core/src/main/cpp/main/include/base/object.h index 6f34a9ca..59bea9a7 100644 --- a/core/src/main/cpp/main/include/base/object.h +++ b/core/src/main/cpp/main/include/base/object.h @@ -20,9 +20,6 @@ #pragma once -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template" - #include "macros.h" #include #include @@ -199,13 +196,6 @@ namespace lspd { template MemberFunction(Return(This::*f)(Args...)) -> MemberFunction; - template using tstring = std::integer_sequence; - - template - constexpr tstring operator ""_tstr() { - return {}; - } - template struct Hooker; @@ -259,5 +249,3 @@ namespace lspd { } // namespace lspd using lspd::operator ""_tstr; - -#pragma clang diagnostic pop diff --git a/core/src/main/cpp/main/include/config.h b/core/src/main/cpp/main/include/config.h index 4fce2bd1..e47f4752 100644 --- a/core/src/main/cpp/main/include/config.h +++ b/core/src/main/cpp/main/include/config.h @@ -48,19 +48,19 @@ inline constexpr bool is64 = Is64(); # define LP_SELECT(lp32, lp64) lp32 #endif - static const auto kEntryClassName = "org.lsposed.lspd.core.Main"s; - static const auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"s; - static const auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"s; - static const auto kDexPath = "framework/lspd.dex"s; + static constexpr auto kEntryClassName = "org.lsposed.lspd.core.Main"_tstr; + static constexpr auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"_tstr; + static constexpr auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"_tstr; + static constexpr auto kDexPath = "framework/lspd.dex"_tstr; - static const auto kLibArtName = "libart.so"s; - static const auto kLibFwName = "libandroidfw.so"s; + static constexpr auto kLibArtName = "libart.so"_tstr; + static constexpr auto kLibFwName = "libandroidfw.so"_tstr; - static const auto kLibBasePath = - LP_SELECT("/system/lib/"s, - "/system/lib64/"s); - static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName; - static const auto kLibFwPath = kLibBasePath + kLibFwName; + static constexpr auto kLibBasePath = + LP_SELECT("/system/lib/"_tstr, + "/system/lib64/"_tstr); + static constexpr auto kLibArtLegacyPath = kLibBasePath + kLibArtName; + static constexpr auto kLibFwPath = kLibBasePath + kLibFwName; inline constexpr const char *const BoolToString(bool b) { return b ? "true" : "false"; diff --git a/core/src/main/cpp/main/include/utils.h b/core/src/main/cpp/main/include/utils.h index bdd30cd8..bc598b4d 100644 --- a/core/src/main/cpp/main/include/utils.h +++ b/core/src/main/cpp/main/include/utils.h @@ -20,6 +20,9 @@ #pragma once +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template" + #include #include #include @@ -35,4 +38,42 @@ namespace lspd { __system_property_get("ro.build.version.sdk", prop_value); return atoi(prop_value); } + + + template + struct tstring : public std::integer_sequence { + const char *c_str() const { + return str_; + } + + operator std::string_view() const { + return c_str(); + } + private: + constexpr static char str_[]{chars..., '\0'}; + }; + + template + inline constexpr tstring operator ""_tstr() { + return {}; + } + + + template + inline constexpr tstring + operator+(const tstring &, const tstring &) { + return {}; + } + + template + inline constexpr auto operator+(const std::string &a, const tstring &) { + return a + std::string{as..., '\0'}; + } + + template + inline constexpr auto operator+(const tstring &, const std::string &b) { + return std::string{as..., '\0'} + b; + } } + +#pragma clang diagnostic pop