feat(libSceIcu): implement field position iterator C API #19435

Merged
AlexWhitehouse merged 1 commit from upstream-pr/19435 into main 2026-11-19 11:52:24 +00:00
AlexWhitehouse commented 2026-11-13 09:33:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-13T09:33:20Z.


What

libSceIcu's field-position iterator C API threw not implemented. #17265 had already given ufieldpositer_open and ufieldpositer_close their signatures and early returns. This PR implements the rest of those two, plus ufieldpositer_next:

Export NID
ufieldpositer_open Ns2ep8k12aw
ufieldpositer_close mANYKKAD1dg
ufieldpositer_next v9QRrGYy3lk
  • Sources: the ICU revision the repository already builds (049e0d6a, ICU 78.1). These files are compiled unchanged into icu_i18n:

    The three small FieldPosition methods they need (RTTI, destructor and clone) are ported from format.cpp into FieldPositionBackend.cpp, which starts with that file's notice. Building the whole of format.cpp would pull in locale and formatting code. I checked ICU 68.2, which the library's other early-return entries cite: these C functions behave the same there.

  • Behaviour:

    • open leaves an incoming failure status as is and returns null. Otherwise it creates an iterator and keeps the incoming status, so a warning survives.
    • next returns the next field and writes its begin and end through whichever pointers aren't null. Once the iterator is exhausted, it returns -1 and leaves both outputs unchanged.
    • close(nullptr) does nothing.
  • Handles: the library records the iterators it creates, as its other opaque-handle wrappers do.

    • next or close on a handle it didn't create throws, so the existing foreign-handle assertions still hold.
    • A null status pointer also throws.
  • Debt (as a fragment, docs/dev/debt/changes/feat-libsceicu-field-position-iterator.md):

    • the ufieldpositer_next placeholder moves out of RecoveredInventory.cpp, so the count of remaining placeholders drops from 48 to 47 (the entry on main still says 49 after uscript_getCode left it). open and close were already outside it;
    • the iterator entry now records the unmeasured console ABI and ICU-version equivalence, and that no guest formatter fills these iterators yet.

Tested

  • New test: guest_icu_field_position_iterator (core/libs/prx/libSceIcu/tests/FieldPositionIteratorBehavior.cpp) covers:
    • open with success and warning statuses, and failure statuses returning null with the status unchanged;
    • empty iteration returning -1 with outputs unchanged, including with null output pointers;
    • two independent iterators filled in different orders through ICU's FieldPositionIteratorHandler, iterated in insertion order and then exhausted;
    • a null status, a null handle and a foreign handle throwing, and close(nullptr).
  • Linux x86-64 (Ubuntu 26.04, GCC 15, Release):
    • on main, the test fails with ufieldpositer_open_nid_postfix not implemented;
    • with this PR, guest_icu_field_position_iterator, guest_icu_recovered_signatures (existing assertions unchanged) and public_headers pass.
  • Windows 11 (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): guest_icu_field_position_iterator, guest_icu_recovered_signatures, patched_libraries and public_headers pass at 477e77f654. libSceIcu.prx relinks with no warnings in the changed files and no duplicate or undefined ICU symbols. The branch was then rebased onto current main without conflicts, and the focused tests pass again on Linux.
  • Mutation check: swapping the begin and end outputs fails the index assertion.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • python3 tools/pr_overlap.py: no open PR implements these exports.
    • It couldn't compare seven PRs automatically; I checked their diffs by hand. #14144, #14340, #14443, #18208 and my #16971 only append to the libSceIcu or ICU CMake files.
    • #18210 also changes the recovered-inventory count. Whichever merges second recounts.

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:5293299686 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19435). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-13T09:33:20Z. --- ### What libSceIcu's field-position iterator C API threw `not implemented`. #17265 had already given `ufieldpositer_open` and `ufieldpositer_close` their signatures and early returns. This PR implements the rest of those two, plus `ufieldpositer_next`: | Export | NID | |---|---| | `ufieldpositer_open` | `Ns2ep8k12aw` | | `ufieldpositer_close` | `mANYKKAD1dg` | | `ufieldpositer_next` | `v9QRrGYy3lk` | - **Sources:** the ICU revision the repository already builds (049e0d6a, ICU 78.1). These files are compiled unchanged into `icu_i18n`: - [`ufieldpositer.cpp`](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/i18n/ufieldpositer.cpp); - [`fpositer.cpp`](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/i18n/fpositer.cpp); - [`fphdlimp.cpp`](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/i18n/fphdlimp.cpp). The three small `FieldPosition` methods they need (RTTI, destructor and `clone`) are ported from [`format.cpp`](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/i18n/format.cpp) into `FieldPositionBackend.cpp`, which starts with that file's notice. Building the whole of `format.cpp` would pull in locale and formatting code. I checked ICU 68.2, which the library's other early-return entries cite: these C functions behave the same there. - **Behaviour:** - `open` leaves an incoming failure status as is and returns null. Otherwise it creates an iterator and keeps the incoming status, so a warning survives. - `next` returns the next field and writes its begin and end through whichever pointers aren't null. Once the iterator is exhausted, it returns -1 and leaves both outputs unchanged. - `close(nullptr)` does nothing. - **Handles:** the library records the iterators it creates, as its other opaque-handle wrappers do. - `next` or `close` on a handle it didn't create throws, so the existing foreign-handle assertions still hold. - A null status pointer also throws. - **Debt** (as a fragment, `docs/dev/debt/changes/feat-libsceicu-field-position-iterator.md`): - the `ufieldpositer_next` placeholder moves out of `RecoveredInventory.cpp`, so the count of remaining placeholders drops from 48 to 47 (the entry on `main` still says 49 after `uscript_getCode` left it). `open` and `close` were already outside it; - the iterator entry now records the unmeasured console ABI and ICU-version equivalence, and that no guest formatter fills these iterators yet. ### Tested - **New test:** `guest_icu_field_position_iterator` (`core/libs/prx/libSceIcu/tests/FieldPositionIteratorBehavior.cpp`) covers: - `open` with success and warning statuses, and failure statuses returning null with the status unchanged; - empty iteration returning -1 with outputs unchanged, including with null output pointers; - two independent iterators filled in different orders through ICU's `FieldPositionIteratorHandler`, iterated in insertion order and then exhausted; - a null status, a null handle and a foreign handle throwing, and `close(nullptr)`. - **Linux x86-64** (Ubuntu 26.04, GCC 15, Release): - on `main`, the test fails with `ufieldpositer_open_nid_postfix not implemented`; - with this PR, `guest_icu_field_position_iterator`, `guest_icu_recovered_signatures` (existing assertions unchanged) and `public_headers` pass. - **Windows 11** (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): `guest_icu_field_position_iterator`, `guest_icu_recovered_signatures`, `patched_libraries` and `public_headers` pass at 477e77f654. `libSceIcu.prx` relinks with no warnings in the changed files and no duplicate or undefined ICU symbols. The branch was then rebased onto current `main` without conflicts, and the focused tests pass again on Linux. - **Mutation check:** swapping the begin and end outputs fails the index assertion. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - **`python3 tools/pr_overlap.py`:** no open PR implements these exports. - It couldn't compare seven PRs automatically; I checked their diffs by hand. #14144, #14340, #14443, #18208 and my #16971 only append to the libSceIcu or ICU CMake files. - #18210 also changes the recovered-inventory count. Whichever merges second recounts. ### 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)
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!19435
No description provided.