JNI: Fix static_assert for type registrations

Types signatures have to start with either "[L" (array of class)
or "L" (just class), and end with ";". Only "[" (array of primitive
type) makes no sense, esp since we also require a terminating
";".

Change-Id: Iea9ce992c31a34639016c967f813ebf9343c6978
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Volker Hilsheimer 2024-05-31 16:13:14 +02:00
parent 102670a82e
commit d41ae1a9a8

View File

@ -27,12 +27,12 @@ template<> \
struct QtJniTypes::Traits<QtJniTypes::Type> { \
static constexpr auto signature() \
{ \
static_assert((Signature[0] == 'L' \
|| Signature[0] == '[') \
&& Signature[sizeof(Signature) - 2] == ';', \
constexpr QtJniTypes::CTString sig(Signature); \
static_assert((sig.startsWith('L') || sig.startsWith("[L")) \
&& sig.endsWith(';'), \
"Type signature needs to start with 'L' or" \
" '[' and end with ';'"); \
return QtJniTypes::CTString(Signature); \
" '[L', and end with ';'"); \
return sig; \
} \
}; \