diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/core/slang-rtti-util.h | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/core/slang-rtti-util.h')
| -rw-r--r-- | source/core/slang-rtti-util.h | 80 |
1 files changed, 51 insertions, 29 deletions
diff --git a/source/core/slang-rtti-util.h b/source/core/slang-rtti-util.h index 4807c5ea2..0058eaddf 100644 --- a/source/core/slang-rtti-util.h +++ b/source/core/slang-rtti-util.h @@ -25,31 +25,33 @@ // // Convert from such JSON objects using JSONToNativeConverter::convert -#define SLANG_MAKE_STRUCT_RTTI_INFO(S, ...) \ - template<> \ - struct GetRttiInfo<S> \ - { \ - static const RttiInfo* get() \ - { \ - using S_ = S; \ - const static StructRttiInfo::Field fs[] = {__VA_ARGS__}; \ - const auto ignoreUnknownFields = true; \ - const static auto ret = StructRttiInfo{ \ +#define SLANG_MAKE_STRUCT_RTTI_INFO(S, ...) \ + template<> \ + struct GetRttiInfo<S> \ + { \ + static const RttiInfo* get() \ + { \ + using S_ = S; \ + const static StructRttiInfo::Field fs[] = {__VA_ARGS__}; \ + const auto ignoreUnknownFields = true; \ + const static auto ret = StructRttiInfo{ \ {{RttiInfo::Kind::Struct, alignof(S), sizeof(S)}, #S}, \ - nullptr, \ - SLANG_COUNT_OF(fs), \ - fs, \ - ignoreUnknownFields \ - }; \ - return &ret; \ - } \ + nullptr, \ + SLANG_COUNT_OF(fs), \ + fs, \ + ignoreUnknownFields}; \ + return &ret; \ + } \ }; -#define SLANG_RTTI_FIELD_IMPL(m, name, flags) \ - {name, GetRttiInfo<decltype(S_::m)>::get(), offsetof(S_, m), flags} +#define SLANG_RTTI_FIELD_IMPL(m, name, flags) \ + { \ + name, GetRttiInfo<decltype(S_::m)>::get(), offsetof(S_, m), flags \ + } #define SLANG_RTTI_FIELD(m) SLANG_RTTI_FIELD_IMPL(m, #m, 0) #define SLANG_OPTIONAL_RTTI_FIELD(m) SLANG_RTTI_FIELD_IMPL(m, #m, StructRttiInfo::Flag::Optional) -namespace Slang { +namespace Slang +{ struct RttiUtil { @@ -64,22 +66,42 @@ struct RttiUtil static bool isDefault(RttiDefaultValue defaultValue, const RttiInfo* rttiInfo, const void* src); - /// Gets funcs for default scenarios + /// Gets funcs for default scenarios static RttiTypeFuncs getDefaultTypeFuncs(const RttiInfo* rttiInfo); - /// Set a list count - static SlangResult setListCount(RttiTypeFuncsMap* typeMap, const RttiInfo* elementType, void* dst, Index count); + /// Set a list count + static SlangResult setListCount( + RttiTypeFuncsMap* typeMap, + const RttiInfo* elementType, + void* dst, + Index count); - /// Returns if the type can be zero initialized + /// Returns if the type can be zero initialized static bool canZeroInit(const RttiInfo* type); - /// Returns true if the type needs dtor + /// Returns true if the type needs dtor static bool hasDtor(const RttiInfo* type); - /// Returns true if we can memcpy to copy + /// Returns true if we can memcpy to copy static bool canMemCpy(const RttiInfo* type); - static void ctorArray(RttiTypeFuncsMap* typeMap, const RttiInfo* rttiInfo, void* inDst, ptrdiff_t stride, Index count); - static void copyArray(RttiTypeFuncsMap* typeMap, const RttiInfo* rttiInfo, void* inDst, const void* inSrc, ptrdiff_t stride, Index count); - static void dtorArray(RttiTypeFuncsMap* typeMap, const RttiInfo* rttiInfo, void* inDst, ptrdiff_t stride, Index count); + static void ctorArray( + RttiTypeFuncsMap* typeMap, + const RttiInfo* rttiInfo, + void* inDst, + ptrdiff_t stride, + Index count); + static void copyArray( + RttiTypeFuncsMap* typeMap, + const RttiInfo* rttiInfo, + void* inDst, + const void* inSrc, + ptrdiff_t stride, + Index count); + static void dtorArray( + RttiTypeFuncsMap* typeMap, + const RttiInfo* rttiInfo, + void* inDst, + ptrdiff_t stride, + Index count); }; } // namespace Slang |
