feat(libSceIcu): implement Unicode script properties #18331

Merged
fogydes merged 2 commits from upstream-pr/18331 into main 2026-11-12 20:47:57 +00:00
fogydes commented 2026-11-11 09:20:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-11-11T09:20:03Z.


What

Calls to ten Unicode script-property exports currently throw immediately. Implement their ICU C behavior with typed System V adapters: script lookup and membership, long/short names, extension lists, usage/direction/case/line-break metadata, and UTF-16 sample strings. Extension queries copy the fitting prefix on overflow; sample queries never copy an incomplete surrogate pair. Native enum arrays and status values are staged without aliasing guest int32_t buffers. Build uscript_props.cpp on every host instead of Windows only.

This slice comes from the current ICU debt and the PS5 3.20 export inventory. Behavior and signatures follow existing submodule ICU 78.1 at 049e0d6a420629ac7db77256987d083a563287b5: uchar.cpp, propname.cpp, uscript_props.cpp, and unicode/uscript.h. The latter's prose says getScript returns 0 for invalid code points, while the implementation returns -1; this follows the implementation. No new dependency or shipped module is added.

Measurement Before After
progress.py --module libSceIcu: implemented 192 199
TODO, including partial implementations 2550 2543
Total inventoried functions 2742 2742
export_gap.py against the cited 661-NID table: missing 25 25
Already provided / unknown 636 / 0 636 / 0

Ten unconditional stubs gain behavior. The tracker still classifies the three status/buffer APIs as TODO because unusable guest memory deliberately calls NotImplemented_nid_no_patch; those guards are retained. Presence coverage is unchanged because all ten NIDs already resolved as stubs. uscript_getCode remains unimplemented because locale resources are unavailable.

Console ABI, Unicode-data version and title compatibility are unverified: the implementation uses ICU 78.1 / Unicode 17.0, while the legacy inventory has ICU 68-era names. The debt entry records this, pointer-safety behavior, and the header/source disagreement. No console or title-unblock claim.

