diff options
Diffstat (limited to 'source/core')
25 files changed, 484 insertions, 216 deletions
diff --git a/source/core/slang-byte-encode-util.cpp b/source/core/slang-byte-encode-util.cpp index acafdf2b4..f3f375c60 100644 --- a/source/core/slang-byte-encode-util.cpp +++ b/source/core/slang-byte-encode-util.cpp @@ -210,20 +210,31 @@ SLANG_FORCE_INLINE static uint32_t _decodeLiteCut2UInt32(const uint8_t* in, int #if SLANG_BYTE_ENCODE_USE_UNALIGNED_ACCESS switch (numBytesRemaining) { - case 2: value = *(const uint16_t*)in; break; - case 3: value = (uint32_t(in[2]) << 16) | (uint32_t(in[1]) << 8) | uint32_t(in[0]); break; - case 4: value = *(const uint32_t*)in; break; - default: break; + case 2: + value = *(const uint16_t*)in; + break; + case 3: + value = (uint32_t(in[2]) << 16) | (uint32_t(in[1]) << 8) | uint32_t(in[0]); + break; + case 4: + value = *(const uint32_t*)in; + break; + default: + break; } #else // This works on all cpus although slower value = in[0]; switch (numBytesRemaining) { - case 4: value |= uint32_t(in[3]) << 24; /* fall thru */ - case 3: value |= uint32_t(in[2]) << 16; /* fall thru */ - case 2: value |= uint32_t(in[1]) << 8; /* fall thru */ - case 1: break; + case 4: + value |= uint32_t(in[3]) << 24; /* fall thru */ + case 3: + value |= uint32_t(in[2]) << 16; /* fall thru */ + case 2: + value |= uint32_t(in[1]) << 8; /* fall thru */ + case 1: + break; } #endif return value; diff --git a/source/core/slang-command-options-writer.cpp b/source/core/slang-command-options-writer.cpp index f46bcc56c..9135998af 100644 --- a/source/core/slang-command-options-writer.cpp +++ b/source/core/slang-command-options-writer.cpp @@ -109,7 +109,8 @@ static bool _needsMarkdownEscape(const UnownedStringSlice& text) { return true; } - default: break; + default: + break; } } @@ -125,12 +126,23 @@ void _appendEscapedMarkdown(const UnownedStringSlice& text, StringBuilder& ioBuf { switch (c) { - case '<': ioBuf << "<"; break; - case '>': ioBuf << ">"; break; - case '&': ioBuf << "&"; break; - case '[': ioBuf << "\\["; break; - case ']': ioBuf << "\\]"; break; - default: ioBuf << c; + case '<': + ioBuf << "<"; + break; + case '>': + ioBuf << ">"; + break; + case '&': + ioBuf << "&"; + break; + case '[': + ioBuf << "\\["; + break; + case ']': + ioBuf << "\\]"; + break; + default: + ioBuf << c; } } } diff --git a/source/core/slang-file-system.cpp b/source/core/slang-file-system.cpp index 3e129f7bf..309b8c128 100644 --- a/source/core/slang-file-system.cpp +++ b/source/core/slang-file-system.cpp @@ -225,9 +225,14 @@ SlangResult OSFileSystem::enumeratePathContents( SlangPathType pathType; switch (type) { - case Path::Type::File: pathType = SLANG_PATH_TYPE_FILE; break; - case Path::Type::Directory: pathType = SLANG_PATH_TYPE_DIRECTORY; break; - default: return; + case Path::Type::File: + pathType = SLANG_PATH_TYPE_FILE; + break; + case Path::Type::Directory: + pathType = SLANG_PATH_TYPE_DIRECTORY; + break; + default: + return; } m_callback(pathType, m_buffer.getBuffer(), m_userData); @@ -298,9 +303,12 @@ SlangResult OSFileSystem::createDirectory(const char* path) } switch (res) { - case SLANG_E_CANNOT_OPEN: return CompressedResult::CannotOpen; - case SLANG_E_NOT_FOUND: return CompressedResult::NotFound; - default: return CompressedResult::Fail; + case SLANG_E_CANNOT_OPEN: + return CompressedResult::CannotOpen; + case SLANG_E_NOT_FOUND: + return CompressedResult::NotFound; + default: + return CompressedResult::Fail; } } @@ -377,7 +385,8 @@ void CacheFileSystem::setInnerFileSystem( : UniqueIdentityMode::SimplifyPathAndHash; break; } - default: break; + default: + break; } if (pathStyle == PathStyle::Default) @@ -779,9 +788,12 @@ SlangResult CacheFileSystem::getPath(PathKind kind, const char* path, ISlangBlob { switch (kind) { - case PathKind::Simplified: return _getSimplifiedPath(path, outPath); - case PathKind::Canonical: return _getCanonicalPath(path, outPath); - default: break; + case PathKind::Simplified: + return _getSimplifiedPath(path, outPath); + case PathKind::Canonical: + return _getCanonicalPath(path, outPath); + default: + break; } if (m_fileSystemExt) @@ -813,7 +825,8 @@ SlangResult CacheFileSystem::_getSimplifiedPath(const char* path, ISlangBlob** o *outSimplifiedPath = StringUtil::createStringBlob(simplifiedPath).detach(); return SLANG_OK; } - default: return SLANG_E_NOT_IMPLEMENTED; + default: + return SLANG_E_NOT_IMPLEMENTED; } } diff --git a/source/core/slang-http.cpp b/source/core/slang-http.cpp index fa7ca952b..ec1ccc0a2 100644 --- a/source/core/slang-http.cpp +++ b/source/core/slang-http.cpp @@ -247,9 +247,12 @@ SlangResult HTTPPacketConnection::update() { switch (m_readState) { - case ReadState::Closed: return SLANG_OK; - case ReadState::Error: return m_readResult; - default: break; + case ReadState::Closed: + return SLANG_OK; + case ReadState::Error: + return m_readResult; + default: + break; } SLANG_RETURN_ON_FAIL(_updateReadResult(m_readStream->update())); @@ -287,7 +290,8 @@ SlangResult HTTPPacketConnection::update() _handleContent(); break; } - default: break; + default: + break; } return m_readResult; diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 25c4c9389..7bfde7bd7 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -381,7 +381,8 @@ String Path::combine(const String& path1, const String& path2, const String& pat return element[1] == ':' && ((firstChar >= 'a' && firstChar <= 'z') || (firstChar >= 'A' && firstChar <= 'Z')); } - default: return false; + default: + return false; } } @@ -783,7 +784,8 @@ SlangResult Path::remove(const String& path) } break; } - default: break; + default: + break; } return SLANG_FAIL; @@ -1025,13 +1027,15 @@ static SlangResult _calcExectuablePath(char* outPath, size_t* ioSize) uint32_t size = uint32_t(*ioSize); switch (_NSGetExecutablePath(outPath, &size)) { - case 0: return SLANG_OK; + case 0: + return SLANG_OK; case -1: { *ioSize = size; return SLANG_E_BUFFER_TOO_SMALL; } - default: break; + default: + break; } return SLANG_FAIL; #else diff --git a/source/core/slang-memory-file-system.cpp b/source/core/slang-memory-file-system.cpp index 2bca497e2..534f226d0 100644 --- a/source/core/slang-memory-file-system.cpp +++ b/source/core/slang-memory-file-system.cpp @@ -156,7 +156,8 @@ SlangResult MemoryFileSystem::getPath(PathKind kind, const char* path, ISlangBlo *outPath = StringBlob::moveCreate(buffer).detach(); return SLANG_OK; } - default: break; + default: + break; } return SLANG_E_NOT_AVAILABLE; } diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index ea8a2f4a5..79b883e39 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -138,7 +138,8 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); { return SLANG_E_CANNOT_OPEN; } - default: break; + default: + break; } // Turn to Result, if not one of the well known errors return HRESULT_FROM_WIN32(lastError); diff --git a/source/core/slang-render-api-util.cpp b/source/core/slang-render-api-util.cpp index 476188abd..1e77c2ac6 100644 --- a/source/core/slang-render-api-util.cpp +++ b/source/core/slang-render-api-util.cpp @@ -183,7 +183,8 @@ static Token nextToken(Slang::UnownedStringSlice& textInOut, Slang::UnownedStrin SLANG_RETURN_ON_FAIL(findApiFlagsByName(lexeme, &apiFlags)); break; } - default: return SLANG_FAIL; + default: + return SLANG_FAIL; } while (true) @@ -196,8 +197,10 @@ static Token nextToken(Slang::UnownedStringSlice& textInOut, Slang::UnownedStrin *apiFlagsOut = apiFlags; return SLANG_OK; } - case Token::eOp: break; - default: return SLANG_FAIL; + case Token::eOp: + break; + default: + return SLANG_FAIL; } const char op = lexeme[0]; @@ -276,10 +279,13 @@ static bool _canLoadSharedLibrary(const char* libName) return _canLoadSharedLibrary("webgpu_dawn") && _canLoadSharedLibrary("dxcompiler") && _canLoadSharedLibrary("dxil"); #elif SLANG_APPLE_FAMILY - case RenderApiType::Vulkan: return true; - case RenderApiType::Metal: return true; + case RenderApiType::Vulkan: + return true; + case RenderApiType::Metal: + return true; #elif SLANG_UNIX_FAMILY - case RenderApiType::Vulkan: return true; + case RenderApiType::Vulkan: + return true; #endif #if SLANG_ENABLE_DIRECTX @@ -289,10 +295,13 @@ static bool _canLoadSharedLibrary(const char* libName) return _canLoadSharedLibrary(SLANG_ENABLE_VKD3D ? "vkd3d-proton-d3d12" : "d3d12"); #endif - case RenderApiType::CPU: return true; + case RenderApiType::CPU: + return true; // We'll assume CUDA is available, and if not, trying to create it will detect it - case RenderApiType::CUDA: return true; - default: break; + case RenderApiType::CUDA: + return true; + default: + break; } return false; } diff --git a/source/core/slang-riff-file-system.cpp b/source/core/slang-riff-file-system.cpp index b290ee5e5..7da076974 100644 --- a/source/core/slang-riff-file-system.cpp +++ b/source/core/slang-riff-file-system.cpp @@ -155,7 +155,8 @@ SlangResult RiffFileSystem::loadArchive(const void* archive, size_t archiveSizeI m_compressionSystem = LZ4CompressionSystem::getSingleton(); break; } - default: return SLANG_FAIL; + default: + return SLANG_FAIL; } // Read all of the contained data @@ -209,8 +210,10 @@ SlangResult RiffFileSystem::loadArchive(const void* archive, size_t archiveSizeI dstEntry.m_contents = RawBlob::create(srcData, srcEntry->compressedSize); break; } - case SLANG_PATH_TYPE_DIRECTORY: break; - default: return SLANG_FAIL; + case SLANG_PATH_TYPE_DIRECTORY: + break; + default: + return SLANG_FAIL; } // If it's the root entry we can ignore (as already added) diff --git a/source/core/slang-riff.cpp b/source/core/slang-riff.cpp index 94cd2038e..0eb0381e1 100644 --- a/source/core/slang-riff.cpp +++ b/source/core/slang-riff.cpp @@ -279,7 +279,8 @@ struct DumpVisitor : public RiffContainer::Visitor SLANG_RETURN_ON_FAIL(stream->write(trailing, remainingSize)); } } - default: break; + default: + break; } // Next @@ -411,7 +412,8 @@ SlangResult RiffContainer::Chunk::visit(Visitor* visitor) SLANG_RETURN_ON_FAIL(visitor->leaveList(list)); return SLANG_OK; } - default: return SLANG_FAIL; + default: + return SLANG_FAIL; } } @@ -438,7 +440,8 @@ SlangResult RiffContainer::Chunk::visitPreOrder(VisitorCallback callback, void* } return SLANG_OK; } - default: return SLANG_FAIL; + default: + return SLANG_FAIL; } } @@ -465,7 +468,8 @@ SlangResult RiffContainer::Chunk::visitPostOrder(VisitorCallback callback, void* SLANG_RETURN_ON_FAIL(callback(this, data)); return SLANG_OK; } - default: return SLANG_FAIL; + default: + return SLANG_FAIL; } } @@ -473,9 +477,12 @@ size_t RiffContainer::Chunk::calcPayloadSize() { switch (m_kind) { - case Kind::Data: return static_cast<DataChunk*>(this)->calcPayloadSize(); - case Kind::List: return static_cast<ListChunk*>(this)->calcPayloadSize(); - default: return 0; + case Kind::Data: + return static_cast<DataChunk*>(this)->calcPayloadSize(); + case Kind::List: + return static_cast<ListChunk*>(this)->calcPayloadSize(); + default: + return 0; } } diff --git a/source/core/slang-rtti-info.cpp b/source/core/slang-rtti-info.cpp index 9ca1c19b6..070b9c204 100644 --- a/source/core/slang-rtti-info.cpp +++ b/source/core/slang-rtti-info.cpp @@ -109,15 +109,33 @@ static void _appendFixedArray(const FixedArrayRttiInfo* inFixedArray, StringBuil { switch (info->m_kind) { - case RttiInfo::Kind::I32: out << "int32_t"; break; - case RttiInfo::Kind::U32: out << "uint32_t"; break; - case RttiInfo::Kind::I64: out << "int64_t"; break; - case RttiInfo::Kind::U64: out << "uint64_t"; break; - case RttiInfo::Kind::F32: out << "float"; break; - case RttiInfo::Kind::F64: out << "double"; break; - case RttiInfo::Kind::Bool: out << "bool"; break; - case RttiInfo::Kind::String: out << "String"; break; - case RttiInfo::Kind::UnownedStringSlice: out << "UnownedStringSlice"; break; + case RttiInfo::Kind::I32: + out << "int32_t"; + break; + case RttiInfo::Kind::U32: + out << "uint32_t"; + break; + case RttiInfo::Kind::I64: + out << "int64_t"; + break; + case RttiInfo::Kind::U64: + out << "uint64_t"; + break; + case RttiInfo::Kind::F32: + out << "float"; + break; + case RttiInfo::Kind::F64: + out << "double"; + break; + case RttiInfo::Kind::Bool: + out << "bool"; + break; + case RttiInfo::Kind::String: + out << "String"; + break; + case RttiInfo::Kind::UnownedStringSlice: + out << "UnownedStringSlice"; + break; case RttiInfo::Kind::Ptr: { const PtrRttiInfo* ptrRttiInfo = static_cast<const PtrRttiInfo*>(info); diff --git a/source/core/slang-rtti-util.cpp b/source/core/slang-rtti-util.cpp index 701c90e2f..92f45a3bf 100644 --- a/source/core/slang-rtti-util.cpp +++ b/source/core/slang-rtti-util.cpp @@ -315,22 +315,30 @@ RttiTypeFuncs RttiUtil::getDefaultTypeFuncs(const RttiInfo* rttiInfo) { switch (rttiInfo->m_size) { - case 1: return GetRttiTypeFuncsForZeroPod<uint8_t>::getFuncs(); - case 2: return GetRttiTypeFuncsForZeroPod<uint16_t>::getFuncs(); - case 4: return GetRttiTypeFuncsForZeroPod<uint32_t>::getFuncs(); - case 8: return GetRttiTypeFuncsForZeroPod<uint64_t>::getFuncs(); + case 1: + return GetRttiTypeFuncsForZeroPod<uint8_t>::getFuncs(); + case 2: + return GetRttiTypeFuncsForZeroPod<uint16_t>::getFuncs(); + case 4: + return GetRttiTypeFuncsForZeroPod<uint32_t>::getFuncs(); + case 8: + return GetRttiTypeFuncsForZeroPod<uint64_t>::getFuncs(); } return RttiTypeFuncs::makeEmpty(); } switch (rttiInfo->m_kind) { - case RttiInfo::Kind::String: return GetRttiTypeFuncs<String>::getFuncs(); + case RttiInfo::Kind::String: + return GetRttiTypeFuncs<String>::getFuncs(); case RttiInfo::Kind::UnownedStringSlice: return GetRttiTypeFuncs<UnownedStringSlice>::getFuncs(); - case RttiInfo::Kind::List: return ListFuncs::getFuncs(); - case RttiInfo::Kind::Struct: return StructArrayFuncs::getFuncs(); - default: break; + case RttiInfo::Kind::List: + return ListFuncs::getFuncs(); + case RttiInfo::Kind::Struct: + return StructArrayFuncs::getFuncs(); + default: + break; } return RttiTypeFuncs::makeEmpty(); @@ -344,11 +352,20 @@ RttiTypeFuncs RttiUtil::getDefaultTypeFuncs(const RttiInfo* rttiInfo) // Passing in rttiInfo allows for other more complex types to be econverted switch (rttiInfo->m_kind) { - case RttiInfo::Kind::I32: *(int32_t*)dst = int32_t(value); break; - case RttiInfo::Kind::U32: *(uint32_t*)dst = uint32_t(value); break; - case RttiInfo::Kind::I64: *(int64_t*)dst = int64_t(value); break; - case RttiInfo::Kind::U64: *(uint64_t*)dst = uint64_t(value); break; - default: return SLANG_FAIL; + case RttiInfo::Kind::I32: + *(int32_t*)dst = int32_t(value); + break; + case RttiInfo::Kind::U32: + *(uint32_t*)dst = uint32_t(value); + break; + case RttiInfo::Kind::I64: + *(int64_t*)dst = int64_t(value); + break; + case RttiInfo::Kind::U64: + *(uint64_t*)dst = uint64_t(value); + break; + default: + return SLANG_FAIL; } return SLANG_OK; } @@ -359,11 +376,16 @@ RttiTypeFuncs RttiUtil::getDefaultTypeFuncs(const RttiInfo* rttiInfo) switch (rttiInfo->m_kind) { - case RttiInfo::Kind::I32: return *(const int32_t*)src; - case RttiInfo::Kind::U32: return *(const uint32_t*)src; - case RttiInfo::Kind::I64: return *(const int64_t*)src; - case RttiInfo::Kind::U64: return *(const uint64_t*)src; - default: break; + case RttiInfo::Kind::I32: + return *(const int32_t*)src; + case RttiInfo::Kind::U32: + return *(const uint32_t*)src; + case RttiInfo::Kind::I64: + return *(const int64_t*)src; + case RttiInfo::Kind::U64: + return *(const uint64_t*)src; + default: + break; } SLANG_ASSERT(!"Not integral!"); @@ -380,9 +402,12 @@ RttiTypeFuncs RttiUtil::getDefaultTypeFuncs(const RttiInfo* rttiInfo) { switch (rttiInfo->m_kind) { - case RttiInfo::Kind::F32: return *(const float*)src; - case RttiInfo::Kind::F64: return *(const double*)src; - default: break; + case RttiInfo::Kind::F32: + return *(const float*)src; + case RttiInfo::Kind::F64: + return *(const double*)src; + default: + break; } } @@ -400,9 +425,14 @@ RttiTypeFuncs RttiUtil::getDefaultTypeFuncs(const RttiInfo* rttiInfo) { switch (rttiInfo->m_kind) { - case RttiInfo::Kind::F32: *(float*)dst = float(v); return SLANG_OK; - case RttiInfo::Kind::F64: *(double*)dst = v; return SLANG_OK; - default: break; + case RttiInfo::Kind::F32: + *(float*)dst = float(v); + return SLANG_OK; + case RttiInfo::Kind::F64: + *(double*)dst = v; + return SLANG_OK; + default: + break; } } @@ -434,9 +464,12 @@ static int64_t _getIntDefaultValue(RttiDefaultValue value) switch (value) { default: - case RttiDefaultValue::Normal: return 0; - case RttiDefaultValue::One: return 1; - case RttiDefaultValue::MinusOne: return -1; + case RttiDefaultValue::Normal: + return 0; + case RttiDefaultValue::One: + return 1; + case RttiDefaultValue::MinusOne: + return -1; } } @@ -487,8 +520,10 @@ static bool _isStructDefault(const StructRttiInfo* type, const void* src) switch (rttiInfo->m_kind) { - case RttiInfo::Kind::Invalid: return true; - case RttiInfo::Kind::Bool: return *(const bool*)src == (_getIntDefaultValue(defaultValue) != 0); + case RttiInfo::Kind::Invalid: + return true; + case RttiInfo::Kind::Bool: + return *(const bool*)src == (_getIntDefaultValue(defaultValue) != 0); case RttiInfo::Kind::String: { return ((const String*)src)->getLength() == 0; diff --git a/source/core/slang-semantic-version.cpp b/source/core/slang-semantic-version.cpp index ab7b5007b..b05eb503f 100644 --- a/source/core/slang-semantic-version.cpp +++ b/source/core/slang-semantic-version.cpp @@ -152,7 +152,8 @@ void SemanticVersion::append(StringBuilder& buf) const matchVersion.m_version.m_patch + 1); break; } - default: break; + default: + break; } List<SemanticVersion> sortedVersions; @@ -198,9 +199,15 @@ void MatchSemanticVersion::append(StringBuilder& buf) const switch (m_kind) { default: - case Kind::Unknown: buf << "unknown"; break; - case Kind::Past: buf << "past"; break; - case Kind::Future: buf << "future"; break; + case Kind::Unknown: + buf << "unknown"; + break; + case Kind::Past: + buf << "past"; + break; + case Kind::Future: + buf << "future"; + break; case Kind::Major: { buf << m_version.m_major; diff --git a/source/core/slang-signal.cpp b/source/core/slang-signal.cpp index 1600183e7..4ae75eb0e 100644 --- a/source/core/slang-signal.cpp +++ b/source/core/slang-signal.cpp @@ -10,13 +10,20 @@ static const char* _getSignalTypeAsText(SignalType type) { switch (type) { - case SignalType::AssertFailure: return "assert failure"; - case SignalType::Unimplemented: return "unimplemented"; - case SignalType::Unreachable: return "hit unreachable code"; - case SignalType::Unexpected: return "unexpected"; - case SignalType::InvalidOperation: return "invalid operation"; - case SignalType::AbortCompilation: return "abort compilation"; - default: return "unhandled"; + case SignalType::AssertFailure: + return "assert failure"; + case SignalType::Unimplemented: + return "unimplemented"; + case SignalType::Unreachable: + return "hit unreachable code"; + case SignalType::Unexpected: + return "unexpected"; + case SignalType::InvalidOperation: + return "invalid operation"; + case SignalType::AbortCompilation: + return "abort compilation"; + default: + return "unhandled"; } } @@ -50,9 +57,12 @@ String _getMessage(SignalType type, char const* message) #if SLANG_HAS_EXCEPTIONS switch (type) { - case SignalType::InvalidOperation: throw InvalidOperationException(_getMessage(type, message)); - case SignalType::AbortCompilation: throw AbortCompilationException(_getMessage(type, message)); - default: throw InternalError(_getMessage(type, message)); + case SignalType::InvalidOperation: + throw InvalidOperationException(_getMessage(type, message)); + case SignalType::AbortCompilation: + throw AbortCompilationException(_getMessage(type, message)); + default: + throw InternalError(_getMessage(type, message)); } #else // Attempt to drop out into the debugger. If a debugger isn't attached this will likely crash - diff --git a/source/core/slang-stream.cpp b/source/core/slang-stream.cpp index ca7528f61..6af3f959e 100644 --- a/source/core/slang-stream.cpp +++ b/source/core/slang-stream.cpp @@ -123,7 +123,8 @@ SlangResult FileStream::_init( mode = "ab"; } break; - default: break; + default: + break; } #ifdef _WIN32 @@ -144,11 +145,21 @@ SlangResult FileStream::_init( int shFlag = _SH_DENYRW; switch (share) { - case FileShare::None: shFlag = _SH_DENYRW; break; - case FileShare::ReadOnly: shFlag = _SH_DENYWR; break; - case FileShare::WriteOnly: shFlag = _SH_DENYRD; break; - case FileShare::ReadWrite: shFlag = _SH_DENYNO; break; - default: SLANG_ASSERT(!"Invalid file share mode."); return SLANG_FAIL; + case FileShare::None: + shFlag = _SH_DENYRW; + break; + case FileShare::ReadOnly: + shFlag = _SH_DENYWR; + break; + case FileShare::WriteOnly: + shFlag = _SH_DENYRD; + break; + case FileShare::ReadWrite: + shFlag = _SH_DENYNO; + break; + default: + SLANG_ASSERT(!"Invalid file share mode."); + return SLANG_FAIL; } if (share == FileShare::None) #pragma warning(suppress : 4996) @@ -193,10 +204,18 @@ SlangResult FileStream::seek(SeekOrigin seekOrigin, Int64 offset) int fseekOrigin; switch (seekOrigin) { - case SeekOrigin::Start: fseekOrigin = SEEK_SET; break; - case SeekOrigin::End: fseekOrigin = SEEK_END; break; - case SeekOrigin::Current: fseekOrigin = SEEK_CUR; break; - default: SLANG_ASSERT(!"Unsupported seek origin."); return SLANG_FAIL; + case SeekOrigin::Start: + fseekOrigin = SEEK_SET; + break; + case SeekOrigin::End: + fseekOrigin = SEEK_END; + break; + case SeekOrigin::Current: + fseekOrigin = SEEK_CUR; + break; + default: + SLANG_ASSERT(!"Unsupported seek origin."); + return SLANG_FAIL; } // If endReached is intended to be like feof - then doing a seek will reset it @@ -285,10 +304,18 @@ SlangResult MemoryStreamBase::seek(SeekOrigin origin, Int64 offset) Int64 pos = 0; switch (origin) { - case SeekOrigin::Start: pos = offset; break; - case SeekOrigin::End: pos = Int64(m_contentsSize) + offset; break; - case SeekOrigin::Current: pos = Int64(m_position) + offset; break; - default: SLANG_ASSERT(!"Unsupported seek origin."); return SLANG_E_NOT_IMPLEMENTED; + case SeekOrigin::Start: + pos = offset; + break; + case SeekOrigin::End: + pos = Int64(m_contentsSize) + offset; + break; + case SeekOrigin::Current: + pos = Int64(m_position) + offset; + break; + default: + SLANG_ASSERT(!"Unsupported seek origin."); + return SLANG_E_NOT_IMPLEMENTED; } m_atEnd = false; @@ -682,10 +709,14 @@ static FILE* _getFileFromStdStreamType(StdStreamType stdStream) { switch (stdStream) { - case StdStreamType::ErrorOut: return stderr; - case StdStreamType::Out: return stdout; - case StdStreamType::In: return stdin; - default: return nullptr; + case StdStreamType::ErrorOut: + return stderr; + case StdStreamType::Out: + return stdout; + case StdStreamType::In: + return stdin; + default: + return nullptr; } } @@ -693,10 +724,13 @@ static int _getBufferOptions(StreamBufferStyle style) { switch (style) { - case StreamBufferStyle::None: return _IONBF; - case StreamBufferStyle::Line: return _IOLBF; + case StreamBufferStyle::None: + return _IONBF; + case StreamBufferStyle::Line: + return _IOLBF; default: - case StreamBufferStyle::Full: return _IOFBF; + case StreamBufferStyle::Full: + return _IOFBF; } } diff --git a/source/core/slang-string-escape-util.cpp b/source/core/slang-string-escape-util.cpp index a6a70ce76..42e757b23 100644 --- a/source/core/slang-string-escape-util.cpp +++ b/source/core/slang-string-escape-util.cpp @@ -141,17 +141,28 @@ static char _getCppEscapedChar(char c) { switch (c) { - case '\b': return 'b'; - case '\f': return 'f'; - case '\n': return 'n'; - case '\r': return 'r'; - case '\a': return 'a'; - case '\t': return 't'; - case '\v': return 'v'; - case '\'': return '\''; - case '\"': return '"'; - case '\\': return '\\'; - default: return 0; + case '\b': + return 'b'; + case '\f': + return 'f'; + case '\n': + return 'n'; + case '\r': + return 'r'; + case '\a': + return 'a'; + case '\t': + return 't'; + case '\v': + return 'v'; + case '\'': + return '\''; + case '\"': + return '"'; + case '\\': + return '\\'; + default: + return 0; } } @@ -159,17 +170,28 @@ static char _getCppUnescapedChar(char c) { switch (c) { - case 'b': return '\b'; - case 'f': return '\f'; - case 'n': return '\n'; - case 'r': return '\r'; - case 'a': return '\a'; - case 't': return '\t'; - case 'v': return '\v'; - case '\'': return '\''; - case '\"': return '"'; - case '\\': return '\\'; - default: return 0; + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 'a': + return '\a'; + case 't': + return '\t'; + case 'v': + return '\v'; + case '\'': + return '\''; + case '\"': + return '"'; + case '\\': + return '\\'; + default: + return 0; } } @@ -669,7 +691,8 @@ SlangResult JSONStringEscapeHandler::lexQuoted(const char* cursor, const char** switch (c) { - case 0: return SLANG_FAIL; + case 0: + return SLANG_FAIL; case '"': { *outCursor = cursor; @@ -708,7 +731,8 @@ SlangResult JSONStringEscapeHandler::lexQuoted(const char* cursor, const char** } } // Somewhat surprisingly it appears it's valid to have \r\n inside of quotes. - default: break; + default: + break; } } } @@ -717,15 +741,24 @@ static char _getJSONEscapedChar(char c) { switch (c) { - case '\b': return 'b'; - case '\f': return 'f'; - case '\n': return 'n'; - case '\r': return 'r'; - case '\t': return 't'; - case '\\': return '\\'; - case '/': return '/'; - case '"': return '"'; - default: return 0; + case '\b': + return 'b'; + case '\f': + return 'f'; + case '\n': + return 'n'; + case '\r': + return 'r'; + case '\t': + return 't'; + case '\\': + return '\\'; + case '/': + return '/'; + case '"': + return '"'; + default: + return 0; } } @@ -733,15 +766,24 @@ static char _getJSONUnescapedChar(char c) { switch (c) { - case 'b': return '\b'; - case 'f': return '\f'; - case 'n': return '\n'; - case 'r': return '\r'; - case 't': return '\t'; - case '\\': return '\\'; - case '/': return '/'; - case '"': return '"'; - default: return 0; + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + case '\\': + return '\\'; + case '/': + return '/'; + case '"': + return '"'; + default: + return 0; } } @@ -997,14 +1039,19 @@ StringEscapeUtil::Handler* StringEscapeUtil::getHandler(Style style) { switch (style) { - case Style::Cpp: return &g_cppHandler; - case Style::Space: return &g_spaceHandler; - case Style::JSON: return &g_jsonHandler; + case Style::Cpp: + return &g_cppHandler; + case Style::Space: + return &g_spaceHandler; + case Style::JSON: + return &g_jsonHandler; // TODO(JS): For now we make Slang language string encoding/decoding the same as C++ // That may not be desirable because C++ has a variety of surprising edge cases (for example // around \x) - case Style::Slang: return &g_cppHandler; - default: return nullptr; + case Style::Slang: + return &g_cppHandler; + default: + return nullptr; } } diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index 1f67089a5..6f1dc2ccb 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -577,7 +577,8 @@ String StringUtil::replaceAll( outLine = UnownedStringSlice(begin, lineEnd); return true; } - default: break; + default: + break; } } diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index b58d466fa..e9804eaa8 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -367,11 +367,16 @@ OSString String::toWString(Index* outLength) const List<Byte> buf; switch (sizeof(wchar_t)) { - case 2: Slang::CharEncoding::UTF16->encode(getUnownedSlice(), buf); break; + case 2: + Slang::CharEncoding::UTF16->encode(getUnownedSlice(), buf); + break; - case 4: Slang::CharEncoding::UTF32->encode(getUnownedSlice(), buf); break; + case 4: + Slang::CharEncoding::UTF32->encode(getUnownedSlice(), buf); + break; - default: break; + default: + break; } auto length = Index(buf.getCount() / sizeof(wchar_t)); @@ -688,9 +693,12 @@ Index UnownedStringSlice::indexOf(const UnownedStringSlice& in) const const char* inChars = in.m_begin; switch (inLen) { - case 0: return 0; - case 1: return indexOf(inChars[0]); - default: break; + case 0: + return 0; + case 1: + return indexOf(inChars[0]); + default: + break; } const char* chars = m_begin; diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp index a71048f10..06a94bb9d 100644 --- a/source/core/slang-test-tool-util.cpp +++ b/source/core/slang-test-tool-util.cpp @@ -12,10 +12,14 @@ namespace Slang { switch (res) { - case SLANG_OK: return ToolReturnCode::Success; - case SLANG_E_INTERNAL_FAIL: return ToolReturnCode::CompilationFailed; - case SLANG_FAIL: return ToolReturnCode::Failed; - case SLANG_E_NOT_AVAILABLE: return ToolReturnCode::Ignored; + case SLANG_OK: + return ToolReturnCode::Success; + case SLANG_E_INTERNAL_FAIL: + return ToolReturnCode::CompilationFailed; + case SLANG_FAIL: + return ToolReturnCode::Failed; + case SLANG_E_NOT_AVAILABLE: + return ToolReturnCode::Ignored; default: { return (SLANG_SUCCEEDED(res)) ? ToolReturnCode::Success : ToolReturnCode::Failed; diff --git a/source/core/slang-token-reader.cpp b/source/core/slang-token-reader.cpp index d37ee0ed4..1dcce0655 100644 --- a/source/core/slang-token-reader.cpp +++ b/source/core/slang-token-reader.cpp @@ -369,12 +369,24 @@ List<Token> TokenizeText(const String& fileName, const String& text) { case '\\': case '\"': - case '\'': tokenBuilder.append(nextChar); break; - case 't': tokenBuilder.append('\t'); break; - case 's': tokenBuilder.append(' '); break; - case 'n': tokenBuilder.append('\n'); break; - case 'r': tokenBuilder.append('\r'); break; - case 'b': tokenBuilder.append('\b'); break; + case '\'': + tokenBuilder.append(nextChar); + break; + case 't': + tokenBuilder.append('\t'); + break; + case 's': + tokenBuilder.append(' '); + break; + case 'n': + tokenBuilder.append('\n'); + break; + case 'r': + tokenBuilder.append('\r'); + break; + case 'b': + tokenBuilder.append('\b'); + break; } }; while (pos <= text.getLength()) diff --git a/source/core/slang-type-convert-util.cpp b/source/core/slang-type-convert-util.cpp index 3eb053726..db59215b5 100644 --- a/source/core/slang-type-convert-util.cpp +++ b/source/core/slang-type-convert-util.cpp @@ -13,14 +13,22 @@ namespace Slang { return SLANG_SOURCE_LANGUAGE_GLSL; } - case SLANG_HLSL: return SLANG_SOURCE_LANGUAGE_HLSL; - case SLANG_C_SOURCE: return SLANG_SOURCE_LANGUAGE_C; - case SLANG_CPP_SOURCE: return SLANG_SOURCE_LANGUAGE_CPP; - case SLANG_CPP_PYTORCH_BINDING: return SLANG_SOURCE_LANGUAGE_CPP; - case SLANG_HOST_CPP_SOURCE: return SLANG_SOURCE_LANGUAGE_CPP; - case SLANG_CUDA_SOURCE: return SLANG_SOURCE_LANGUAGE_CUDA; - case SLANG_WGSL: return SLANG_SOURCE_LANGUAGE_WGSL; - default: break; + case SLANG_HLSL: + return SLANG_SOURCE_LANGUAGE_HLSL; + case SLANG_C_SOURCE: + return SLANG_SOURCE_LANGUAGE_C; + case SLANG_CPP_SOURCE: + return SLANG_SOURCE_LANGUAGE_CPP; + case SLANG_CPP_PYTORCH_BINDING: + return SLANG_SOURCE_LANGUAGE_CPP; + case SLANG_HOST_CPP_SOURCE: + return SLANG_SOURCE_LANGUAGE_CPP; + case SLANG_CUDA_SOURCE: + return SLANG_SOURCE_LANGUAGE_CUDA; + case SLANG_WGSL: + return SLANG_SOURCE_LANGUAGE_WGSL; + default: + break; } return SLANG_SOURCE_LANGUAGE_UNKNOWN; } @@ -30,11 +38,16 @@ namespace Slang { switch (lang) { - case SLANG_SOURCE_LANGUAGE_GLSL: return SLANG_GLSL; - case SLANG_SOURCE_LANGUAGE_HLSL: return SLANG_HLSL; - case SLANG_SOURCE_LANGUAGE_C: return SLANG_C_SOURCE; - case SLANG_SOURCE_LANGUAGE_CPP: return SLANG_CPP_SOURCE; - case SLANG_SOURCE_LANGUAGE_CUDA: return SLANG_CUDA_SOURCE; + case SLANG_SOURCE_LANGUAGE_GLSL: + return SLANG_GLSL; + case SLANG_SOURCE_LANGUAGE_HLSL: + return SLANG_HLSL; + case SLANG_SOURCE_LANGUAGE_C: + return SLANG_C_SOURCE; + case SLANG_SOURCE_LANGUAGE_CPP: + return SLANG_CPP_SOURCE; + case SLANG_SOURCE_LANGUAGE_CUDA: + return SLANG_CUDA_SOURCE; } return SLANG_TARGET_UNKNOWN; diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp index 0afd25342..01ce0d1ac 100644 --- a/source/core/slang-type-text-util.cpp +++ b/source/core/slang-type-text-util.cpp @@ -281,9 +281,11 @@ static const NamesDescriptionValue s_fileSystemTypes[] = { switch (scalarType) { #define SLANG_SCALAR_TYPE_TO_TEXT(value, text) \ - case ScalarType::value: return UnownedStringSlice::fromLiteral(#text); + case ScalarType::value: \ + return UnownedStringSlice::fromLiteral(#text); SLANG_SCALAR_TYPES(SLANG_SCALAR_TYPE_TO_TEXT) - default: break; + default: + break; } return UnownedStringSlice(); diff --git a/source/core/slang-writer.cpp b/source/core/slang-writer.cpp index eb315323c..b3a48d9c7 100644 --- a/source/core/slang-writer.cpp +++ b/source/core/slang-writer.cpp @@ -177,7 +177,8 @@ SlangResult FileWriter::setMode(SlangWriterMode mode) break; #endif } - default: break; + default: + break; } return SLANG_FAIL; } diff --git a/source/core/slang-zip-file-system.cpp b/source/core/slang-zip-file-system.cpp index b3c50ab57..9c805dc55 100644 --- a/source/core/slang-zip-file-system.cpp +++ b/source/core/slang-zip-file-system.cpp @@ -289,7 +289,8 @@ SlangResult ZipFileSystemImpl::_copyToAndInitWriter(mz_zip_archive& outWriter) return SLANG_OK; } - default: break; + default: + break; } return SLANG_FAIL; } @@ -316,7 +317,8 @@ SlangResult ZipFileSystemImpl::_requireModeImpl(Mode newMode) _initReadWrite(m_archive); break; } - default: break; + default: + break; } break; } @@ -412,7 +414,8 @@ SlangResult ZipFileSystemImpl::_requireModeImpl(Mode newMode) } break; } - default: break; + default: + break; } } } @@ -581,7 +584,8 @@ SlangResult ZipFileSystemImpl::getPath(PathKind pathKind, const char* path, ISla *outPath = StringUtil::createStringBlob(Path::simplify(path)).detach(); return SLANG_OK; } - default: break; + default: + break; } return SLANG_E_NOT_AVAILABLE; @@ -856,9 +860,15 @@ void ZipFileSystemImpl::setCompressionStyle(const CompressionStyle& style) { switch (style.m_type) { - case CompressionStyle::Type::BestSpeed: m_compressionLevel = MZ_BEST_SPEED; break; - case CompressionStyle::Type::BestCompression: m_compressionLevel = MZ_BEST_COMPRESSION; break; - case CompressionStyle::Type::Default: m_compressionLevel = MZ_DEFAULT_LEVEL; break; + case CompressionStyle::Type::BestSpeed: + m_compressionLevel = MZ_BEST_SPEED; + break; + case CompressionStyle::Type::BestCompression: + m_compressionLevel = MZ_BEST_COMPRESSION; + break; + case CompressionStyle::Type::Default: + m_compressionLevel = MZ_DEFAULT_LEVEL; + break; case CompressionStyle::Type::Level: { int level = int(style.m_level * 10.0f + 0.5); diff --git a/source/core/unix/slang-unix-process.cpp b/source/core/unix/slang-unix-process.cpp index 97b59f21c..b3abc873c 100644 --- a/source/core/unix/slang-unix-process.cpp +++ b/source/core/unix/slang-unix-process.cpp @@ -653,7 +653,8 @@ closePipes: out = new UnixPipeStream(STDERR_FILENO, FileAccess::Write, false); break; } - default: return SLANG_FAIL; + default: + return SLANG_FAIL; } return SLANG_OK; } |
