feat(libSceNKWebKit): implement WTF::StringImpl::utf8ForCharacters and FileSystemImpl::makeAllDirectories #21270

Merged
Harnoor6693 merged 2 commits from upstream-pr/21270 into main 2026-11-16 19:22:53 +00:00
Harnoor6693 commented 2026-11-16 04:04:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Harnoor6693 on 2026-11-16T04:04:57Z.


What

Implements three libSceNKWebKit WTF exports that were NotImplemented stubs:

  • WTF::StringImpl::utf8ForCharacters for 16-bit characters (takes the ConversionMode: lenient, strict, replacing) and for 8-bit Latin-1 characters. Both reuse the conversion behind StringImpl::utf8. A null buffer with a nonzero length throws; length 0 gives an empty CString.
  • WTF::FileSystemImpl::makeAllDirectories: creates each missing component through the guest stat and mkdir with mode 0700, returns true when the path already exists (including a file), and returns false for a blocked component, a null String or an empty one.

The debt fragment adds both entries as Functional (not compared with a console module; the 0700 mode and the blocked-component result are unmeasured) and removes the three stubs. Layout and behaviour follow pinned WebKit sources; no code was copied.

Tested

  • macOS on Apple silicon (AppleClang, full BUILD_TESTING build, rebased on 1136efb901): ctest -R '^nkwebkit_wtf$' 1 of 1 passed.
  • Ubuntu 26.04 x86-64, GCC 15.2: the same test, 1 of 1 passed at head 4fc3ae8ef6. With makeAllDirectories made to return false the test aborts, so the new assertions catch a broken implementation. The utf8ForCharacters mutation check was run before the final rebase; the rebase only merged this PR's test block with two tests added to tests/Wtf.cpp on main.
  • python3 tools/check_conventions.py --base origin/main and python3 tools/debt_fold.py --check pass.
  • pr_overlap --branch fails closed (24 PRs touch Export.cpp or InventoryExports.hpp and could not be compared). I read each PR's diff: none adds or removes these three exports.
  • Not tested: Windows, a console, any title or homebrew.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

