diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-11-19 10:22:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-19 10:22:56 -0500 |
| commit | 87eb789ae03cbd7a79d5433cefb37f10bec86753 (patch) | |
| tree | dcf634615a59ba3a927e92e5597c2335f31b341a /tools | |
| parent | 1d5f815b3964edee8a2d701e1a6cc078c89d677f (diff) | |
Improvements to JSON/RTTI (#2022)
* #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.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-unit-test/unit-test-json-native.cpp | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/tools/slang-unit-test/unit-test-json-native.cpp b/tools/slang-unit-test/unit-test-json-native.cpp index 1d2085751..6636cc04a 100644 --- a/tools/slang-unit-test/unit-test-json-native.cpp +++ b/tools/slang-unit-test/unit-test-json-native.cpp @@ -11,13 +11,42 @@ using namespace Slang; namespace { // anonymous +struct OtherStruct +{ + typedef OtherStruct ThisType; + + bool operator==(const ThisType& rhs) const { return f == rhs.f && value == rhs.value; } + bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } + + float f = 1.0f; + String value; + + static const StructRttiInfo g_rttiInfo; +}; + +static const StructRttiInfo _makeOtherStructRtti() +{ + OtherStruct obj; + StructRttiBuilder builder(&obj, "OtherStruct", nullptr); + builder.addField("f", &obj.f); + builder.addField("value", &obj.value); + return builder.make(); +} +/* static */const StructRttiInfo OtherStruct::g_rttiInfo = _makeOtherStructRtti(); + struct SomeStruct { typedef SomeStruct ThisType; bool operator==(const ThisType& rhs) const { - return a == rhs.a && b == rhs.b && s == rhs.s && list == rhs.list; + return a == rhs.a && + b == rhs.b && + s == rhs.s && + list == rhs.list && + boolValue == rhs.boolValue && + structList == rhs.structList && + makeConstArrayView(fixedArray) == makeConstArrayView(rhs.fixedArray); } bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } @@ -25,12 +54,15 @@ struct SomeStruct float b = 2.0f; String s; List<String> list; + bool boolValue = false; + + List<OtherStruct> structList; + + int fixedArray[2] = { 0, 0 }; static const StructRttiInfo g_rttiInfo; }; -} // anonymous - static const StructRttiInfo _makeSomeStructRtti() { SomeStruct obj; @@ -40,11 +72,17 @@ static const StructRttiInfo _makeSomeStructRtti() builder.addField("b", &obj.b); builder.addField("s", &obj.s); builder.addField("list", &obj.list); + builder.addField("boolValue", &obj.boolValue); + builder.addField("structList", &obj.structList); + builder.addField("fixedArray", &obj.fixedArray); return builder.make(); } /* static */const StructRttiInfo SomeStruct::g_rttiInfo = _makeSomeStructRtti(); +} // anonymous + + static SlangResult _check() { // Convert into a JSON string @@ -52,6 +90,15 @@ static SlangResult _check() SomeStruct s; s.list.add("Hello!"); s.s = "There"; + s.boolValue = true; + + OtherStruct o; + o.f = 27.5f; + o.value = "This works!"; + + s.structList.add(o); + s.fixedArray[1] = 8; + s.fixedArray[0] = -1; // Try serializing it out |
