feat(libSceNKWebKit): implement WTF::StringPrintStream #20404
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20404"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-15T05:19:55Z.
What
Implements the 11 exports of
WTF::StringPrintStream, WTF's print-into-a-stringPrintStream, following the pinned StringPrintStream.cpp (identical ate12a212a531a, the revision the URL parser follows):C1,C2): the buffer starts as the 128-byte inline buffer, empty and NUL-terminated.vprintf(const char*, va_list): the source's two passes. The first formats into the remaining space through a copy of the guestva_list(a struct copy, which isva_copyfor the System Vva_list); if the text does not fit, the buffer grows to twice the needed size (fastMalloc, old contents copied, old heap buffer freed) and the second pass formats with the caller's list. Formatting is guestvsnprintf.toCString,toString(String::fromUTF8, null for invalid UTF-8),toStringWithLatin1Fallback, andtryToString, which returnsExpected<String, UTF8ConversionError>withOutOfMemorypastString::MaxLength.reset: empties the text and keeps the buffer, heap or inline.D1,D2, andD0, which alsofastFrees the object, asWTF_MAKE_FAST_ALLOCATEDdoes).Layouts, with
static_asserts inStringPrintStreamExports.hpp, were measured on a Linux build of WTF: the 160-byte object (vtable pointer, buffer, write position at 16, size at 24, inline buffer at 32) and the 16-byteExpected(value or error code at 0, has-value byte at 8,OutOfMemory= 1).The constructor installs a vtable built here with the source's slot order (checked with
-fdump-lang-class): complete and deleting destructors,vprintf,flush(empty, asPrintStream::flushis), then thePrintStream::beginandPrintStream::endexports.PrintStream::endis still a placeholder (#19380 implements it), soprintthrough the stream throws until that lands;vprintfand the conversions do not depend on it. The empty flush slot is a localAPS5_VABIfunction, soprogress.pylists it among the inert names, as it doesWtfJson.cpp's vtable slots.A null object, format or argument list throws, and so does a failed format, where the source would move its write position backwards.
Debt: a fragment,
docs/dev/debt/changes/feat-nkwebkit-string-print-stream.md, adds the entry under Functional and removes the 11 inventory rows.Tested
Linux Mint 22.3:
nkwebkit_stringprintstreamtest: construction over poisoned storage (both constructors), every vtable slot against the export it should hold, callingvprintf,flushandbeginthrough the vtable as guest code does, and the deleting destructor through slot 1 on afastMalloc'd stream. Buffer growth matches WTF built for Linux for the same sequences: three 120-character prints (position 360, size 482), one 1000-character print (size 2002), 127 characters staying inline then one more growing to 258, fifty short prints (140, 258), andresetkeeping the 482-byte heap buffer. AlsotoCString, UTF-8 and invalid UTF-8 throughtoString,toStringWithLatin1FallbackandtryToString, and the null refusals. The test passes a real System Vva_liston both Linux and Windows builds (__builtin_sysv_va_start, asFileHandle::printfdoes).ctest -R nkwebkit: 91 tests passed.progress.py --module libSceNKWebKit: the 11 exports move to implemented.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T22:36:04Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and its focused tests look consistent with the stated behavior, but the build and tests were not run during this review.
What I ran
Reviewed head
8bdcc2572228bb01e0b6919bd64f7d695ed8f09eusing the prepared diff andrepo_read.py. I did not run build or test commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and test results were not independently confirmed. The full text of
Export.cppandInventoryExports.hppwas excluded as too large; I reviewed the affected hunks in the prepared diff and the corresponding head ranges. No other changed files were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:00:47Z.
Review: COMMENTED
Built the exact changed sources and ran
StringPrintStreamon Linux against the existing WebKit runtime. The constructor, vtable, and string output checks passed.AI-assisted: yes.
Pull request closed