feat(libSceNKWebKit): implement WKSerializedScriptValue creation and deserialization helpers #15843

Merged
heditrigui merged 5 commits from upstream-pr/15843 into main 2026-11-10 22:33:41 +00:00
heditrigui commented 2026-11-04 18:53:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by heditrigui on 2026-11-04T18:53:35Z.


What

Implements WKSerializedScriptValueCreate and WKSerializedScriptValueDeserialize in libSceNKWebKit (core/libs/prx/libSceNKWebKit/src/SerializedScriptValue.cpp):

  • Implements WKSerializedScriptValueCreate bridging JavaScriptCore values into serialized values using QuickJS JSON stringification (JSValueCreateJSONString), with explicit preservation for undefined, NaN, +Infinity and -Infinity.
  • Implements WKSerializedScriptValueDeserialize restoring serialized values back to JSValueRef in the target execution context (JSValueMakeFromJSONString), setting *exception to an Error object if deserialization fails and an exception pointer is supplied.
  • Employs NKWebKit::ObjectOf<NKWebKit::ObjectType::SerializedScriptValue>, enabling standard WebKit C API reference counting (WKRetain, WKRelease) and runtime type identification (WKGetTypeID, returning 20).
  • Replaces throwing placeholders in Export.cpp and declarations in InventoryExports.hpp, declaring C API in WebKitValueExports.hpp.
  • Decrements throwing additional callable exports count in docs/dev/debt/libSceNKWebKit.md from 6046 to 6044 and documents JSON representation and exception semantics in the functional technical debt section.

Tested

  • Added unit test suite in core/libs/prx/libSceNKWebKit/tests/Base.cpp (TestSerializedScriptValue):
    • Validates type ID returns 20 (WKSerializedScriptValueGetTypeID).
    • Validates null safety on invalid context, value, and serialized object references.
    • Validates round-trip serialization and deserialization of numbers, NaN, +Infinity, -Infinity, booleans, strings, null, and undefined.
    • Validates cross-context deserialization (serialized in primary context, deserialized into secondary context).
    • Validates reference counting and retention lifetime via WKRetain and WKRelease.
    • Validates *exception populated on deserialization failure with invalid JSON.
  • Verified conventions with python tools/check_conventions.py --base upstream/main (0 errors).
  • Verified public headers with python core/libs/tests/test_public_headers.py --audit-only (407 libraries, 33,856 exports).

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:5159825183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15843). Originally posted by [heditrigui](https://github.com/heditrigui) on 2026-11-04T18:53:35Z. --- ### What Implements `WKSerializedScriptValueCreate` and `WKSerializedScriptValueDeserialize` in `libSceNKWebKit` (`core/libs/prx/libSceNKWebKit/src/SerializedScriptValue.cpp`): - Implements `WKSerializedScriptValueCreate` bridging JavaScriptCore values into serialized values using QuickJS JSON stringification (`JSValueCreateJSONString`), with explicit preservation for `undefined`, `NaN`, `+Infinity` and `-Infinity`. - Implements `WKSerializedScriptValueDeserialize` restoring serialized values back to `JSValueRef` in the target execution context (`JSValueMakeFromJSONString`), setting `*exception` to an Error object if deserialization fails and an exception pointer is supplied. - Employs `NKWebKit::ObjectOf<NKWebKit::ObjectType::SerializedScriptValue>`, enabling standard WebKit C API reference counting (`WKRetain`, `WKRelease`) and runtime type identification (`WKGetTypeID`, returning 20). - Replaces throwing placeholders in `Export.cpp` and declarations in `InventoryExports.hpp`, declaring C API in `WebKitValueExports.hpp`. - Decrements throwing additional callable exports count in `docs/dev/debt/libSceNKWebKit.md` from 6046 to 6044 and documents JSON representation and exception semantics in the functional technical debt section. ### Tested - Added unit test suite in `core/libs/prx/libSceNKWebKit/tests/Base.cpp` (`TestSerializedScriptValue`): - Validates type ID returns 20 (`WKSerializedScriptValueGetTypeID`). - Validates null safety on invalid context, value, and serialized object references. - Validates round-trip serialization and deserialization of numbers, NaN, +Infinity, -Infinity, booleans, strings, null, and undefined. - Validates cross-context deserialization (serialized in primary context, deserialized into secondary context). - Validates reference counting and retention lifetime via `WKRetain` and `WKRelease`. - Validates `*exception` populated on deserialization failure with invalid JSON. - Verified conventions with `python tools/check_conventions.py --base upstream/main` (0 errors). - Verified public headers with `python core/libs/tests/test_public_headers.py --audit-only` (407 libraries, 33,856 exports). ### 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
adriadam10 commented 2026-11-09 18:54:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-09T18:54:50Z.

Review: CHANGES_REQUESTED


Thanks for the work. Blocking items:

  • core/libs/prx/libSceNKWebKit/tests/Base.cpp contains the whole file twice: the using WKPoint/Check/Require/TestTypeIDs/main block appears at lines 24-1752 and again at 1805-3546, so it does not compile (redefinitions, two main). It comes from the merge-of-main commits. Please restore Base.cpp from main and re-add only TestSerializedScriptValue, its call in main and the WKSerializedScriptValueGetTypeID() == 20 check.
  • The branch conflicts with main in Export.cpp, InventoryExports.hpp and docs/dev/debt/libSceNKWebKit.md. Please rebase onto main (a clean rebase instead of the repeated merge commits would also help).
  • WKSerializedScriptValueDeserialize ignores exception and the debt line says failures are reported; either set *exception when JSValueMakeFromJSONString fails or reword the line.
  • The body says the count goes 7429 → 7427, but the debt file changes 6315 → 6313; make the body match.
  • The windows check is red on this head; please check it after the rebase.

The implementation in SerializedScriptValue.cpp looks fine otherwise.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5831003444 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15843#pullrequestreview-5831003444). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-09T18:54:50Z. **Review:** CHANGES_REQUESTED --- Thanks for the work. Blocking items: - `core/libs/prx/libSceNKWebKit/tests/Base.cpp` contains the whole file twice: the `using WKPoint`/`Check`/`Require`/`TestTypeIDs`/`main` block appears at lines 24-1752 and again at 1805-3546, so it does not compile (redefinitions, two `main`). It comes from the merge-of-main commits. Please restore `Base.cpp` from `main` and re-add only `TestSerializedScriptValue`, its call in `main` and the `WKSerializedScriptValueGetTypeID() == 20` check. - The branch conflicts with `main` in `Export.cpp`, `InventoryExports.hpp` and `docs/dev/debt/libSceNKWebKit.md`. Please rebase onto `main` (a clean rebase instead of the repeated merge commits would also help). - `WKSerializedScriptValueDeserialize` ignores `exception` and the debt line says failures are reported; either set `*exception` when `JSValueMakeFromJSONString` fails or reword the line. - The body says the count goes 7429 → 7427, but the debt file changes 6315 → 6313; make the body match. - The `windows` check is red on this head; please check it after the rebase. The implementation in `SerializedScriptValue.cpp` looks fine otherwise.
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!15843
No description provided.