feat(libSceJson2): implement sce::Json::Array::operator= #10353

Merged
ntamas94 merged 1 commit from upstream-pr/10353 into main 2026-10-23 23:55:05 +00:00
ntamas94 commented 2026-10-23 18:54:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-23T18:54:02Z.


What

sce::Json::Array::operator=(const Array&) now copies the source array into this and returns this, as the console does; on main it is an inventory declaration that throws NotImplemented. Knowledge is Power: Decades (CUSA12435) imports it from its Unity plugin Media/Plugins/PS4WebAPI.prx. The copy is built first with the existing CopyArray, then the old elements are destroyed and replaced, the way Object::operator= already works; assigning an array to itself leaves it unchanged. The inventory stub and its debt line are removed. guest_json gains ArrayAssignment: assigning a three-element array over a one-element one returns this, leaves three elements in both, keeps the copy's elements after the source is cleared, and survives a self-assignment.

Tested

Windows 11, MinGW-w64 GCC (winlibs), Ninja: guest_json passed on the final head (d44c823); with main's Export.cpp and InventoryExports.cpp it does not link (undefined reference to sce::Json::Array::operator=(sce::Json::Array const&)), as the inventory stub exports the name only to guests. guest_json_numeric_locale and guest_json_copy_failure pass. python tools/check_conventions.py --base origin/main passes.

Measured on a PS4 Pro (firmware 10.71) with a homebrew probe linked against the system libSceJson2: the array is the list member of a parsed document ([1,2,3]), the destination a freshly constructed Array; one line per call as function[label] | arguments | return | errno:

_ZNK3sce4Json5Array4sizeEv[list] | $arr | 0x0000000000000003 | -
_ZN3sce4Json5ArrayC1Ev | survey_array | void | -
_ZN3sce4Json5ArrayaSERKS1_[copy-list] | survey_array, $arr | <address of survey_array> | -
_ZNK3sce4Json5Array4sizeEv[copy] | survey_array | 0x0000000000000003 | -
_ZNK3sce4Json5Array4sizeEv[source-after-copy] | $arr | 0x0000000000000003 | -

The return value is the destination's own address, the copy holds three elements and the source keeps its three. Not run with a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4987785497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10353). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-10-23T18:54:02Z. --- ### What `sce::Json::Array::operator=(const Array&)` now copies the source array into `this` and returns `this`, as the console does; on `main` it is an inventory declaration that throws `NotImplemented`. Knowledge is Power: Decades (CUSA12435) imports it from its Unity plugin `Media/Plugins/PS4WebAPI.prx`. The copy is built first with the existing `CopyArray`, then the old elements are destroyed and replaced, the way `Object::operator=` already works; assigning an array to itself leaves it unchanged. The inventory stub and its debt line are removed. `guest_json` gains `ArrayAssignment`: assigning a three-element array over a one-element one returns `this`, leaves three elements in both, keeps the copy's elements after the source is cleared, and survives a self-assignment. ### Tested Windows 11, MinGW-w64 GCC (winlibs), Ninja: `guest_json` passed on the final head (d44c823); with `main`'s `Export.cpp` and `InventoryExports.cpp` it does not link (`undefined reference to sce::Json::Array::operator=(sce::Json::Array const&)`), as the inventory stub exports the name only to guests. `guest_json_numeric_locale` and `guest_json_copy_failure` pass. `python tools/check_conventions.py --base origin/main` passes. Measured on a PS4 Pro (firmware 10.71) with a homebrew probe linked against the system `libSceJson2`: the array is the `list` member of a parsed document (`[1,2,3]`), the destination a freshly constructed `Array`; one line per call as `function[label] | arguments | return | errno`: ``` _ZNK3sce4Json5Array4sizeEv[list] | $arr | 0x0000000000000003 | - _ZN3sce4Json5ArrayC1Ev | survey_array | void | - _ZN3sce4Json5ArrayaSERKS1_[copy-list] | survey_array, $arr | <address of survey_array> | - _ZNK3sce4Json5Array4sizeEv[copy] | survey_array | 0x0000000000000003 | - _ZNK3sce4Json5Array4sizeEv[source-after-copy] | $arr | 0x0000000000000003 | - ``` The return value is the destination's own address, the copy holds three elements and the source keeps its three. Not run with a title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 19:01:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T19:01:26Z.

Review: APPROVED


Reviewed the implementation against the current JSON2 ownership helpers and the reported PS4 system-library probe. The copy-before-destroy sequence preserves the destination on copy failure, avoids invalidating the source during self-assignment, and returns the destination as the probe measured. The regression test covers replacement, deep-copy independence after clearing the source, and self-assignment. The PR reports focused Windows guest tests and console probe evidence; hosted conventions, intake, eligibility, labels, and report checks pass. Product build jobs were skipped by repository policy, so I am not treating them as hosted build coverage.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633172156 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10353#pullrequestreview-5633172156). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T19:01:26Z. **Review:** APPROVED --- Reviewed the implementation against the current JSON2 ownership helpers and the reported PS4 system-library probe. The copy-before-destroy sequence preserves the destination on copy failure, avoids invalidating the source during self-assignment, and returns the destination as the probe measured. The regression test covers replacement, deep-copy independence after clearing the source, and self-assignment. The PR reports focused Windows guest tests and console probe evidence; hosted conventions, intake, eligibility, labels, and report checks pass. Product build jobs were skipped by repository policy, so I am not treating them as hosted build coverage.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10353
No description provided.