feat(libSceJson2): implement Value, Object, Array, and String methods #7477
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7477"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-18T08:53:02Z.
What
Implements missing
libSceJson2functions:sce::Json::Value::operator bool() const(_ZNK3sce4Json5ValuecvbEv): returnsfalseforTypeNulland booleanfalse, andtruefor booleantrueand other initialized value types.sce::Json::Object::insert(const Pair&)(_ZN3sce4Json6Object6insertERKNS1_4PairE): updates existing keys or appends a deep copy, returning an iterator via hidden result pointer.sce::Json::Object::iteratorandObject::Pairmethods:operator==(const iterator&) const(_ZNK3sce4Json6Object8iteratoreqERKS2_)operator++(int)(_ZN3sce4Json6Object8iteratorppEi) via result pointeroperator=(const iterator&)(_ZN3sce4Json6Object8iteratoraSERKS2_)iterator()(_ZN3sce4Json6Object8iteratorC1Ev)iterator(const iterator&)(_ZN3sce4Json6Object8iteratorC1ERKS2_)advance(size_t)(_ZN3sce4Json6Object8iterator7advanceEm)Pair()(_ZN3sce4Json6Object4PairC1Ev)sce::Json::Object::erase(const String&)(_ZN3sce4Json6Object5eraseERKNS0_6StringE): removes matching entry, destroying key and value.sce::Json::Array::iteratorcopy constructor (_ZN3sce4Json5Array8iteratorC1ERKS2_) andadvance(size_t)(_ZN3sce4Json5Array8iterator7advanceEm).sce::Json::Value::swap(Value&)(_ZN3sce4Json5Value4swapERS1_): swaps node pointers without reallocations.sce::Json::Stringmethods:size() const(_ZNK3sce4Json6String4sizeEv)capacity() const(_ZNK3sce4Json6String8capacityEv)operator==(const String&) const(_ZNK3sce4Json6StringeqERKS1_)compare(const String&) const(_ZNK3sce4Json6String7compareERKS1_)resize(size_t)(_ZN3sce4Json6String6resizeEm)append(const char*, size_t)(_ZN3sce4Json6String6appendEPKcm)operator+=(const char*)(_ZN3sce4Json6StringpLEPKc)operator+=(unsigned char)(_ZN3sce4Json6StringpLEh)docs/dev/debt/libSceJson2.mdto document the new members and unverified behaviors.Tested
core/libs/tests/GuestJson.cppunit tests:ValueOperatorBool()ObjectInsert()ObjectPair()ArrayIteratorCopies()ObjectIteratorCopies()StringMethods()ValueSwap()ArrayIteratorAdvance()ObjectOperations()StreamParse()core/libs/tests/JsonCopyFailure.cppunit tests:python3 tools/check_conventions.py --base upstream/main: passed with 0 errors.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T09:11:56Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/tests/GuestJson.cppL933-934Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
docs/dev/debt/libSceJson2.mdcore/libs/tests/GuestJson.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T12:50:02Z.
Review: COMMENTED
Linux/GCC run of the current head, since the description lists only macOS with AppleClang and the last two commits add the iterator/erase methods and rework the parser and serialiser.
Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2 (libstdc++), Release,
BUILD_TESTING=ON, full build.Head
266fcdb79merged ontomain6efb7261b(clean merge).guest_json,param_json_parserandparam_json_utf8pass.GuestJson.cpponly, onmain: does not link (undefined reference to sce::Json::Object::iterator::iterator()and the other new methods), as expected for exportsmaindoes not have yet.ctest -E "^agc|gpu|vulkan|video_out"): 714/714.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-18T17:39:32Z.
Thanks @jotitadev for running the full build and test suite on Linux/GCC 15.2! I've updated the PR description with the Linux test results.
Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-19T04:40:18Z.
Resolved conflicts with latest
main(retainedValuehandler implementations from #6126 alongside the newValue,Object,Array, andStringmethods). All tests pass and conventions checks pass cleanly.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T15:40:13Z.
Review: CHANGES_REQUESTED
Thanks for the work. A few things before this can go in:
mainincore/libs/prx/libSceJson2/Export.cpp(AssignNode) anddocs/dev/debt/libSceJson2.md. #6593 wrapped the string/array/object copies intry { ... } catch (...) { Clear(copy); throw; }; theswitchrewrite drops that cleanup. Please rebase and keep the cleanup.AppendEscapedrun-scanning,snprintfinSerialize, stack buffer for numbers,reserve(256), theliteraltemplate) are performance work unrelated to the new members. Perf changes need before/after numbers from the same machine and scene; please move them to a separate PR with measurements or drop them.Value::operator bool,Object::insert(updating an existing key) anderase's return type have no cited source. Please say where each behaviour comes from (KytyPS5, shadPS4, SharpProspero, or the title's disassembly). If none exists, keep them as unverified in the debt file and don't pin the guesses in tests as facts (intZero, empty string,[]evaluating to true).Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T15:52:27Z.
I have a focused fix for
Value::set(ValueType)allocation-failure state corruption.SetTypeclears the previous value before allocating its String/Array/Object storage, sostd::bad_allocleaves the new type with null storage. The fix allocates the replacement first and retains the previous value on failure. The regression fails on main; the fixed Windows full build,guest_json,guest_json_copy_failureandpatched_librariespass (20 operations, 312 injected allocation failures, no tracked leaks).This touches the same
SetTypehunk as this PR. I propose landing the focused fix first, then rebasing #7477 while retaining this allocation-safety change and the cleanup from #6593. Would that order work for you? I am preparing a separate PR for the narrow fix; the new JSON members remain in #7477.The patch below was tested on main
bcdee66d109008334b07c0ff73a27e845708675f; I am updating the branch to current main before opening the PR. The JSON implementation and regression fixture have not changed upstream between those bases.AI-assisted: yes.
Proposed focused patch
Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-19T16:01:35Z.
Thanks for the review @adriadam10! I have addressed all points:
main. Kept thetry { ... } catch (...) { Clear(copy); throw; }cleanup inAssignNodefrom #6593, dropping the switch rewrite.AppendEscapedrun-scanning and reserve,snprintfinSerialize, stack buffer inParser::number,reserve(256)in callback-driven parse, and theliteraltemplate) so this PR is strictly scoped to the new member functions.docs/dev/debt/libSceJson2.mdto explicitly record thatValue::operator bool,Object::insert(updating an existing key), andObject::erase's return type have no cited sources in KytyPS5, shadPS4, SharpProspero, or disassembly, and marked their general console behaviors as unverified.GuestJson.cppto remove unverified assertions (intZero, empty string,[],{}evaluating to true, and updating an existing key viainsert), testing only standard null/boolean conversions and distinct key insertion.All unit tests (
GuestJsonandJsonCopyFailure) and convention checks pass cleanly.Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-19T16:06:07Z.
Thanks for checking and preparing the fix, @Ondra97!
In our latest rebase addressing @adriadam10's review, we dropped our earlier changes to
SetTypecompletely, leavingSetTypeandJsonCopyFailure.cppidentical tomain.Because #7477 no longer touches
SetType, there is no overlap or conflict between the two branches. Either merge order works smoothly, and I'll be glad to rebase #7477 if your fix lands first!Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-19T16:21:11Z.
Local cross-check report for CI checks and test suite on the latest head (
2a1ca278e):Machine: macOS arm64, AppleClang 21.0.0, Release
Head:
2a1ca278erebased cleanly onmain32004dfa5(mergeable with currentmaindbac9fa15)Required Checks (4/4 Passed):
python3 -I tools/check_conventions.py --base upstream/main --head HEAD→ passed with 0 errors.python3 -I tools/pr_labels.py --pr 7477→ passed with 0 errors (docs,prx).main, 0 merge conflicts, branch targetmain→ passed.python3 tools/progress.py→ libraries 4133/5174 (79.88%), shaders 1166/1166 (100.0%).Skipped CI Jobs Cross-Verification (6/6 Verified as Expected):
relinker&relinker-asan: Skipped by workflow gate. Gated by path filter (core/relinker/,libc/, build files); PR #7477 modifies onlylibSceJson2,GuestJson.cpp, and debt documentation.register-context: Skipped by workflow gate. Path-filtered tocore/libs/tests/register_context/.write-watch: Skipped by workflow gate. Path-filtered tocore/libs/tests/write_watch/.linux&windows(Full builds): Skipped by CI design for pull request events (github.event_name == 'push'or maintainerworkflow_dispatchonly). Full build & test suite verified independently on Linux x86_64 / GCC 15.2 by @jotitadev (714/714 non-GPU tests passing) and on macOS (AppleClang).Unit Tests:
guest_json: passed (String methods, Array/Object iterators,erase,swap,insert, andoperator bool).guest_json_copy_failure: passed (17 operations, 309 injected allocation failures, no tracked leaks).Written with AI assistance. I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T16:30:05Z.
Progress report (
32004df→2a1ca27)📈 System libraries: 79.88% (+0.11%, +21 implemented functions)
✅ 21 implemented
_ZN3sce4Json5Array8iterator7advanceEm_ZN3sce4Json5Array8iteratorC1ERKS2__ZN3sce4Json5Value4swapERS1__ZN3sce4Json6Object4PairC1Ev_ZN3sce4Json6Object5eraseERKNS0_6StringE_ZN3sce4Json6Object6insertERKNS1_4PairE_ZN3sce4Json6Object8iterator7advanceEm_ZN3sce4Json6Object8iteratorC1ERKS2__ZN3sce4Json6Object8iteratorC1Ev_ZN3sce4Json6Object8iteratoraSERKS2__ZN3sce4Json6Object8iteratorppEi_ZN3sce4Json6String6appendEPKcm_ZN3sce4Json6String6resizeEm_ZN3sce4Json6StringpLEPKc_ZN3sce4Json6StringpLEh_ZNK3sce4Json5ValuecvbEv_ZNK3sce4Json6Object8iteratoreqERKS2__ZNK3sce4Json6String4sizeEv_ZNK3sce4Json6String7compareERKS1__ZNK3sce4Json6String8capacityEv_ZNK3sce4Json6StringeqERKS1_Imported from boykopovar/AnyPS5. Originally posted by SwetabhSingh17 on 2026-10-19T16:42:15Z.
Local cross-check report for the 4 required CI checks and PR status on the latest head (
2a1ca278e):Machine: Windows 11 Home 64-bit, AMD Ryzen 9 7900X (12 cores / 24 threads), NVIDIA GeForce RTX 4070 SUPER, 32 GB RAM
Head:
2a1ca278erebased cleanly onmain32004dfa5(mergeable with currentmaindbac9fa15)Required Checks (4/4 Passed):
main, 0 merge conflicts, branch targetmain→ passed.python3 -I tools/check_conventions.py --base upstream/main --head HEAD→ passed with 0 errors.python3 -I tools/pr_labels.py --pr 7477→ passed with 0 errors (docs,prx).python3 tools/progress.py→ libraries 4133/5174 (79.88%), shaders 1166/1166 (100.0%).Skipped CI Jobs Cross-Verification (6/6 Verified as Expected):
relinker&relinker-asan: Skipped by workflow gate. Gated by path filter (core/relinker/,libc/, build files); PR #7477 modifies onlylibSceJson2,GuestJson.cpp, and debt documentation.register-context: Skipped by workflow gate. Path-filtered tocore/libs/tests/register_context/.write-watch: Skipped by workflow gate. Path-filtered tocore/libs/tests/write_watch/.linux&windows(Full builds): Skipped by CI design for pull request events (github.event_name == 'push'or maintainerworkflow_dispatchonly). Full build & test suite verified independently on Linux x86_64 / GCC 15.2 by @jotitadev (714/714 non-GPU tests passing) and on macOS (AppleClang).Review & Verification Summary:
docs/dev/debt/libSceJson2.md.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T16:44:06Z.
Thanks for confirming. I verified that #7477 leaves SetType and JsonCopyFailure.cpp unchanged from main and opened #7977 for the allocation failure fix. I linked this agreement in the PR; it has no dependency on #7477, so either merge order works.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T23:03:36Z.
Checked the new head against the previous review:
AssignNodeis untouched and #6593'stry { ... } catch (...) { Clear(copy); throw; }cleanup is kept.operator bool,Object::insert,erase,advance,swapand theStringmembers are listed as unverified indocs/dev/debt/libSceJson2.md, and the tests don't pin those guesses.Merged.