diff --git a/source/slang/slang-fossil.cpp b/source/slang/slang-fossil.cpp index 61354c9fa04..b5074eac6e8 100644 --- a/source/slang/slang-fossil.cpp +++ b/source/slang/slang-fossil.cpp @@ -77,8 +77,7 @@ Fossil::AnyValPtr getRootValue(void const* data, Size size) } // namespace Fossil -Fossil::AnyValRef Fossil::ValRef::getElement( - Index index) const +Fossil::AnyValRef Fossil::ValRef::getElement(Index index) const { SLANG_ASSERT(index >= 0); SLANG_ASSERT(index < getElementCount()); @@ -92,8 +91,7 @@ Fossil::AnyValRef Fossil::ValRef::getElement( return Fossil::AnyValRef(elementPtr, elementLayout); } -FossilizedRecordElementLayout* FossilizedRecordLayout::getField( - Index index) const +FossilizedRecordElementLayout* FossilizedRecordLayout::getField(Index index) const { SLANG_ASSERT(index >= 0); SLANG_ASSERT(index < fieldCount); @@ -102,8 +100,7 @@ FossilizedRecordElementLayout* FossilizedRecordLayout::getField( return fieldsPtr + index; } -Fossil::AnyValRef Fossil::ValRef::getField( - Index index) const +Fossil::AnyValRef Fossil::ValRef::getField(Index index) const { SLANG_ASSERT(index >= 0); SLANG_ASSERT(index < getFieldCount()); diff --git a/source/slang/slang-fossil.h b/source/slang/slang-fossil.h index 66793965043..b5fd9b7b550 100644 --- a/source/slang/slang-fossil.h +++ b/source/slang/slang-fossil.h @@ -69,7 +69,10 @@ struct FossilizedPtr : RelativePtr32 using Layout = FossilizedPtrLikeLayout; - SLANG_FORCE_INLINE static bool isMatchingKind(FossilizedValKind kind) { return kind == FossilizedValKind::Ptr; } + SLANG_FORCE_INLINE static bool isMatchingKind(FossilizedValKind kind) + { + return kind == FossilizedValKind::Ptr; + } }; static_assert(sizeof(FossilizedPtr) == sizeof(uint32_t)); @@ -493,30 +496,22 @@ SLANG_FORCE_INLINE int compare(FossilizedString const& lhs, UnownedStringSlice c return compare(lhs.get(), rhs); } -SLANG_FORCE_INLINE bool operator==( - FossilizedString const& left, - UnownedStringSlice const& right) +SLANG_FORCE_INLINE bool operator==(FossilizedString const& left, UnownedStringSlice const& right) { return left.get() == right; } -SLANG_FORCE_INLINE bool operator!=( - FossilizedString const& left, - UnownedStringSlice const& right) +SLANG_FORCE_INLINE bool operator!=(FossilizedString const& left, UnownedStringSlice const& right) { return left.get() != right; } -SLANG_FORCE_INLINE bool operator==( - FossilizedStringObj const& left, - UnownedStringSlice const& right) +SLANG_FORCE_INLINE bool operator==(FossilizedStringObj const& left, UnownedStringSlice const& right) { return left.get() == right; } -SLANG_FORCE_INLINE bool operator!=( - FossilizedStringObj const& left, - UnownedStringSlice const& right) +SLANG_FORCE_INLINE bool operator!=(FossilizedStringObj const& left, UnownedStringSlice const& right) { return left.get() != right; } @@ -1099,8 +1094,8 @@ struct ValRef> : ValRefBase> template SLANG_FORCE_INLINE ValPtr cast(AnyValPtr valPtr) { -// if (!valPtr) -// return ValPtr(); + // if (!valPtr) + // return ValPtr(); return ValPtr( static_cast(valPtr.getDataPtr()), (typename T::Layout*)(valPtr.getLayout())); diff --git a/source/slang/slang-serialize-ast.cpp b/source/slang/slang-serialize-ast.cpp index 09b1d8cc920..d4816657068 100644 --- a/source/slang/slang-serialize-ast.cpp +++ b/source/slang/slang-serialize-ast.cpp @@ -1,6 +1,7 @@ // slang-serialize-ast.cpp #include "slang-serialize-ast.h" +#include "core/slang-performance-profiler.h" #include "slang-ast-dispatch.h" #include "slang-check.h" #include "slang-compiler.h" @@ -10,8 +11,6 @@ #include "slang-serialize-fossil.h" #include "slang-serialize-riff.h" -#include "core/slang-performance-profiler.h" - // #include "slang-serialize-ast.cpp.fiddle" @@ -540,7 +539,7 @@ struct ASTSerialWriteContext : SourceLocSerialContext ModuleDecl* _module = nullptr; SerialSourceLocWriter* _sourceLocWriter = nullptr; - public: +public: // // For the most part, this type just implements the methods // of the `IASTSerializerImpl` interface, and then has some @@ -556,8 +555,7 @@ struct ASTSerialWriteContext : SourceLocSerialContext ContainerDeclDirectMemberDecls& value); SerialSourceLocWriter* getSourceLocWriter() { return _sourceLocWriter; } - private: - +private: void _writeImportedModule(ASTSerializer const& serializer, ModuleDecl* moduleDecl); void _writeImportedDecl( ASTSerializer const& serializer, @@ -687,7 +685,7 @@ struct ASTSerialReadContext : public SourceLocSerialContext, public RefObject Count _deserializedTopLevelDeclCount = 0; #endif - public: +public: // // Much like the `ASTSerialWriter`, for the most part this // type just implements the `IASTSerializer` interface, @@ -704,8 +702,7 @@ struct ASTSerialReadContext : public SourceLocSerialContext, public RefObject ContainerDeclDirectMemberDecls& value); SerialSourceLocReader* getSourceLocReader() { return _sourceLocReader; } - private: - +private: ModuleDecl* _readImportedModule(ASTSerializer const& serializer); NodeBase* _readImportedDecl(ASTSerializer const& serializer); diff --git a/source/slang/slang-serialize-fossil.cpp b/source/slang/slang-serialize-fossil.cpp index afcb60ad75b..3a3d8c00fbf 100644 --- a/source/slang/slang-serialize-fossil.cpp +++ b/source/slang/slang-serialize-fossil.cpp @@ -2,7 +2,6 @@ #include "slang-serialize-fossil.h" #include "../core/slang-blob.h" - #include "core/slang-performance-profiler.h" namespace Slang @@ -324,7 +323,10 @@ void SerialWriter::handleUniquePtr(void*& value, SerializerCallback callback, vo handleSharedPtr(value, callback, context); } -void SerialWriter::handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context) +void SerialWriter::handleDeferredObjectContents( + void* valuePtr, + SerializerCallback callback, + void* context) { // Because we are already deferring writing of the *entirety* of // an object's members as part of how `handleSharedPtr()` works, @@ -1367,7 +1369,10 @@ void SerialReader::handleSharedPtr(void*& value, SerializerCallback callback, vo value = objectInfo->resurrectedObjectPtr; } -void SerialReader::handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context) +void SerialReader::handleDeferredObjectContents( + void* valuePtr, + SerializerCallback callback, + void* context) { // Unlike the case in `SerialWriter::handleDeferredObjectContents()`, // we very much *do* want to delay invoking the callback until later. @@ -1577,7 +1582,7 @@ void SerialReader::_pushContainerState( auto containerDataPtr = containerObjPtr.getDataPtr(); auto containerLayout = containerObjPtr.getLayout(); - auto elementCount = (uint32_t) containerObjPtr->getElementCount(); + auto elementCount = (uint32_t)containerObjPtr->getElementCount(); FossilizedValLayout const* elementLayout = containerLayout->elementLayout; auto elementStride = containerLayout->elementStride; diff --git a/source/slang/slang-serialize-fossil.h b/source/slang/slang-serialize-fossil.h index d53e3c09a39..184831a39e2 100644 --- a/source/slang/slang-serialize-fossil.h +++ b/source/slang/slang-serialize-fossil.h @@ -36,15 +36,14 @@ namespace Fossil #define SLANG_SERIALIZE_FOSSIL_ENABLE_VALIDATION_CHECKS 1 #if SLANG_SERIALIZE_FOSSIL_ENABLE_VALIDATION_CHECKS -#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) \ - do \ - { \ - if (!(CONDITION)) \ +#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) \ + do \ + { \ + if (!(CONDITION)) \ SLANG_UNEXPECTED("invalid format encountered in serialized data"); \ } while (0) #else -#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) \ - SLANG_ASSERT(CONDITION) +#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) SLANG_ASSERT(CONDITION) #endif // A commonly-occuring kind of validation check when reading @@ -87,7 +86,6 @@ SLANG_FORCE_INLINE ValPtr expectPossiblyNullValOfType(AnyValPtr valPtr) struct SerialWriter { public: - SerialWriter(ChunkBuilder* chunk); SerialWriter(BlobBuilder& blobBuilder); @@ -635,11 +633,7 @@ struct SerialWriter void handleSharedPtr(void*& value, SerializerCallback callback, void* context); void handleUniquePtr(void*& value, SerializerCallback callback, void* context); - void handleDeferredObjectContents( - void* valuePtr, - SerializerCallback callback, - void* context) - ; + void handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context); }; /// Serializer implementation for reading objects from a fossil-format blob. @@ -744,7 +738,6 @@ struct SerialReader SLANG_FORCE_INLINE State& getState() { return _state; } public: - // // The serialization protocol allows the back-end // implementation to define a `Scope` type that will @@ -766,7 +759,6 @@ struct SerialReader }; private: - // // Like other serializer implementations for reading, we track objects // that are in the process of being read in, to avoid possible diff --git a/source/slang/slang-serialize-ir.cpp b/source/slang/slang-serialize-ir.cpp index ad50ce3c17d..594953d7e2d 100644 --- a/source/slang/slang-serialize-ir.cpp +++ b/source/slang/slang-serialize-ir.cpp @@ -4,6 +4,7 @@ #include "core/slang-blob-builder.h" #include "core/slang-common.h" #include "core/slang-dictionary.h" +#include "core/slang-performance-profiler.h" #include "slang-ir-insts-stable-names.h" #include "slang-ir-insts.h" #include "slang-ir-validate.h" @@ -14,8 +15,6 @@ #include "slang-tag-version.h" #include "slang.h" -#include "core/slang-performance-profiler.h" - // #include "slang-serialize-ir.cpp.fiddle" diff --git a/source/slang/slang-serialize-riff.h b/source/slang/slang-serialize-riff.h index fe88e830755..b305113fa3e 100644 --- a/source/slang/slang-serialize-riff.h +++ b/source/slang/slang-serialize-riff.h @@ -247,10 +247,7 @@ struct RIFFSerialWriter void handleSharedPtr(void*& value, SerializerCallback callback, void* context); void handleUniquePtr(void*& value, SerializerCallback callback, void* context); - void handleDeferredObjectContents( - void* valuePtr, - SerializerCallback callback, - void* context); + void handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context); }; /// Serializer implementation for reading from a tree of RIFF chunks. diff --git a/source/slang/slang-serialize.h b/source/slang/slang-serialize.h index db791d66b58..841bc53e5f1 100644 --- a/source/slang/slang-serialize.h +++ b/source/slang/slang-serialize.h @@ -783,34 +783,33 @@ struct ScopedSerializerOptional }; -#define SLANG_SCOPED_SERIALIZER_ARRAY(SERIALIZER) \ - ::Slang::ScopedSerializerArray> SLANG_CONCAT(_scopedSerializerArray, __LINE__)(SERIALIZER) +#define SLANG_SCOPED_SERIALIZER_ARRAY(SERIALIZER) \ + ::Slang::ScopedSerializerArray> SLANG_CONCAT( \ + _scopedSerializerArray, \ + __LINE__)(SERIALIZER) -#define SLANG_SCOPED_SERIALIZER_DICTIONARY(SERIALIZER) \ +#define SLANG_SCOPED_SERIALIZER_DICTIONARY(SERIALIZER) \ ::Slang::ScopedSerializerDictionary> \ - SLANG_CONCAT( \ - _scopedSerializerDictionary, \ - __LINE__)( \ - SERIALIZER) + SLANG_CONCAT(_scopedSerializerDictionary, __LINE__)(SERIALIZER) -#define SLANG_SCOPED_SERIALIZER_OPTIONAL(SERIALIZER) \ +#define SLANG_SCOPED_SERIALIZER_OPTIONAL(SERIALIZER) \ ::Slang::ScopedSerializerOptional> SLANG_CONCAT( \ - _scopedSerializerOptional, \ + _scopedSerializerOptional, \ __LINE__)(SERIALIZER) -#define SLANG_SCOPED_SERIALIZER_STRUCT(SERIALIZER) \ +#define SLANG_SCOPED_SERIALIZER_STRUCT(SERIALIZER) \ ::Slang::ScopedSerializerStruct> SLANG_CONCAT( \ - _scopedSerializerStruct, \ + _scopedSerializerStruct, \ __LINE__)(SERIALIZER) -#define SLANG_SCOPED_SERIALIZER_VARIANT(SERIALIZER) \ +#define SLANG_SCOPED_SERIALIZER_VARIANT(SERIALIZER) \ ::Slang::ScopedSerializerVariant> SLANG_CONCAT( \ - _scopedSerializerVariant, \ + _scopedSerializerVariant, \ __LINE__)(SERIALIZER) -#define SLANG_SCOPED_SERIALIZER_TUPLE(SERIALIZER) \ +#define SLANG_SCOPED_SERIALIZER_TUPLE(SERIALIZER) \ ::Slang::ScopedSerializerTuple> SLANG_CONCAT( \ - _scopedSerializerTuple, \ + _scopedSerializerTuple, \ __LINE__)(SERIALIZER) // @@ -1046,9 +1045,9 @@ template SLANG_FORCE_INLINE void deferSerializeObjectContents(S const& serializer, T* value) { serializer->handleDeferredObjectContents( - value, - _serializeObjectContentsCallback, - serializer.getContext()); + value, + _serializeObjectContentsCallback, + serializer.getContext()); } template @@ -1073,18 +1072,18 @@ template SLANG_FORCE_INLINE void serializeSharedPtr(S const& serializer, T*& value) { serializer->handleSharedPtr( - *(void**)&value, - _serializeObjectCallback, - serializer.getContext()); + *(void**)&value, + _serializeObjectCallback, + serializer.getContext()); } template SLANG_FORCE_INLINE void serializeUniquePtr(S const& serializer, T*& value) { serializer->handleUniquePtr( - *(void**)&value, - _serializeObjectCallback, - serializer.getContext()); + *(void**)&value, + _serializeObjectCallback, + serializer.getContext()); } template