Skip to content

feat(libSceNpCppWebApi): read size and operator[] of the Sku, Container and PlayerSession vectors from host bodies - #11248

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
AlexFigas:feat/npcppwebapi-vector-size-and-index
Oct 26, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
AlexFigas:feat/npcppwebapi-vector-size-and-index

Conversation

@AlexFigas

Copy link
Copy Markdown
Contributor

What

Four Vector accessors were NotImplemented stubs:

  • Vector<IntrusivePtr<InGameCatalog::V5::Sku>>::size
  • Vector<IntrusivePtr<InGameCatalog::V5::Container>>::size
  • Vector<IntrusivePtr<InGameCatalog::V5::Container>>::operator[]
  • Vector<IntrusivePtr<SessionManager::V1::PlayerSession>>::operator[]

They now do what the empty, size and operator[] of the other element types already do, which the Vector debt entries describe:

  • size returns 0 for a vector that has no body and the element count of a body this library created. It throws on any other body.
  • operator[] returns the element of a body this library created that holds IntrusivePtr elements. It throws when the vector has no body or holds anything else.

Two shared helpers, HostVectorSize and HostVectorElement, hold this logic.

The module bundled with PPSA21564 (sce_module/libSceNpCppWebApi.prx, the library's own code) computes the same values on its own layout:

Export Module
Vector<...Sku>::size (0xc23d0), Vector<...Container>::size (0xa8290) (end - begin) / 0x18, from [rdi + 0x28] - [rdi + 0x18]
Vector<...Container>::operator[] (0xa8390), Vector<...PlayerSession>::operator[] (0x287f50) begin + index * 0x18, no bounds check

operator[] here has no bounds check either.

The size of Vector<IntrusivePtr<UserProfile::V1::BasicPresence>> and of Vector<unsigned long> is the same one-liner. I left it out because the UserProfile debt line that says they throw sits next to the line #10832 rewrites. It can follow once that PR lands.

Tested

On Ubuntu 24.04 under WSL2 (GCC 13.3, Release), ctest --test-dir build -R np_cpp_web_api passes all 4 tests. guest_np_cpp_web_api_offline gains TestVectorSizeAndElements, which checks:

  • both sizes return 0 for a vector without a body, and both operator[]s throw on one;
  • after two pushBacks through the JoinableUser vector, both sizes return 2, and both operator[]s return the two elements in order and next to each other;
  • destroying the vector gives back the references it took;
  • every accessor throws on a foreign body.

Also 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

…er and PlayerSession vectors from host bodies

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the shared helpers against the existing VectorBody layout and append/destructor paths. HostVectorSize handles a null body and rejects foreign bodies; HostVectorElement additionally restricts access to the intrusive-pointer element kind. The four exports use the helper matching their ABI, and the new test exercises null/owned/foreign bodies, contiguous order, and retained references. The lack of an operator[] bounds check matches the documented operator[] behavior and the bundled module evidence.

git diff --check and current-main conventions pass. The author reports the focused np_cpp_web_api CTest suite passing 4/4 under Ubuntu 24.04/WSL2. I did not rerun the product test locally because the available build is relinker-only; hosted product jobs are skipped by policy. No concrete defect found.

@babyhuey

Copy link
Copy Markdown
Contributor

Windows run of this head 4d0cd9a53e1, merged onto main 9b197b6ce45 (clean merge, local only), with the selection CI's skipped Windows product job uses: Windows 11, Ryzen 7 5800X, RTX 3080, WinLibs GCC 15.2, Release, BUILD_TESTING=ON. The tree was configured fresh after the merge, then select_tests.py select / ninja -f select.ninja selected / --target libs / select_tests.py ctest --parallel 4 --timeout 120, with check_skips.py --job windows (all skips expected).

  • Selected 378 tests: 371 pass, 1 fails, pr_overlap_encoding, which also fails on 9b197b6ce45 itself on this machine. No failures from this PR.

AI-assisted: yes (Claude Code)

@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 9612 core/libs/prx/libSceNpCppWebApi/Export.cpp

@oneandonlydean
oneandonlydean merged commit 9359e44 into boykopovar:main Oct 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants