From f4d900dfb64d95f121dd8565dd269be061ef8509 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 29 Jun 2017 11:50:55 -0700 Subject: Overhaul `RefPtr` and `String` - `RefPtr` no longer tries to have distinct cases for interal-vs-external reference counts. Instead we always require an internal reference count. - Types the used `RefPtr` but weren't `RefObject` were made to inherit `RefObject` - The `ReferenceCounted` base class was removed, so that only `RefObject` remains - Implicit conversion from `RefPtr` to `T*` added - This created some complicates for other types that relied on implicit conversions, so this isn't a net cleanup right now - The main type that got messed up by the above was `String`, which previously held a `RefPtr`. This change thus *also* includes a major overhaul of `String`: - `String` now holds all its data via indirection, using a `StringRepresentation` that is a `RefObject`. This object holds a length, capacity, and directly stores the character data in its allocation. This means that `sizeof(String)==sizeof(void*)` - It is now possible to directly mutate a `String` by appending to its representation (we just need to ensure it has a reference count of `1`, possibly by cloning it). This means that `StringBuilder` is now basically just an idomatic use of `String` - A couple operations that just return sub-ranges of a `String` now return `StringSlice` to avoid allocation when it isn't needed. This required more work. - Indices into strings changed from `int` to `UInt` (which is pointer-sized). This had a bunch of follow-on changes because the value `-1` sometimes needs to be special-cased in code that uses indices. Further cleanups are probably needed here. --- tools/slang-test/main.cpp | 4 ++-- tools/slang-test/os.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp index 7a0cac3ce..2bca2f78d 100644 --- a/tools/slang-test/main.cpp +++ b/tools/slang-test/main.cpp @@ -548,7 +548,7 @@ OSError spawnAndWait(String testPath, OSProcessSpawner& spawner) { if( options.shouldBeVerbose ) { - fprintf(stderr, "%s\n", spawner.commandLine_.Buffer()); + fprintf(stderr, "%s\n", spawner.commandLine_.ToString().begin()); } OSError err = spawner.spawnAndWaitForCompletion(); @@ -1149,7 +1149,7 @@ void handleTestResult( break; } - printf("%s test: '%S'\n", resultString, testName.ToWString()); + printf("%s test: '%S'\n", resultString, testName.ToWString().begin()); } break; diff --git a/tools/slang-test/os.cpp b/tools/slang-test/os.cpp index 63db4f9ad..40fd8afff 100644 --- a/tools/slang-test/os.cpp +++ b/tools/slang-test/os.cpp @@ -314,8 +314,8 @@ OSError OSProcessSpawner::spawnAndWaitForCompletion() // `CreateProcess` requires write access to this, for some reason... BOOL success = CreateProcessW( - isExecutablePath_ ? executableName_.ToWString() : nullptr, - (LPWSTR)commandLine_.ToString().ToWString(), + isExecutablePath_ ? executableName_.ToWString().begin() : nullptr, + (LPWSTR)commandLine_.ToString().ToWString().begin(), nullptr, nullptr, true, -- cgit v1.2.3