feat(libSceJson2): implement sce::Json::String at, find and rfind #10212

Merged
noamroger merged 1 commit from upstream-pr/10212 into main 2026-10-24 02:23:37 +00:00
noamroger commented 2026-10-23 13:56:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by noamroger on 2026-10-23T13:56:34Z.


What

Implements seven of the libSceJson2 exports declared as pending in be37cb907: sce::Json::String::at(size_t), find(const char*, size_t), find(const char*, size_t, size_t), find(const String&, size_t), and the three matching rfind overloads. Their pending declarations are removed from InventoryExports.cpp.

The return types (char for at, a size for find/rfind, String::npos when not found) follow the PS Vita library's String in vitasdk json.h, already cited in the library's debt file; the search follows std::string, as the existing find(char)/rfind(char) do. at past the end, a null text, and a null String throw; the console's behaviour there is unverified and recorded in docs/dev/debt/libSceJson2.md. A null text with a zero length is accepted as an empty needle.

Tested

Ubuntu 24.04, GCC 13.3: GuestJson.cpp built against libSceJson2/Export.cpp and run; it passes. The new checks in StringMethods cover each overload (match, no match, pos in the middle, empty needle at and past the end, npos start for rfind, partial-length needle, String needle) and the throwing paths for at and null text. Also run under ASan/UBSan: no new findings (a 48-byte leak in Array::begin/end is reported identically on main). Not run through the full CMake build. tools/check_conventions.py --base origin/main passes. No title tested.

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

Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4983866661 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10212). Originally posted by [noamroger](https://github.com/noamroger) on 2026-10-23T13:56:34Z. --- ### What Implements seven of the libSceJson2 exports declared as pending in be37cb907: `sce::Json::String::at(size_t)`, `find(const char*, size_t)`, `find(const char*, size_t, size_t)`, `find(const String&, size_t)`, and the three matching `rfind` overloads. Their pending declarations are removed from `InventoryExports.cpp`. The return types (`char` for `at`, a size for `find`/`rfind`, `String::npos` when not found) follow the PS Vita library's `String` in [vitasdk json.h](https://github.com/vitasdk/vita-headers/blob/15605617cbbb23d266f88af28899fdb573e2355e/include/psp2/json.h#L338), already cited in the library's debt file; the search follows `std::string`, as the existing `find(char)`/`rfind(char)` do. `at` past the end, a null text, and a null `String` throw; the console's behaviour there is unverified and recorded in `docs/dev/debt/libSceJson2.md`. A null text with a zero length is accepted as an empty needle. ### Tested Ubuntu 24.04, GCC 13.3: `GuestJson.cpp` built against `libSceJson2/Export.cpp` and run; it passes. The new checks in `StringMethods` cover each overload (match, no match, `pos` in the middle, empty needle at and past the end, `npos` start for `rfind`, partial-length needle, `String` needle) and the throwing paths for `at` and null text. Also run under ASan/UBSan: no new findings (a 48-byte leak in `Array::begin`/`end` is reported identically on `main`). Not run through the full CMake build. `tools/check_conventions.py --base origin/main` passes. No title tested. ### 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 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-23 13:58:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T13:58:05Z.

Review: APPROVED


Reviewed exact head 1aab236614c9b579d627b99f4f5fca62c0de2fd2. This is a focused implementation of the seven listed String::at, find, and rfind overloads, replaces the matching pending exports, adds overload and boundary tests, and records the unverified console behavior for invalid inputs in the debt entry. The changes are limited to the implementation, its tests and debt documentation. The template records AI assistance, and its checked items pass the repository conventions checker.

I independently ran tools/check_conventions.py against this head and git diff --check; both passed. I built the actual GuestJson.cpp test with this head's libSceJson2/Export.cpp using GCC C++20 with AddressSanitizer and UndefinedBehaviorSanitizer, then ran it successfully (ASAN_OPTIONS=detect_leaks=0; exit 0). Leak detection was disabled for this local run, so this does not independently verify the author's reported leak comparison. Hosted conventions, intake and labels checks pass. The author's Ubuntu test and sanitizer report is consistent with the focused coverage; no full CMake build or console test was run here. Approving this exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5629268863 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10212#pullrequestreview-5629268863). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T13:58:05Z. **Review:** APPROVED --- Reviewed exact head `1aab236614c9b579d627b99f4f5fca62c0de2fd2`. This is a focused implementation of the seven listed `String::at`, `find`, and `rfind` overloads, replaces the matching pending exports, adds overload and boundary tests, and records the unverified console behavior for invalid inputs in the debt entry. The changes are limited to the implementation, its tests and debt documentation. The template records AI assistance, and its checked items pass the repository conventions checker. I independently ran `tools/check_conventions.py` against this head and `git diff --check`; both passed. I built the actual `GuestJson.cpp` test with this head's `libSceJson2/Export.cpp` using GCC C++20 with AddressSanitizer and UndefinedBehaviorSanitizer, then ran it successfully (`ASAN_OPTIONS=detect_leaks=0`; exit 0). Leak detection was disabled for this local run, so this does not independently verify the author's reported leak comparison. Hosted conventions, intake and labels checks pass. The author's Ubuntu test and sanitizer report is consistent with the focused coverage; no full CMake build or console test was run here. Approving this exact head.
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!10212
No description provided.