feat(libSceIcu): implement the enumeration dispatch exports #11132

Merged
mantavisual merged 31 commits from upstream-pr/11132 into main 2026-11-04 04:49:08 +00:00
mantavisual commented 2026-10-25 19:08:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mantavisual on 2026-10-25T19:08:20Z.


What

Implements the four uenum_ exports that firmware 13.42's libSceIcu has (BunnyFl's export list): uenum_close, uenum_count, uenum_next and uenum_unext. They don't enumerate anything themselves. They dispatch through the callbacks in a UEnumeration, the object ICU's enumeration producers return; 13.42 exports producers such as ucal_openTimeZones, ucol_getKeywordValues and ucurr_openISOCurrencies.

Behaviour follows ICU 78.1's uenum.cpp over the UEnumeration layout in uenumimp.h: baseContext, context, then the close, count, uNext, next and reset callbacks, 56 bytes. The callbacks are called with the guest ABI (APS5_VABI), so an enumeration built by guest code or by a future producer here works the same way.

  • uenum_count, uenum_next and uenum_unext return −1 or null for a null enumeration without reading the status, and for an error that is already set without calling anything. If the callback is missing, they set U_UNSUPPORTED_ERROR. Otherwise they return whatever the callback returns, and the callback may change the status.
  • uenum_next passes a local length slot when the caller gives a null resultLength. uenum_unext forwards the null as ICU does.
  • uenum_close does nothing for null. With a close callback, it frees baseContext (if set) and then calls close. Without one, it frees only the enumeration. Freeing uses the guest free, because ICU's uprv_free defaults to free and 13.42 exports no u_setMemoryFunctions to change it.

A null status with a nonnull enumeration throws APS5_INVALID_ARG_EX, since ICU dereferences it. uenum_reset and the *Default helpers are not in 13.42's exports and are not added. The new debt entry records this, and that no export here creates an enumeration yet.

Depends on #11122 (stacked on it). The agreed ICU order is #11013 → #10961 → … → #10967 → #11088 → #11115 → #11118 → #11122, and this PR comes after #11122. Until those merge, the diff also shows their commits. This PR's own change is the last commit, c1d9fa2f64.