Tested

  • Windows, MinGW-w64 GCC: rebuilt libSceIcu, runtime dependencies and all 35 ICU guest test executables; ctest --test-dir build-full -R '^guest_icu_' --output-on-failure -j 6: 35/35 passed. New tests check code-point and script boundaries, Unicode extension sets, invalid inputs, warning/error propagation, partial/exact buffers, supplementary samples and untouched sentinels. Expected extension sets come from pinned ppucd.txt.
  • Rebuilt nid_patcher, regenerated the libc preserve list, patched the produced PE library and verified all ten script NIDs in its export table.
  • python core/libs/tests/test_public_headers.py --audit-only: 407 libraries, 33941 exports, unique declarations and umbrella coverage verified.
  • python tools/check_conventions.py --base origin/main and git diff --check: passed.
  • python tools/pr_overlap.py --branch feat/libSceIcu-script-properties: exit 2 because 19 other PRs conflict with its current base. Completed the required manual comparison of all 19 plus the 3 confirmed line-overlap PRs (22 exact heads). None implements these ten functions or supplies a semantic prerequisite. #14340/#14443 relocate unchanged throwing script stubs and retain textual integration conflicts. #16872 shares a CMake insertion point; #16971/#17646 share debt edits. Other stale inventory/debt rewrites can require rebasing. This is not a claim that the automated overlap report is clean.
  • Debian / WSL, GCC: built the runtime and guest_icu_script_tests; ctest -R '^guest_icu_script$' --output-on-failure: 1/1 passed. The unchanged revision-metadata CMake script ran via Windows Git because the native Git submodule scan over /mnt/d stalled compilation; the compiler, linker and test ran on Linux, and the temporary generated-build recipe was restored afterward.

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:5256898840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18331). Originally posted by [fogydes](https://github.com/fogydes) on 2026-11-11T09:20:03Z. --- ### What Calls to ten Unicode script-property exports currently throw immediately. Implement their ICU C behavior with typed System V adapters: script lookup and membership, long/short names, extension lists, usage/direction/case/line-break metadata, and UTF-16 sample strings. Extension queries copy the fitting prefix on overflow; sample queries never copy an incomplete surrogate pair. Native enum arrays and status values are staged without aliasing guest `int32_t` buffers. Build `uscript_props.cpp` on every host instead of Windows only. This slice comes from the current ICU debt and the [PS5 3.20 export inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceIcu.c#L5232-L5241). Behavior and signatures follow existing submodule ICU 78.1 at `049e0d6a420629ac7db77256987d083a563287b5`: [uchar.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/uchar.cpp#L534-L621), [propname.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/propname.cpp#L325-L335), [uscript_props.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/uscript_props.cpp#L273-L321), and `unicode/uscript.h`. The latter's prose says `getScript` returns 0 for invalid code points, while the implementation returns -1; this follows the implementation. No new dependency or shipped module is added. | Measurement | Before | After | | --- | ---: | ---: | | `progress.py --module libSceIcu`: implemented | 192 | 199 | | TODO, including partial implementations | 2550 | 2543 | | Total inventoried functions | 2742 | 2742 | | `export_gap.py` against the cited 661-NID table: missing | 25 | 25 | | Already provided / unknown | 636 / 0 | 636 / 0 | Ten unconditional stubs gain behavior. The tracker still classifies the three status/buffer APIs as TODO because unusable guest memory deliberately calls `NotImplemented_nid_no_patch`; those guards are retained. Presence coverage is unchanged because all ten NIDs already resolved as stubs. `uscript_getCode` remains unimplemented because locale resources are unavailable. Console ABI, Unicode-data version and title compatibility are unverified: the implementation uses ICU 78.1 / Unicode 17.0, while the legacy inventory has ICU 68-era names. The debt entry records this, pointer-safety behavior, and the header/source disagreement. No console or title-unblock claim. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Windows, MinGW-w64 GCC: rebuilt `libSceIcu`, runtime dependencies and all 35 ICU guest test executables; `ctest --test-dir build-full -R '^guest_icu_' --output-on-failure -j 6`: **35/35 passed**. New tests check code-point and script boundaries, Unicode extension sets, invalid inputs, warning/error propagation, partial/exact buffers, supplementary samples and untouched sentinels. Expected extension sets come from pinned `ppucd.txt`. - Rebuilt `nid_patcher`, regenerated the libc preserve list, patched the produced PE library and verified all ten script NIDs in its export table. - `python core/libs/tests/test_public_headers.py --audit-only`: **407 libraries, 33941 exports**, unique declarations and umbrella coverage verified. - `python tools/check_conventions.py --base origin/main` and `git diff --check`: passed. - `python tools/pr_overlap.py --branch feat/libSceIcu-script-properties`: exit 2 because 19 other PRs conflict with its current base. Completed the required manual comparison of all 19 plus the 3 confirmed line-overlap PRs (22 exact heads). None implements these ten functions or supplies a semantic prerequisite. #14340/#14443 relocate unchanged throwing script stubs and retain textual integration conflicts. #16872 shares a CMake insertion point; #16971/#17646 share debt edits. Other stale inventory/debt rewrites can require rebasing. This is not a claim that the automated overlap report is clean. - Debian / WSL, GCC: built the runtime and `guest_icu_script_tests`; `ctest -R '^guest_icu_script$' --output-on-failure`: **1/1 passed**. The unchanged revision-metadata CMake script ran via Windows Git because the native Git submodule scan over `/mnt/d` stalled compilation; the compiler, linker and test ran on Linux, and the temporary generated-build recipe was restored afterward. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
PrivacyOnion commented 2026-11-11 15:55:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T15:55:34Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 64dadcfa9b:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_icu_script_tests, libSceIcu built cleanly.
  • CTest (guest_icu_script):
    1/1 Test #3133: guest_icu_script .................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceIcu/Script.cpp: Verified all 10 Unicode script property exports (uscript_getScript, uscript_hasScript, uscript_getShortName, uscript_getName, uscript_getScriptExtensions, uscript_getUsage, uscript_isRightToLeft, uscript_breaksBetweenLetters, uscript_isCased, uscript_getSampleString) correctly validate inputs against USCRIPT_CODE_LIMIT via NativeScript and properly delegate to ICU 78.1 C APIs.
    • core/libs/prx/libSceIcu/Script.cpp: Validated guest memory safety and buffer bounds in uscript_getScriptExtensions_nid_postfix and uscript_getSampleString_nid_postfix; confirmed staging buffers prevent direct guest pointer aliasing and that preflighting, negative capacities, null pointers, and buffer overflows are handled safely without out-of-bounds writes.
    • core/libs/prx/libSceIcu/Script.cpp: Verified error and warning propagation semantics, including preservation of incoming warnings (such as U_USING_DEFAULT_WARNING), updating error status on failure (U_ILLEGAL_ARGUMENT_ERROR, U_BUFFER_OVERFLOW_ERROR), and handling of U_STRING_NOT_TERMINATED_WARNING (-124) when strings fit without null termination.
    • cmake/Icu.cmake & core/libs/prx/libSceIcu/CMakeLists.txt: Confirmed uscript_props.cpp is compiled on all platforms in icu_common, Script.cpp is integrated into libSceIcu, and guest_icu_script_tests is configured with unwind and library search paths for CTest.
    • AGENTS.md & docs/dev/debt/libSceIcu.md: Verified strict compliance with project rules: zero code comments, no title-specific special-casing or fake success stubs, clean removal of 10 stubs from Export.cpp and LegacyExports.cpp, and comprehensive recording of ICU 78.1 vs legacy console inventory differences in libSceIcu.md.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5861539278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18331#pullrequestreview-5861539278). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-11T15:55:34Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `64dadcfa9b`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_icu_script_tests`, `libSceIcu` built cleanly. - **CTest** (`guest_icu_script`): ``` 1/1 Test #3133: guest_icu_script ................. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceIcu/Script.cpp: Verified all 10 Unicode script property exports (uscript_getScript, uscript_hasScript, uscript_getShortName, uscript_getName, uscript_getScriptExtensions, uscript_getUsage, uscript_isRightToLeft, uscript_breaksBetweenLetters, uscript_isCased, uscript_getSampleString) correctly validate inputs against USCRIPT_CODE_LIMIT via NativeScript and properly delegate to ICU 78.1 C APIs. - core/libs/prx/libSceIcu/Script.cpp: Validated guest memory safety and buffer bounds in uscript_getScriptExtensions_nid_postfix and uscript_getSampleString_nid_postfix; confirmed staging buffers prevent direct guest pointer aliasing and that preflighting, negative capacities, null pointers, and buffer overflows are handled safely without out-of-bounds writes. - core/libs/prx/libSceIcu/Script.cpp: Verified error and warning propagation semantics, including preservation of incoming warnings (such as U_USING_DEFAULT_WARNING), updating error status on failure (U_ILLEGAL_ARGUMENT_ERROR, U_BUFFER_OVERFLOW_ERROR), and handling of U_STRING_NOT_TERMINATED_WARNING (-124) when strings fit without null termination. - cmake/Icu.cmake & core/libs/prx/libSceIcu/CMakeLists.txt: Confirmed uscript_props.cpp is compiled on all platforms in icu_common, Script.cpp is integrated into libSceIcu, and guest_icu_script_tests is configured with unwind and library search paths for CTest. - AGENTS.md & docs/dev/debt/libSceIcu.md: Verified strict compliance with project rules: zero code comments, no title-specific special-casing or fake success stubs, clean removal of 10 stubs from Export.cpp and LegacyExports.cpp, and comprehensive recording of ICU 78.1 vs legacy console inventory differences in libSceIcu.md. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!18331
No description provided.