Identity refactor - #5959
Draft
ab9rf wants to merge 6 commits into
Draft
Identity refactor#5959ab9rf wants to merge 6 commits into
ab9rf wants to merge 6 commits into
Conversation
combine `integer_identity`, `float_identity`, and `bool_identity` into a single type
`type_identity` (non-template, `DataDefs.h`) — the erased abstract base; all virtuals (`type`, `getFullName`, `isPrimitive`, `lua_read`/`lua_write`, `build_metatable`, `allocate`/`copy`/`destroy`) live here `type_identity_for<T>` (`DataIdentity.h`) — the single leaf template. Its base is chosen by `identity_base_of_t<T>`: `T::df_identity_base` typedef wins outright (codegen emits it into every compound type) `is_enum` / `enum_field` → `enum_identity`; `bitfield_traits<T>` → `bitfield_identity` types with `_identity` → `struct_identity` / `union_identity` / `virtual_identity` / `other_vectors_identity` via `is_union`/`is_polymorphic`/marker-typedef checks `char*`/`const char*` → `primitive_identity_base`; `wchar_t*` → `opaque_identity`; other pointers → `pointer_identity_base`; arithmetic + bool → `number_identity_base` `std::string/std::filesystem::path` → `constructed_identity`; C arrays/`std::array` → `buffer_container_identity`; STL/`BitArray`/`DfArray`/`enum_list_attr` → `detail::container_impl<T>`; other classes → `opaque_identity` `lua_read`/`lua_write`/`type()`/`getFullName()`/`isPrimitive()`/`build_metatable`/`isInteger()` are implemented once with `if constexpr` on `T`. `global_identity` is `type_identity<global_object>` over an empty placeholder with `df_identity_base` = `struct_identity`.
this is due to more aggressive devirtualization by gcc
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.
This is most of a "magnum opus" I've been trying to achieve for about three years now. It's not 100% done but it's a huge step in the direction I've been trying to go.
type_identity(non-template,DataDefs.h) — the erased abstract base; all virtuals (type,getFullName,isPrimitive,lua_read/lua_write,build_metatable,allocate/copy/destroy) live heretype_identity_for<T>(DataIdentity.h) — the single leaf template. Its base is chosen byidentity_base_of_t<T>:T::df_identity_basetypedef wins outright (codegen emits it into every compound type)is_enum/enum_field→enum_identity;bitfield_traits<T>→bitfield_identitytypes with
_identity→struct_identity/union_identity/virtual_identity/other_vectors_identityviais_union/is_polymorphic/marker-typedef checkschar*/const char*→primitive_identity_base;wchar_t*→opaque_identity; other pointers →pointer_identity_base; arithmetic + bool →number_identity_basestd::string/std::filesystem::path→constructed_identity; C arrays/std::array→buffer_container_identity; STL/BitArray/DfArray/enum_list_attr→detail::container_impl<T>; other classes →opaque_identitylua_read/lua_write/type()/getFullName()/isPrimitive()/build_metatable/isInteger()are implemented once withif constexpronT.global_identityistype_identity<global_object>over an empty placeholder withdf_identity_base=struct_identity.For now this is a draft; there are still things I want to do this and I definitely don't want to drop this in on top of all the bugfixes and new features that are currently sitting in dev, so it's absolutely not going in before the next release.