|
12 | 12 |
|
13 | 13 | namespace Scripting |
14 | 14 | { |
| 15 | + // Per-entry filter for LuaMethodTable::Set: entries overlapping excludeFlags are skipped. |
| 16 | + enum class LuaMethodFlags : u32 |
| 17 | + { |
| 18 | + None = 0, |
| 19 | + DeveloperOnly = 1 << 0, |
| 20 | + }; |
| 21 | + |
| 22 | + inline constexpr LuaMethodFlags operator|(LuaMethodFlags a, LuaMethodFlags b) |
| 23 | + { |
| 24 | + return static_cast<LuaMethodFlags>(static_cast<u32>(a) | static_cast<u32>(b)); |
| 25 | + } |
| 26 | + inline constexpr LuaMethodFlags operator&(LuaMethodFlags a, LuaMethodFlags b) |
| 27 | + { |
| 28 | + return static_cast<LuaMethodFlags>(static_cast<u32>(a) & static_cast<u32>(b)); |
| 29 | + } |
| 30 | + inline constexpr bool HasAnyFlag(LuaMethodFlags value, LuaMethodFlags mask) |
| 31 | + { |
| 32 | + return (value & mask) != LuaMethodFlags::None; |
| 33 | + } |
| 34 | + |
15 | 35 | template <typename UserDataType = void> |
16 | 36 | struct LuaRegister |
17 | 37 | { |
18 | 38 | public: |
19 | 39 | const char* name; |
20 | 40 | typename std::conditional<std::is_same_v<UserDataType, void>, i32(*)(Zenith*), i32(*)(Zenith*, UserDataType*)>::type func; |
| 41 | + LuaMethodFlags flags = LuaMethodFlags::None; |
21 | 42 | }; |
22 | 43 |
|
23 | 44 | template <typename UserDataType> |
@@ -112,7 +133,7 @@ namespace Scripting |
112 | 133 | } |
113 | 134 |
|
114 | 135 | template <class MethodTableUserDataType, size_t N> |
115 | | - static void Set(Zenith* zenith, const LuaRegister<MethodTableUserDataType> (&methodTable)[N], const char* globalName = nullptr) |
| 136 | + static void Set(Zenith* zenith, const LuaRegister<MethodTableUserDataType> (&methodTable)[N], const char* globalName = nullptr, LuaMethodFlags excludeFlags = LuaMethodFlags::None) |
116 | 137 | { |
117 | 138 | static_assert(std::is_same_v<UserDataType, void> || std::is_same_v<UserDataType, MethodTableUserDataType> || std::is_base_of_v<MethodTableUserDataType, UserDataType>, "LuaMetaTable::Set - LuaRegister's UserDataType must either match LuaMetaTable's UserDataType, be derived from it or be void"); |
118 | 139 | constexpr bool isGlobal = std::is_same_v<UserDataType, void>; |
@@ -147,6 +168,9 @@ namespace Scripting |
147 | 168 | { |
148 | 169 | const auto& method = methodTable[i]; |
149 | 170 |
|
| 171 | + if (HasAnyFlag(method.flags, excludeFlags)) |
| 172 | + continue; |
| 173 | + |
150 | 174 | lua_pushstring(zenith->state, method.name); |
151 | 175 |
|
152 | 176 | lua_pushlightuserdata(zenith->state, (void*)&method); |
|
0 commit comments