Repository navigation
feat(tools): generate Export.cpp skeletons from missing NIDs - #552
Conversation
|
Thanks. Generating the throwing stubs from the NID database is useful, but the hardcoded bodies would spread semantics that don't match Sony's CRT into every Export.cpp made with it:
I'd keep the generator to stubs named from the database and leave real bodies to hand-written PRs with tests. @boykopovar, would you want a generator like that in |
|
Reworked per review: the generator now emits throwing stubs only — the whole hardcoded CRT body table is gone, so no non-Sony semantics can spread. Database names become prefix+CamelCase throwing stubs, everything else collision-free UnknownNN. All comments and the module docstring are removed (shebang only), as is the generated // name line. The description now says the DB input is a plain NID-name CSV like aerolib.csv. Description also updated accordingly. |
|
Thanks. The bodies and comments are gone, so the generator now only writes throwing stubs, and the description matches the input format (the same whitespace-separated file One thing about the names it generates: a NID with a database name becomes a made-up The open question is still @boykopovar's: whether a generator like this belongs in |
3df2745 to
40c6747
Compare
|
Reworked per review:
The open question on whether a generator like this belongs in |
|
Thanks, this covers what I asked. Recomputing names are written as plain exports, C and C++ runtime names get the Two small things:
Whether the generator belongs in |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the rework. The two points from the last review are still open on the current head:
compute_nid,SUFFIXandCHARSET(tools/stubgen.py:8-10,:77-88) are still a copy oftools/nid_names.py. Import them from there so the NID scheme has a single definition.- The default TechnicalDebt path for
--module libkernel(tools/stubgen.py:107-108) iscore/libs/prx/libkernel/Export.cpp, which doesn't exist (libkernel's unknown stubs are inUnimplemented.cpp). Drop that special case or point it at the real file; thelibc/libkernelbranches oftd_libare the same as the default and can go too.
Also, a small thing: please add a sample run (input NIDs, DB lines and the generated output) to the PR description, including one NID that falls back to UnknownNN, so reviewers can check the output without running it.
@boykopovar: the open question from Dean's review stands: should this generator live in tools/ at all?
40c6747 to
4a6775c
Compare
|
Thanks for the follow-up — both done, rebased onto current origin/main (f8c2f07).
The |
adriadam10
left a comment
There was a problem hiding this comment.
Checked tools/stubgen.py on a synthetic DB with libkernel and libSceAmpr, as a script and with python -m tools.stubgen: real names plain, _/CRT names as _nid_postfix, unknown or non-recomputing NIDs as UnknownNN through APS5_EXPORT, and the libkernel TechnicalDebt path now points to Unimplemented.cpp. NID scheme is imported from tools/nid_names.py.
The conventions check was failing only on the unchecked Depends on: none; I ticked it in the PR body (no dependencies). Merging once CI is green.
What
New contributor tool tools/stubgen.py: given a missing-NIDs list (one 11-char NID per line) plus a NID->name CSV mapping (NID name per line, as in aerolib.csv), it emits an Export.cpp skeleton of throwing stubs following repo conventions: a database name that recomputes to the NID (same SHA1+salt scheme as tools/nid_names.py) is emitted as the real name directly as a plain export, C/C++ runtime names (leading
_or bare CRT likewcstombs_s/swscanf_s) in<real>_nid_postfixplain-definition form, anything else (no DB hit or NID mismatch) as collision-freeUnknownNNexported throughAPS5_EXPORT, every body aNotImplemented_nid_no_patch("NID")throw with a dummy return. It also emits the TechnicalDebt line per stub (unknown signaturefor real names,unknown name, signaturefor UnknownNN) with the target path/lib derived from--module(--td-path/--td-liboverride,--td-out/--td-onlyfor TD output). Real bodies are intentionally out of scope and stay hand-written. Stdlib only, no new dependencies, no comments in code or output.Tested
sce*emits plain,_-leading and bare-CRT names (_Thrd_sleep,wcstombs_s,swscanf_s,__cxa_*,_ZTV*,pthread_*,malloc) emit_nid_postfix, unknown NIDs and mismatched DB names fall back toUnknownNN+APS5_EXPORT, TD lines use derivedcore/libs/prx/MODULE/Export.cpppaths (libc/libkernel mapped, overrides work), no// namelines in output.Checklist