diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-11-24 09:34:05 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-24 09:34:05 -0500 |
| commit | bdc61bb8db321a8d788aa739b889354540a49ee0 (patch) | |
| tree | 16c564282a28d69e77d51855a41f11bdfa80fded /source | |
| parent | 9e084ffab37c276d40931a58633041a2e10de623 (diff) | |
Remove test-proxy (#2027)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Use 'Process' to communicate with an command line tool.
* Remove slang-win-stream
* Tidy up windows ProcessUtil.
* First version of BufferedReadStream.
* Windows working IPC for steams.
* Test proxy count option.
* Split Process/ProcessUtil. Process is platform dependant. ProcessUtil are functions that are platform independent.
* First implementation of Unix Process interface.
* Unix process compiles on cygwin.
* Fix typo in unix process.
* Separate unix pipe stream error of invalid access, from pipe availability.
* Fix in standard line extraction.
* Make fd non blocking.
* Fix issues with Windows Process streams.
* Added UnixPipe.
* Some fixes around UnixPipeStream.
* Make a unix stream closed explicit.
* Hack to debug linux process/stream.
* Revert to old linux pipe handling.
* Pass executable path for unit tests.
Split out CommandLine into own source.
* Small improvements in process/command line.
* Check process behavior with crash.
* Make stderr and stdout unbuffered for crash testing.
* Only turn disable buffering in crash test.
* Disable crash test on CI.
* Fix crash on clang/linux.
* Enable crash test.
Remove _appendBuffer as can use StreamUtil functionality.
* Added inital processing for http headers.
* Small improvements to HttpHeader.
* First pass HTTPPacketConnection working on windows.
* Enable other Process communication tests.
* Update comments.
* WIP JSON RPC.
* Add terminate to Process.
Made JSONRPC a Util.
* Small tidy up around HTTPPacketConnection.
* Improve process termination options.
* WIP for test-server.
* Add diagnostics error handling to test-server.
* Improved JSON support.
Parsing/creating JSON-RPC messages.
* WIP JSONRPC parsing.
* First pass RttiInfo support.
* WIP converting between JSON/native types.
* Project files.
* Split out RttiUtil.
Made RttiInfo constuction thread safe.
* WIP RTTI<->JSON.
* Add diagnostics to JSON<->native conversions.
* Make RttiInfo for structs globals. Avoids problem around derived types (like pointers), being able to cause an abort.
* Add pointer support to RTTI.
Fixed some compilation issues on linux.
* Add fixed array support.
* Added Rtti unit test.
* Add rtti unit test.
* Split out quoted/unquoted key handling.
Fix bugs in JSON value/container.
Added JSON native test.
* Make default array allocator use malloc/free.
Remove the new[] handler (doesn't work on visuals studio).
* Fix for linux warning.
* Remove some test code.
* Fix issues on x86 win.
* Fix warning on aarch64.
* Fix some bugs in JSON parsing/handling.
Make Rtti work copy/dtor/ctor struct types.
* Testing JSON<->native with fixed array.
Make makeArrayView explicit if it's just a single value.
Added array type.
* Fix getting arrayView.
* Improve JSON diagnostic name.
* First pass refactor using Rtti for JSON RPC.
* First pass of test server using RTTI/JSON-RPC.
* Added JSONRPCConnection.
* Fix some naming issues.
* First pass of test-server working.
* Added unit test support for JSON-RPC test server.
* Fix compilation issues on linux around template handling.
* Typo fix.
* Fix a bug around SourceLoc lookup with JSONContainer.
* Set the console type to console for ISlangWriters.
* Small improvements to test-server.
* Small improvements in test-server.
* Small fix.
* Remove test-proxy. Make test-process a process that can be used to unit test 'Process'.
Adding mechanism to control spawning that will create a new process for every test.
* Ability to remove source manager for JSONValue.
Diffstat (limited to 'source')
| -rw-r--r-- | source/compiler-core/slang-json-value.cpp | 76 | ||||
| -rw-r--r-- | source/compiler-core/slang-json-value.h | 11 |
2 files changed, 87 insertions, 0 deletions
diff --git a/source/compiler-core/slang-json-value.cpp b/source/compiler-core/slang-json-value.cpp index 216512407..ba4ccad09 100644 --- a/source/compiler-core/slang-json-value.cpp +++ b/source/compiler-core/slang-json-value.cpp @@ -401,6 +401,82 @@ bool JSONContainer::asBool(const JSONValue& value) } } +JSONValue JSONContainer::asValue(const JSONValue& inValue) +{ + JSONValue value = inValue; + switch (value.type) + { + case JSONValue::Type::StringLexeme: + { + const UnownedStringSlice slice = getTransientString(inValue); + value.stringKey = getKey(slice); + value.type = JSONValue::Type::StringValue; + break; + } + case JSONValue::Type::IntegerLexeme: + { + value.floatValue = value.asFloat(); + value.type = JSONValue::Type::IntegerValue; + break; + } + case JSONValue::Type::FloatLexeme: + { + value.floatValue = value.asFloat(); + value.type = JSONValue::Type::FloatValue; + break; + } + default: break; + } + + return value; +} + +void JSONContainer::_clearSourceManagerDependency(JSONValue* ioValues, Index count) +{ + for (Index i = 0; i < count; ++i) + { + auto& value = ioValues[i]; + value = asValue(value); + value.loc = SourceLoc(); + } +} + +void JSONContainer::clearSourceManagerDependency(JSONValue* ioValues, Index valuesCount) +{ + _clearSourceManagerDependency(ioValues, valuesCount); + + // We need to find ranges that are available + for (auto& range : m_ranges) + { + switch (range.type) + { + case Range::Type::Array: + { + _clearSourceManagerDependency(m_arrayValues.getBuffer() + range.startIndex, range.count); + break; + } + case Range::Type::Object: + { + const Index count = range.count; + auto pairs = m_objectValues.getBuffer() + range.startIndex; + + for (Index i = 0; i < count; ++i) + { + auto& pair = pairs[i]; + pair.keyLoc = SourceLoc(); + pair.value = asValue(pair.value); + pair.value.loc = SourceLoc(); + } + break; + } + default: break; + } + } + + // Remove the source manager + m_sourceManager = nullptr; +} + int64_t JSONContainer::asInteger(const JSONValue& value) { switch (value.type) diff --git a/source/compiler-core/slang-json-value.h b/source/compiler-core/slang-json-value.h index b94283d81..2e8707a87 100644 --- a/source/compiler-core/slang-json-value.h +++ b/source/compiler-core/slang-json-value.h @@ -233,9 +233,17 @@ public: /// Set the source manager void setSourceManager(SourceManager* sourceManger) { m_sourceManager = sourceManger; } + /// Clears all the source locs. Useful if the sourceManager is no longer available, or has itself been reset. + /// All JSONValues which were Lexeme based will become held in the container + /// The source manager will set to nullptr + void clearSourceManagerDependency(JSONValue* ioValues, Index count); + /// Reset the state void reset(); + /// Return inValue as a regular value (ie not held as a lexeme) + JSONValue asValue(const JSONValue& inValue); + // Ctor JSONContainer(SourceManager* sourceManger); @@ -278,6 +286,9 @@ protected: /// True if the key and value are equal bool _areEqualOrderedKeys(const JSONKeyValue* a, const JSONKeyValue* b, Index count); + void _clearSourceManagerDependency(JSONValue* ioValues, Index count); + JSONValue _removeManagerDependency(const JSONValue& inValue); + StringBuilder m_buf; ///< A temporary buffer used to hold unescaped strings SourceView* m_currentView = nullptr; |