Tested

Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on #11122 (0bcb2ae1aa).

  • New guest_icu_enumeration, using enumerations whose callbacks are APS5_VABI functions:
    • Dispatch of count (the callback's status change is kept), next with and without a length slot, unext (including a forwarded null length), the end of the enumeration, and close.
    • Every short-circuit: a set error, a null enumeration (including with a null status), and missing callbacks (U_UNSUPPORTED_ERROR, with the length left alone).
    • Freeing with a counting application allocator: with a close callback, only baseContext is freed and close is called. Without one, only the enumeration is freed and its baseContext is left alone, as in ICU.
    • The null-status rejections.
  • ctest -R "guest_icu_|patched_libraries": all 7 pass. The NID-patched libSceIcu.prx builds.
  • tools/progress.py --module libSceIcu: 50 implemented, 0 stubs. tools/check_test_registration.py build: 1346 test executables, none built and not run.
  • python3 tools/check_conventions.py --base origin/main passes. Overlap: no open PR implements or names any uenum_ function (checked 2026-10-25).

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: #11122
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007781083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11132). Originally posted by [mantavisual](https://github.com/mantavisual) on 2026-10-25T19:08:20Z. --- ### What Implements the four `uenum_` exports that firmware 13.42's `libSceIcu` has ([BunnyFl's export list](https://github.com/boykopovar/AnyPS5/pull/11013#issuecomment-6401310351)): `uenum_close`, `uenum_count`, `uenum_next` and `uenum_unext`. They don't enumerate anything themselves. They dispatch through the callbacks in a `UEnumeration`, the object ICU's enumeration producers return; 13.42 exports producers such as `ucal_openTimeZones`, `ucol_getKeywordValues` and `ucurr_openISOCurrencies`. Behaviour follows ICU 78.1's [uenum.cpp](https://github.com/unicode-org/icu/blob/release-78.1/icu4c/source/common/uenum.cpp) over the `UEnumeration` layout in [uenumimp.h](https://github.com/unicode-org/icu/blob/release-78.1/icu4c/source/common/uenumimp.h): `baseContext`, `context`, then the `close`, `count`, `uNext`, `next` and `reset` callbacks, 56 bytes. The callbacks are called with the guest ABI (`APS5_VABI`), so an enumeration built by guest code or by a future producer here works the same way. - `uenum_count`, `uenum_next` and `uenum_unext` return −1 or null for a null enumeration without reading the status, and for an error that is already set without calling anything. If the callback is missing, they set `U_UNSUPPORTED_ERROR`. Otherwise they return whatever the callback returns, and the callback may change the status. - `uenum_next` passes a local length slot when the caller gives a null `resultLength`. `uenum_unext` forwards the null as ICU does. - `uenum_close` does nothing for null. With a `close` callback, it frees `baseContext` (if set) and then calls `close`. Without one, it frees only the enumeration. Freeing uses the guest `free`, because ICU's `uprv_free` defaults to `free` and 13.42 exports no `u_setMemoryFunctions` to change it. A null status with a nonnull enumeration throws `APS5_INVALID_ARG_EX`, since ICU dereferences it. `uenum_reset` and the `*Default` helpers are not in 13.42's exports and are not added. The new debt entry records this, and that no export here creates an enumeration yet. **Depends on #11122** (stacked on it). The [agreed ICU order](https://github.com/boykopovar/AnyPS5/pull/11088#issuecomment-6401396662) is #11013 → #10961 → … → #10967 → #11088 → #11115 → #11118 → #11122, and this PR comes after #11122. Until those merge, the diff also shows their commits. This PR's own change is the last commit, `c1d9fa2f64`. ### Tested Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on #11122 (`0bcb2ae1aa`). - New `guest_icu_enumeration`, using enumerations whose callbacks are `APS5_VABI` functions: - Dispatch of `count` (the callback's status change is kept), `next` with and without a length slot, `unext` (including a forwarded null length), the end of the enumeration, and `close`. - Every short-circuit: a set error, a null enumeration (including with a null status), and missing callbacks (`U_UNSUPPORTED_ERROR`, with the length left alone). - Freeing with a counting application allocator: with a `close` callback, only `baseContext` is freed and `close` is called. Without one, only the enumeration is freed and its `baseContext` is left alone, as in ICU. - The null-status rejections. - `ctest -R "guest_icu_|patched_libraries"`: all 7 pass. The NID-patched `libSceIcu.prx` builds. - `tools/progress.py --module libSceIcu`: 50 implemented, 0 stubs. `tools/check_test_registration.py build`: 1346 test executables, none built and not run. - `python3 tools/check_conventions.py --base origin/main` passes. Overlap: no open PR implements or names any `uenum_` function (checked 2026-10-25). ### 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: #11122 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 19:12:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T19:12:49Z.

Review: APPROVED


Reviewed the PR-specific Enumeration.cpp and UEnumeration layout against pinned ICU 78.1 uenum.cpp/uenumimp.h. Null-enumeration and pre-set-error short circuits, missing-callback status, the next dummy length slot, unext null forwarding, and close/baseContext free ordering match the source. The callback types use the guest calling convention and the 56-byte layout matches ICU. I syntax-compiled the changed dispatcher and GuestIcuEnumeration.cpp locally with GCC 12.2 (g++ -std=c++20 -Icore/libs -fsyntax-only); the PR reports Windows guest_icu_enumeration and ctest -R "guest_icu_|patched_libraries" passing. Hosted eligibility, conventions, intake, labels and report pass; product build/test jobs are skipped. This is stacked on #11122, which remains a merge-order dependency.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644820812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11132#pullrequestreview-5644820812). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T19:12:49Z. **Review:** APPROVED --- Reviewed the PR-specific `Enumeration.cpp` and `UEnumeration` layout against pinned ICU 78.1 `uenum.cpp`/`uenumimp.h`. Null-enumeration and pre-set-error short circuits, missing-callback status, the `next` dummy length slot, `unext` null forwarding, and close/baseContext free ordering match the source. The callback types use the guest calling convention and the 56-byte layout matches ICU. I syntax-compiled the changed dispatcher and `GuestIcuEnumeration.cpp` locally with GCC 12.2 (`g++ -std=c++20 -Icore/libs -fsyntax-only`); the PR reports Windows `guest_icu_enumeration` and `ctest -R "guest_icu_|patched_libraries"` passing. Hosted eligibility, conventions, intake, labels and report pass; product build/test jobs are skipped. This is stacked on #11122, which remains a merge-order dependency.
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!11132
No description provided.