https://claude.ai/code/session_01R6jSFCT3dGPkYpnJPNnPak

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5330828276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21270). Originally posted by [Harnoor6693](https://github.com/Harnoor6693) on 2026-11-16T04:04:57Z. --- ### What Implements three `libSceNKWebKit` WTF exports that were `NotImplemented` stubs: - `WTF::StringImpl::utf8ForCharacters` for 16-bit characters (takes the `ConversionMode`: lenient, strict, replacing) and for 8-bit Latin-1 characters. Both reuse the conversion behind `StringImpl::utf8`. A null buffer with a nonzero length throws; length 0 gives an empty `CString`. - `WTF::FileSystemImpl::makeAllDirectories`: creates each missing component through the guest `stat` and `mkdir` with mode 0700, returns true when the path already exists (including a file), and returns false for a blocked component, a null `String` or an empty one. The debt fragment adds both entries as Functional (not compared with a console module; the 0700 mode and the blocked-component result are unmeasured) and removes the three stubs. Layout and behaviour follow pinned WebKit sources; no code was copied. ### 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. --> - macOS on Apple silicon (AppleClang, full `BUILD_TESTING` build, rebased on `1136efb901`): `ctest -R '^nkwebkit_wtf$'` 1 of 1 passed. - Ubuntu 26.04 x86-64, GCC 15.2: the same test, 1 of 1 passed at head `4fc3ae8ef6`. With `makeAllDirectories` made to return false the test aborts, so the new assertions catch a broken implementation. The `utf8ForCharacters` mutation check was run before the final rebase; the rebase only merged this PR's test block with two tests added to `tests/Wtf.cpp` on `main`. - `python3 tools/check_conventions.py --base origin/main` and `python3 tools/debt_fold.py --check` pass. - `pr_overlap --branch` fails closed (24 PRs touch `Export.cpp` or `InventoryExports.hpp` and could not be compared). I read each PR's diff: none adds or removes these three exports. - Not tested: Windows, a console, any title or homebrew. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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) https://claude.ai/code/session_01R6jSFCT3dGPkYpnJPNnPak
PrivacyOnion commented 2026-11-16 04:13:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T04:13:09Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: nkwebkit_wtf_tests built cleanly.
  • CTest (nkwebkit_wtf):
    1/1 Test #4332: nkwebkit_wtf .....................   Passed    0.06 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/WtfExports.hpp, core/libs/prx/libSceNKWebKit/src/WtfString.cpp, core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WTF::StringImpl::utf8ForCharacters 16-bit and 8-bit overloads in core/libs/prx/libSceNKWebKit/src/WtfString.cpp validate null pointers with non-zero length by throwing std::invalid_argument and delegate properly to ToUTF8.
    • Verified WTF::FileSystemImpl::makeAllDirectories in core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp checks for null/empty paths, converts via _ZNK3WTF6String4utf8ENS_14ConversionModeE, and creates missing directory components with mode 0700 via stat_nid_postfix and mkdir_nid_postfix.
    • Verified Export.cpp, InventoryExports.hpp, WtfExports.hpp, and the technical debt fragment docs/dev/debt/changes/feat-nkwebkit-wtf-utf8-for-characters.md properly remove the three stubbed exports and document the new Functional implementations.
    • Verified unit tests in core/libs/prx/libSceNKWebKit/tests/Wtf.cpp cover UTF-16 conversion modes (lenient, strict, replacing), Latin-1 conversion with embedded nulls, empty/null inputs, nested directory creation, existing files/directories, and cleanup.
    • Checked cross-platform LP64/LLP64 compatibility, #ifndef _WIN32 guards around umask and permission checks in tests, and compliance with AGENTS.md rules.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5914958872 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21270#pullrequestreview-5914958872). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T04:13:09Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `4fc3ae8ef6`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `nkwebkit_wtf_tests` built cleanly. - **CTest** (`nkwebkit_wtf`): ``` 1/1 Test #4332: nkwebkit_wtf ..................... Passed 0.06 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/WtfExports.hpp`, `core/libs/prx/libSceNKWebKit/src/WtfString.cpp`, `core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified WTF::StringImpl::utf8ForCharacters 16-bit and 8-bit overloads in core/libs/prx/libSceNKWebKit/src/WtfString.cpp validate null pointers with non-zero length by throwing std::invalid_argument and delegate properly to ToUTF8. - Verified WTF::FileSystemImpl::makeAllDirectories in core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp checks for null/empty paths, converts via _ZNK3WTF6String4utf8ENS_14ConversionModeE, and creates missing directory components with mode 0700 via stat_nid_postfix and mkdir_nid_postfix. - Verified Export.cpp, InventoryExports.hpp, WtfExports.hpp, and the technical debt fragment docs/dev/debt/changes/feat-nkwebkit-wtf-utf8-for-characters.md properly remove the three stubbed exports and document the new Functional implementations. - Verified unit tests in core/libs/prx/libSceNKWebKit/tests/Wtf.cpp cover UTF-16 conversion modes (lenient, strict, replacing), Latin-1 conversion with embedded nulls, empty/null inputs, nested directory creation, existing files/directories, and cleanup. - Checked cross-platform LP64/LLP64 compatibility, #ifndef _WIN32 guards around umask and permission checks in tests, and compliance with AGENTS.md rules. Looks Good To Me
MarcZX10 commented 2026-11-16 04:36:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T04:36:42Z.

Review: COMMENTED


Reviewed — comments

Changes implement the requested WTF string conversion and directory creation exports; I found one behavior to confirm or adjust before treating the review as complete.

What I ran

  • Reviewed head 4fc3ae8ef65807b55fa124224752a2d759c46ed2 through repo_read.py.
  • No commands or tests were run by me. The build and test results below are author-reported.

Results

Check Result Note
Source review passed Read five included changed files
Author-reported checks not run Linux and macOS test runs reported
Console behavior not run No console comparison reported

Findings

Blocking

None.

Non-blocking

  • The new makeAllDirectories returns true for any existing path, including a regular file (WtfSystem.cpp:117). This matches the PR description but differs from the conventional meaning of “make directories” and may differ from callers’ expectations. Please confirm this is intentional against the relevant WebKit contract, or restrict the success case to directories. The review bundle includes tests that encode the current behavior, but no console comparison.

Not verified

  • Read: WtfExports.hpp, WtfString.cpp, WtfSystem.cpp, tests/Wtf.cpp, review/description.md, review/commits.md, review/manifest.json, and review/diff.patch.
  • Excluded from full-text review: Export.cpp and include/InventoryExports.hpp (too large for the review folder). Their changed hunks were visible in diff.patch; other contents were not read. files.json was not available in the reader listing, so its reviewed/excluded inventory was not verified.
  • No independent tests, console behavior, Windows behavior, or merged-preview check was run.

To get this to a good state

Nothing is required. Optional: confirm the existing-file success behavior against the intended API contract.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5915095375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21270#pullrequestreview-5915095375). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T04:36:42Z. **Review:** COMMENTED --- # Reviewed — comments Changes implement the requested WTF string conversion and directory creation exports; I found one behavior to confirm or adjust before treating the review as complete. ## What I ran - Reviewed head `4fc3ae8ef65807b55fa124224752a2d759c46ed2` through `repo_read.py`. - No commands or tests were run by me. The build and test results below are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Read five included changed files | | Author-reported checks | not run | Linux and macOS test runs reported | | Console behavior | not run | No console comparison reported | ## Findings ### Blocking None. ### Non-blocking - The new `makeAllDirectories` returns true for any existing path, including a regular file (`WtfSystem.cpp:117`). This matches the PR description but differs from the conventional meaning of “make directories” and may differ from callers’ expectations. Please confirm this is intentional against the relevant WebKit contract, or restrict the success case to directories. The review bundle includes tests that encode the current behavior, but no console comparison. ## Not verified - Read: `WtfExports.hpp`, `WtfString.cpp`, `WtfSystem.cpp`, `tests/Wtf.cpp`, `review/description.md`, `review/commits.md`, `review/manifest.json`, and `review/diff.patch`. - Excluded from full-text review: `Export.cpp` and `include/InventoryExports.hpp` (too large for the review folder). Their changed hunks were visible in `diff.patch`; other contents were not read. `files.json` was not available in the reader listing, so its reviewed/excluded inventory was not verified. - No independent tests, console behavior, Windows behavior, or merged-preview check was run. ## To get this to a good state Nothing is required. Optional: confirm the existing-file success behavior against the intended API contract.
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!21270
No description provided.