From 4880789e3003441732cca4471091563f36531635 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 29 Apr 2019 17:03:46 -0400 Subject: String/List closer to conventions, and use Index type (#959) * List made members m_ Tweaked types to closer match conventions. * Use asserts for checking conditions on List. Other small improvements. * List.Count() -> getSize() * List Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List:: AddRange -> addRange Capacity -> getCapacity Insert -> insert InsertRange -> insertRange AddRange -> addRange RemoveRange -> removeRange RemoveAt -> removeAt Remove -> remove Reverse -> reverse FastRemove -> fastRemove FastRemoveAt -> fastRemoveAt Clear -> clear * List FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List Removed m_allocator (wasn't used) Swap -> swapElements Sort -> sort Contains -> contains ForEach -> forEach QuickSort -> quickSort InsertionSort -> insertionSort BinarySearch -> binarySearch Max -> calcMax Min -> calcMin * Initializer::Initialize -> initialize List:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include in common.h, and remove unneeded inclusions * Small refactor of ArrayView - remove stride as not used * getSize -> getCount setSize -> setCount unsafeShrinkToSize->unsafeShrinkToCount growToSize -> growToCount m_size -> m_count * Some tidy up around Allocator. * Use Index type on List. * Refactor of IntSet. First tentative look at using Index. * Made Index an Int Did preliminary fixes. Made String use Index. * Partial refactor of String. * String::Buffer -> getBuffer ToWString -> toWString * Small improvements to String. String:: Buffer() -> getBuffer() Equals() -> equals * Try to use Index where appropriate. * Fix warnings on windows x86 builds. --- tools/slang-test/os.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'tools/slang-test/os.cpp') diff --git a/tools/slang-test/os.cpp b/tools/slang-test/os.cpp index 9ecf50557..a938a71e7 100644 --- a/tools/slang-test/os.cpp +++ b/tools/slang-test/os.cpp @@ -1,7 +1,6 @@ // os.cpp #include "os.h" -#include #include #include @@ -34,7 +33,7 @@ static bool adjustToValidResult(OSFindFilesResult& result) if (wcscmp(result.fileData_.cFileName, L"..") == 0) goto skip; - result.filePath_ = result.directoryPath_ + String::FromWString(result.fileData_.cFileName); + result.filePath_ = result.directoryPath_ + String::fromWString(result.fileData_.cFileName); if (result.fileData_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) result.filePath_ = result.filePath_ + "/"; @@ -63,7 +62,7 @@ OSFindFilesResult osFindFilesInDirectoryMatchingPattern( OSFindFilesResult result; HANDLE findHandle = FindFirstFileW( - searchPath.ToWString(), + searchPath.toWString(), &result.fileData_); result.directoryPath_ = directoryPath; @@ -101,7 +100,7 @@ OSFindFilesResult osFindChildDirectories( OSFindFilesResult result; HANDLE findHandle = FindFirstFileW( - searchPath.ToWString(), + searchPath.toWString(), &result.fileData_); result.directoryPath_ = directoryPath; @@ -223,7 +222,7 @@ void OSProcessSpawner::pushArgument( commandLine_.Append(" "); commandLine_.Append(argument); - argumentList_.Add(argument); + argumentList_.add(argument); } Slang::String OSProcessSpawner::getCommandLine() @@ -321,8 +320,8 @@ OSError OSProcessSpawner::spawnAndWaitForCompletion() // `CreateProcess` requires write access to this, for some reason... BOOL success = CreateProcessW( - isExecutablePath_ ? executableName_.ToWString().begin() : nullptr, - (LPWSTR)commandLine_.ToString().ToWString().begin(), + isExecutablePath_ ? executableName_.toWString().begin() : nullptr, + (LPWSTR)commandLine_.ToString().toWString().begin(), nullptr, nullptr, true, @@ -405,9 +404,9 @@ static bool checkValidResult(OSFindFilesResult& result) String path = result.directoryPath_ + String(result.entry_->d_name); -// fprintf(stderr, "stat(%s)\n", path.Buffer()); +// fprintf(stderr, "stat(%s)\n", path.getBuffer()); struct stat fileInfo; - if(stat(path.Buffer(), &fileInfo) != 0) + if(stat(path.getBuffer(), &fileInfo) != 0) return false; if(S_ISDIR(fileInfo.st_mode)) @@ -443,9 +442,9 @@ OSFindFilesResult osFindFilesInDirectory( { OSFindFilesResult result; -// fprintf(stderr, "osFindFilesInDirectory(%s)\n", directoryPath.Buffer()); +// fprintf(stderr, "osFindFilesInDirectory(%s)\n", directoryPath.getBuffer()); - result.directory_ = opendir(directoryPath.Buffer()); + result.directory_ = opendir(directoryPath.getBuffer()); if(!result.directory_) { result.entry_ = NULL; @@ -462,7 +461,7 @@ OSFindFilesResult osFindChildDirectories( { OSFindFilesResult result; - result.directory_ = opendir(directoryPath.Buffer()); + result.directory_ = opendir(directoryPath.getBuffer()); if(!result.directory_) { result.entry_ = NULL; @@ -482,7 +481,7 @@ void OSProcessSpawner::pushExecutableName( Slang::String executableName) { executableName_ = executableName; - arguments_.Add(executableName); + arguments_.add(executableName); isExecutablePath_ = false; } @@ -490,20 +489,20 @@ void OSProcessSpawner::pushExecutablePath( Slang::String executablePath) { executableName_ = executablePath; - arguments_.Add(executablePath); + arguments_.add(executablePath); isExecutablePath_ = true; } void OSProcessSpawner::pushArgument( Slang::String argument) { - arguments_.Add(argument); - argumentList_.Add(argument); + arguments_.add(argument); + argumentList_.add(argument); } Slang::String OSProcessSpawner::getCommandLine() { - Slang::UInt argCount = arguments_.Count(); + Slang::UInt argCount = arguments_.getCount(); Slang::StringBuilder sb; for(Slang::UInt ii = 0; ii < argCount; ++ii) @@ -519,9 +518,9 @@ OSError OSProcessSpawner::spawnAndWaitForCompletion() List argPtrs; for(auto arg : arguments_) { - argPtrs.Add(arg.Buffer()); + argPtrs.add(arg.getBuffer()); } - argPtrs.Add(NULL); + argPtrs.add(NULL); int stdoutPipe[2]; int stderrPipe[2]; -- cgit v1.2.3