Repository navigation
tsbindgen: lay out std::string, static_vector and the other fields it skipped - #564
Merged
Merged
Conversation
- Updated `nameFromKey` to correctly handle template arguments in names. - Modified `Collector` to ensure operators without names are excluded from declarations. - Introduced new functions in `TypeMapper` to handle template specializations and instantiations. - Enhanced `mapType` to support arrays and bitfields, ensuring proper layout representation. - Added tests for struct layouts, including arrays, unions, and specializations. - Updated `fixture_cpp` and `bindgen_cpp_test` to reflect changes in type mappings and added functionality. - Improved handling of derived structs and template specializations in namespaced contexts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A struct's tuple now spells every field C++ lays out, so structs holding library types are tuples with that library's layout instead of
Opaque.What changes
std::string→basic_string_char,nvrhi::static_vector<IBindingSet *, 8>→static_vector_IBindingSet_8,RefCountPtr<IShader>→RefCountPtr_IShader = [ptr_: IShader | null]. A pointer to a specialization alone staysOpaque /* ... */._padfield; the Itanium ABI's reuse of it is kept.T x[N]→x: [_0: T, ..., _{N-1}: T](up to 1024 elements; tslang has no fixed-size array type).union { char buf[16]; char *ptr; }→[_0: u64, _1: u64]). Anonymous unions are named after their first member; anonymous structs are flattened.[[no_unique_address]]empty members take no storage (libc++'s string allocator).spellRecord) both decides and spells, forrecordSkipReasonandmapFields.alignas,DECLSPEC_ALIGN(16)) is now skipped — a tuple holding it would have been placed at the wrong offset.guiddef.h'soperator==forGUID) is no longer emitted as a namelessdeclare function (...).Member names inside library types are that library's own and differ between MSVC's STL and libc++ (
_Elemsvs__elems_); tuple literals are positional, so only name-based reads are per-ABI.Results
NVRHI: every desc is now a tuple.
BufferDescis 80 bytes under MSVC and 72 under libc++, matching C++ (nvrhi.layoutMatches()).Tests
LayoutTest.cpp(arrays, bitfields, unions, held specializations, MSVC- and libc++-shapedstd::string, base tail padding, inherited name clashes — under bothwindowsTargetandlinuxTarget),Naming.OperatorWithCLinkageIsLeftOut; flipped expectations inSkipTest/NamespacedStructTest. 76/76.test-bindgen-cpp: the fixture passes astatic_vector-shaped container (private array base + count), a buffer/pointer union and a bitfield run to real compiled C++ (exe + JIT).ctest -R "test-bindgen|cppvtable|cpp_slot": 46/46.--filter 'std::*').nvrhi_direct+headlesspass on Windows (dx12/vk, AOT + JIT,-debug) and the Android emulator (x86_64, arm64).Found, not fixed
Reference<X>) fails in tslang:windows.h+d3d12.hgive 284 such errors with both this and the previous tsbindgen. Sorting the output by dependency is a follow-up.@cppclass fields (addClassFields) don't use the layout pass yet: a union or bitfield in a class still drops its fields. NVRHI's interfaces have none.chararrays ares8on x86_64 andu8on aarch64 (faithful; same layout).Downstream
native_ts_graphics' branch
nvrhi-generated-descsuses this (generated descs, hand tuples removed); it will be opened after a tslang with this change is deployed. Nativemainkeeps building in the meantime.🤖 Generated with Claude Code