diff options
author | Kitty Barnett <develop@catznip.com> | 2024-09-02 01:39:17 +0200 |
---|---|---|
committer | Kitty Barnett <develop@catznip.com> | 2024-09-02 01:39:17 +0200 |
commit | 7402fe6412e98e4b295ee3e04874f379c752f7a0 (patch) | |
tree | 65b3bfb411094953f7e2cac6df9d0c73462cb49e /indra/newview/rlvdefines.h | |
parent | b82e9b73d35e41ed51063905dd31ccced9e97266 (diff) |
Add basic scaffolding to support reply commands and handle @versionXXX as an illustration
Diffstat (limited to 'indra/newview/rlvdefines.h')
-rw-r--r-- | indra/newview/rlvdefines.h | 142 |
1 files changed, 97 insertions, 45 deletions
diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index 6ba2afbc69..0459b59483 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -4,32 +4,14 @@ // Defines // -namespace Rlv -{ - // Version of the specification we report - struct SpecVersion { - static constexpr S32 Major = 4; - static constexpr S32 Minor = 0; - static constexpr S32 Patch = 0; - static constexpr S32 Build = 0; - }; - - // RLVa implementation version - struct ImplVersion { - static constexpr S32 Major = 3; - static constexpr S32 Minor = 0; - static constexpr S32 Patch = 0; - static constexpr S32 ImplId = 2; /* Official viewer */ - }; -} - // Defining these makes it easier if we ever need to change our tag #define RLV_WARNS LL_WARNS("RLV") #define RLV_INFOS LL_INFOS("RLV") #define RLV_DEBUGS LL_DEBUGS("RLV") #define RLV_ENDL LL_ENDL +#define RLV_VERIFY(f) (f) -#define RLV_RELEASE +#define RLV_DEBUG #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG // Make sure we halt execution on errors #define RLV_ERRS LL_ERRS("RLV") @@ -37,18 +19,36 @@ namespace Rlv #define RLV_ASSERT(f) if (!(f)) { RLV_ERRS << "ASSERT (" << #f << ")" << RLV_ENDL; } #define RLV_ASSERT_DBG(f) RLV_ASSERT(f) #else + // Don't halt execution on errors in release + #define RLV_ERRS LL_WARNS("RLV") // We don't want to check assertions in release builds - #ifndef RLV_RELEASE + #ifdef RLV_DEBUG #define RLV_ASSERT(f) RLV_VERIFY(f) #define RLV_ASSERT_DBG(f) #else #define RLV_ASSERT(f) #define RLV_ASSERT_DBG(f) - #endif // RLV_RELEASE + #endif // RLV_DEBUG #endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG namespace Rlv { + // Version of the specification we report + namespace SpecVersion { + constexpr S32 Major = 4; + constexpr S32 Minor = 0; + constexpr S32 Patch = 0; + constexpr S32 Build = 0; + }; + + // RLVa implementation version + namespace ImplVersion { + constexpr S32 Major = 3; + constexpr S32 Minor = 0; + constexpr S32 Patch = 0; + constexpr S32 ImplId = 13; + }; + namespace Constants { constexpr char CmdPrefix = '@'; @@ -61,33 +61,84 @@ namespace Rlv namespace Rlv { - enum class ECmdRet{ - Unknown = 0x0000, // Unknown error (should only be used internally) - Retained, // Command was retained - Success = 0x0100, // Command executed successfully - SuccessUnset, // Command executed successfully (RLV_TYPE_REMOVE for an unrestricted behaviour) - SuccessDuplicate, // Command executed successfully (RLV_TYPE_ADD for an already restricted behaviour) - SuccessDeprecated, // Command executed successfully but has been marked as deprecated - SuccessDelayed, // Command parsed valid but will execute at a later time - Failed = 0x0200, // Command failed (general failure) - FailedSyntax, // Command failed (syntax error) - FailedOption, // Command failed (invalid option) - FailedParam, // Command failed (invalid param) - FailedLock, // Command failed (command is locked by another object) - FailedDisabled, // Command failed (command disabled by user) - FailedUnknown, // Command failed (unknown command) - FailedNoSharedRoot, // Command failed (missing #RLV) - FailedDeprecated, // Command failed (deprecated and no longer supported) - FailedNoBehaviour, // Command failed (force modifier on an object with no active restrictions) - FailedUnheldBehaviour, // Command failed (local modifier on an object that doesn't hold the base behaviour) - FailedBlocked, // Command failed (object is blocked) - FailedThrottled, // Command failed (throttled) - FailedNoProcessor // Command doesn't have a template processor define (legacy code) + enum class EBehaviour { + Version = 0, + VersionNew, + VersionNum, + + Count, + Unknown, }; + enum class EBehaviourOptionType + { + None, // Behaviour takes no parameters + Exception, // Behaviour requires an exception as a parameter + NoneOrException, // Behaviour takes either no parameters or an exception + }; + + enum class EParamType { + Unknown = 0x00, + Add = 0x01, // <param> == "n"|"add" + Remove = 0x02, // <param> == "y"|"rem" + Force = 0x04, // <param> == "force" + Reply = 0x08, // <param> == <number> + Clear = 0x10, + AddRem = Add | Remove + }; + + enum class ECmdRet { + Unknown = 0x0000, // Unknown error (should only be used internally) + Retained, // Command was retained + Success = 0x0100, // Command executed successfully + SuccessUnset, // Command executed successfully (RLV_TYPE_REMOVE for an unrestricted behaviour) + SuccessDuplicate, // Command executed successfully (RLV_TYPE_ADD for an already restricted behaviour) + SuccessDeprecated, // Command executed successfully but has been marked as deprecated + SuccessDelayed, // Command parsed valid but will execute at a later time + Failed = 0x0200, // Command failed (general failure) + FailedSyntax, // Command failed (syntax error) + FailedOption, // Command failed (invalid option) + FailedParam, // Command failed (invalid param) + FailedLock, // Command failed (command is locked by another object) + FailedDisabled, // Command failed (command disabled by user) + FailedUnknown, // Command failed (unknown command) + FailedNoSharedRoot, // Command failed (missing #RLV) + FailedDeprecated, // Command failed (deprecated and no longer supported) + FailedNoBehaviour, // Command failed (force modifier on an object with no active restrictions) + FailedUnheldBehaviour, // Command failed (local modifier on an object that doesn't hold the base behaviour) + FailedBlocked, // Command failed (object is blocked) + FailedThrottled, // Command failed (throttled) + FailedNoProcessor // Command doesn't have a template processor define (legacy code) + }; + + enum class EExceptionCheck + { + Permissive, // Exception can be set by any object + Strict, // Exception must be set by all objects holding the restriction + Default, // Permissive or strict will be determined by currently enforced restrictions + }; + + // Replace&remove in c++23 + template <typename E> + constexpr std::enable_if_t<std::is_enum_v<E> && !std::is_convertible_v<E, int>, std::underlying_type_t<E>> to_underlying(E e) noexcept + { + return static_cast<std::underlying_type_t<E>>(e); + } + + template <typename E> + constexpr std::enable_if_t<std::is_enum_v<E> && !std::is_convertible_v<E, int>, bool> has_flag(E value, E flag) noexcept + { + return (to_underlying(value) & to_underlying(flag)) != 0; + } + constexpr bool isReturnCodeSuccess(ECmdRet eRet) { - return (static_cast<uint16_t>(eRet) & static_cast<uint16_t>(ECmdRet::Success)) == static_cast<uint16_t>(ECmdRet::Success); + return (to_underlying(eRet) & to_underlying(ECmdRet::Success)) == to_underlying(ECmdRet::Success); + } + + constexpr bool isReturnCodeFailed(ECmdRet eRet) + { + return (to_underlying(eRet) & to_underlying(ECmdRet::Failed)) == to_underlying(ECmdRet::Failed); } } @@ -103,6 +154,7 @@ namespace Rlv constexpr char Debug[] = "RestrainedLoveDebug"; constexpr char DebugHideUnsetDup[] = "RLVaDebugHideUnsetDuplicate"; + constexpr char EnableExperimentalCommands[] = "RLVaExperimentalCommands"; constexpr char EnableIMQuery[] = "RLVaEnableIMQuery"; constexpr char EnableTempAttach[] = "RLVaEnableTemporaryAttachments"; constexpr char TopLevelMenu[] = "RLVaTopLevelMenu"; |