Skip to content

Commit 61e68d1

Browse files
committed
Improve prefix handling
1 parent bf27227 commit 61e68d1

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

include/RED4ext/Dump/Reflection-inl.hpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,34 @@ RED4EXT_INLINE void Dump(std::filesystem::path aOutPath, std::filesystem::path a
4141
{
4242
size_t i = 0;
4343

44-
constexpr std::string_view exceptions[] = {"AI", "GpuWrapApi", "GpuWrapApiVertexPacking"};
45-
46-
for (const auto& exception : exceptions)
44+
static constexpr std::pair<std::string_view, bool> uniqueNamespaces[] = {
45+
{"AI", false},
46+
{"inGame", true},
47+
{"GpuWrapApi", true},
48+
{"GpuWrapApiVertexPacking", true}
49+
};
50+
51+
for (const auto& [name, isSpecialCase] : uniqueNamespaces)
4752
{
48-
if (aInput.size() > exception.size() && aInput.starts_with(exception))
53+
if (aInput.size() > name.size() && aInput.starts_with(name))
4954
{
50-
i = exception.size();
51-
}
52-
}
55+
i = name.size();
5356

54-
// Special case for enums under `GpuWrapApi` i.e. `eTextureType`
55-
if ((aInput.starts_with("GpuWrapApi") || aInput.starts_with("GpuWrapApiVertexPacking")) && aInput[i] == 'e')
56-
{
57-
return aInput.substr(0, i);
58-
}
57+
if (isSpecialCase)
58+
{
59+
// Special case of "in", this will break directory layout for "ink", "interop", etc..
60+
if (aInput.starts_with("inGame"))
61+
{
62+
return "";
63+
}
5964

60-
// Special case of "in", this will break directory layout for "ink", "interop", etc..
61-
if (aInput.starts_with("inGame"))
62-
{
63-
return "";
65+
// Special case for enums under `GpuWrapApi` i.e. `eTextureType`
66+
if (name.starts_with("GpuWrapApi") && aInput[i] == 'e')
67+
{
68+
return aInput.substr(0, i);
69+
}
70+
}
71+
}
6472
}
6573

6674
for (; i < aInput.size(); ++i)

0 commit comments

Comments
 (0)