feat(libSceJsc): implement WTF::StringImpl::defaultWritingDirection #19772

Merged
nexus7super-ship-it merged 4 commits from upstream-pr/19772 into main 2026-11-17 02:13:25 +00:00
nexus7super-ship-it commented 2026-11-13 22:26:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nexus7super-ship-it on 2026-11-13T22:26:02Z.


What

Implements WTF::StringImpl::defaultWritingDirection(bool*) (libSceJsc, NID vKObO5LG+x8), which threw through NotImplemented_nid_no_patch.

It follows the pinned WebKit StringImpl.cpp that WtfStringSearch.cpp already derives from: for each code unit it asks u_charDirection; the first left-to-right unit returns U_LEFT_TO_RIGHT (0), the first right-to-left or Arabic unit returns U_RIGHT_TO_LEFT (1), and *hasStrongDirectionality is set when the pointer is not null; with no strong unit it returns 0 and sets the flag to false. Like WebKit it walks code units, so a lone surrogate is strong left-to-right. u_charDirection comes from libSceIcu, which libSceJsc now links (the console's JavaScriptCore uses ICU the same way). A null this throws where WebKit faults. The Unicode version gap (ICU 78 here, ICU 68 on the console) is recorded in docs/dev/debt/libSceJsc.md.

#18430, #18442 and #18951 touch the same files but none adds this function.

Tested

Linux (Ubuntu, GCC), Release build with BUILD_TESTING=ON: jsc_wtf_string_search gains Latin, Hebrew, Arabic, neutral, empty, null-flag, surrogate and null-this cases; all 9 libSceJsc tests, nkwebkit_jsc and nkwebkit_jscapibridge pass, as do public_headers, conventions_* and progress_report (129 tests). python3 tools/check_conventions.py --base origin/main passes. No title was run.

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:5303796984 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19772). Originally posted by [nexus7super-ship-it](https://github.com/nexus7super-ship-it) on 2026-11-13T22:26:02Z. --- ### What Implements `WTF::StringImpl::defaultWritingDirection(bool*)` (libSceJsc, NID `vKObO5LG+x8`), which threw through `NotImplemented_nid_no_patch`. It follows the pinned WebKit [StringImpl.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/text/StringImpl.cpp#L1709-L1727) that `WtfStringSearch.cpp` already derives from: for each code unit it asks `u_charDirection`; the first left-to-right unit returns `U_LEFT_TO_RIGHT` (0), the first right-to-left or Arabic unit returns `U_RIGHT_TO_LEFT` (1), and `*hasStrongDirectionality` is set when the pointer is not null; with no strong unit it returns 0 and sets the flag to false. Like WebKit it walks code units, so a lone surrogate is strong left-to-right. `u_charDirection` comes from libSceIcu, which libSceJsc now links (the console's JavaScriptCore uses ICU the same way). A null `this` throws where WebKit faults. The Unicode version gap (ICU 78 here, ICU 68 on the console) is recorded in `docs/dev/debt/libSceJsc.md`. #18430, #18442 and #18951 touch the same files but none adds this function. ### Tested Linux (Ubuntu, GCC), Release build with `BUILD_TESTING=ON`: `jsc_wtf_string_search` gains Latin, Hebrew, Arabic, neutral, empty, null-flag, surrogate and null-`this` cases; all 9 libSceJsc tests, `nkwebkit_jsc` and `nkwebkit_jscapibridge` pass, as do `public_headers`, `conventions_*` and `progress_report` (129 tests). `python3 tools/check_conventions.py --base origin/main` passes. No title was run. ### 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)
PrivacyOnion commented 2026-11-14 03:57:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T03:57:49Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: jsc_wtf_string_search_tests built cleanly.
  • CTest (jsc_wtf_string_search):
    1/1 Test #3403: jsc_wtf_string_search ............   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceJsc/Export.cpp, core/libs/prx/libSceJsc/include/InventoryExports.hpp, core/libs/prx/libSceJsc/include/WtfStringSearchExports.hpp, core/libs/prx/libSceJsc/src/WtfStringSearch.cpp 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/libSceJsc/src/WtfStringSearch.cpp: verified Require(self, func) guards against null this pointers and throws std::invalid_argument instead of faulting.
    • core/libs/prx/libSceJsc/src/WtfStringSearch.cpp: verified hasStrongDirectionality is null-checked before dereferencing on both strong-directionality (true) and fallback (false) branches.
    • core/libs/prx/libSceJsc/src/WtfStringSearch.cpp: verified direction mapping matches pinned WebKit StringImpl.cpp line for line (LeftToRight 0 -> 0, RightToLeft 1 -> 1, RightToLeftArabic 13 -> 1, defaulting to LeftToRight 0).
    • core/libs/prx/libSceJsc/CMakeLists.txt: verified libSceJsc privately links libSceIcu to resolve u_charDirection_nid_postfix, and test environment PATH prepends libSceIcu on Windows.
    • core/libs/prx/libSceJsc/tests/WtfStringSearch.cpp: verified TestDefaultWritingDirection covers 8-bit Latin, 16-bit Hebrew, 16-bit Arabic, neutral strings, empty strings, lone surrogates, nullptr hasStrongDirectionality, and nullptr this pointer.
    • docs/dev/debt/libSceJsc.md: verified the callable NID count in the Additional callable exports section was decremented from 330 to 329 upon removing _ZN3WTF10StringImpl23defaultWritingDirectionEPb, and the Unicode 17 vs 13 version delta is documented under technical debt.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5901452901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19772#pullrequestreview-5901452901). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T03:57:49Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `ba8bdef246`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `jsc_wtf_string_search_tests` built cleanly. - **CTest** (`jsc_wtf_string_search`): ``` 1/1 Test #3403: jsc_wtf_string_search ............ Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceJsc/Export.cpp`, `core/libs/prx/libSceJsc/include/InventoryExports.hpp`, `core/libs/prx/libSceJsc/include/WtfStringSearchExports.hpp`, `core/libs/prx/libSceJsc/src/WtfStringSearch.cpp` 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/libSceJsc/src/WtfStringSearch.cpp: verified Require(self, __func__) guards against null this pointers and throws std::invalid_argument instead of faulting. - core/libs/prx/libSceJsc/src/WtfStringSearch.cpp: verified hasStrongDirectionality is null-checked before dereferencing on both strong-directionality (true) and fallback (false) branches. - core/libs/prx/libSceJsc/src/WtfStringSearch.cpp: verified direction mapping matches pinned WebKit StringImpl.cpp line for line (LeftToRight 0 -> 0, RightToLeft 1 -> 1, RightToLeftArabic 13 -> 1, defaulting to LeftToRight 0). - core/libs/prx/libSceJsc/CMakeLists.txt: verified libSceJsc privately links libSceIcu to resolve u_charDirection_nid_postfix, and test environment PATH prepends libSceIcu on Windows. - core/libs/prx/libSceJsc/tests/WtfStringSearch.cpp: verified TestDefaultWritingDirection covers 8-bit Latin, 16-bit Hebrew, 16-bit Arabic, neutral strings, empty strings, lone surrogates, nullptr hasStrongDirectionality, and nullptr this pointer. - docs/dev/debt/libSceJsc.md: verified the callable NID count in the Additional callable exports section was decremented from 330 to 329 upon removing _ZN3WTF10StringImpl23defaultWritingDirectionEPb, and the Unicode 17 vs 13 version delta is documented under technical debt. - Minor: please drop the `Generated with` footer from the description; 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!19772
No description provided.