Repository navigation
Split accessors out of dispatch and reflector types - #99
Merged
Merged
Conversation
**NOTE**: This targets `feature/v5`. A hand-written convention or reflection now needs an `access_type` to give `proxy` an accessor, because `proxy` no longer reads the member template `accessor` of its dispatch type or reflector type. **Motivation** - `proxy` formed its accessors from the dispatch type of each convention and the reflector type of each reflection. The same type decided how a call is forwarded or what is reflected, and also how it is spelled on a `proxy`. - Two dispatch types could not contribute overloads to one member function or operator, and no accessor could combine an operation with a reflection. - The accessor macros of the compatibility protocol held the plain names, so removing the protocol would have renamed the macros that stay. **Design** - A convention or a reflection names its access type as `access_type`. The member template `accessor<Self, Ds...>` of the access type receives descriptors: `proxy_operation<D, O>` for an operation and `proxy_reflection<M>` for a reflection. - `proxy` groups the conventions and reflections of its facade and of every super by access type, separately for direct and indirect ones. It inherits one accessor per group, formed from the descriptors of the group with duplicates removed and in an unspecified order. An accessor of member functions `using`-declares the members of the accessors of the individual descriptors, so overload resolution spans the whole group. - A missing `access_type` means `void`, which provides no accessor. `proxy` reads the access type from the convention or the reflection only. - `basic_facade_builder` gives each convention and reflection it adds an access type. Library dispatch types and reflectors get library access types, `weak_dispatch<D>` shares the access type of `D` when `D` is a library dispatch type, and any other type gets an adapter of its member template `accessor`, which the expansions of `PRO_DEF_MEM_DISPATCH`, `PRO_DEF_FREE_DISPATCH` and `PRO_DEF_FREE_AS_MEM_DISPATCH` keep providing. - The library itself no longer relies on the compatibility protocol. **Changes** - Added the class templates `proxy_operation` and `proxy_reflection` and replaced *ProAccessible* with *ProAccess*. - Added `operator_access`, `explicit_conversion_access` and `implicit_conversion_access`, which hold the accessors moved out of `operator_dispatch` and the conversion dispatches, so that a convention can name them with any dispatch type. - Renamed `cast_dispatch_base` to `cast_access_base` and moved it to `dispatch.h`, its only user. - Gave the dispatch types and reflectors behind the skills their own access types in the detail namespace, and made the dispatch type of `format_traits` the namespace-scope `format_dispatch`. - Made `basic_facade_builder` resolve default access types through `default_access_traits` when the convention or reflection type is instantiated, so that a dispatch type or a reflector may still be incomplete when it is added. - Declared the `lock` convention of `weak_facade` with `weak_lock_dispatch` and a hand-written `weak_lock_access` for its single descriptor, replacing the macro-defined `weak_mem_lock`. - Gave the accessor macros of the access types the plain names and moved the macros of the compatibility protocol into one `PRO5D_DEF_LEGACY_*` block ahead of the dispatch macros that use them. - Exported the new public names from the `proxy.v5` module. - Moved the accessor pages of the operator and conversion dispatches to the access types, and documented the descriptors, *ProAccess*, the inheritance rules of `proxy` and `proxy_indirect_accessor`, and the access types that the builder gives. - Listed `PRO_DEF_FREE_AS_MEM_DISPATCH` among the dispatch types with full accessibility in the notes of `proxy_invoke`. - Added tests for a hand-written convention and reflection sharing an access type, a super with both `as_view` and `as_weak`, conventions and reflections without an access type, and the access types that the builder gives, including overloads shared across dispatch types and duplicates from supers.
mingxwa
force-pushed
the
user/mingxwa/access
branch
from
November 9, 2026 15:27
50f92e4 to
6dc0a89
Compare
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.
Motivation
proxyformed its accessors from the dispatch type of each convention and the reflector type of each reflection. The same type decided how a call is forwarded or what is reflected, and also how it is spelled on aproxy.Design
access_type. The member templateaccessor<Self, Ds...>of the access type receives descriptors:proxy_operation<D, O>for an operation andproxy_reflection<M>for a reflection.proxygroups the conventions and reflections of its facade and of every super by access type, separately for direct and indirect ones. It inherits one accessor per group, formed from the descriptors of the group with duplicates removed and in an unspecified order. An accessor of member functionsusing-declares the members of the accessors of the individual descriptors, so overload resolution spans the whole group.access_typemeansvoid, which provides no accessor.proxyreads the access type from the convention or the reflection only.basic_facade_buildergives each convention and reflection it adds an access type. Library dispatch types and reflectors get library access types,weak_dispatch<D>shares the access type ofDwhenDis a library dispatch type, and any other type gets an adapter of its member templateaccessor, which the expansions ofPRO_DEF_MEM_DISPATCH,PRO_DEF_FREE_DISPATCHandPRO_DEF_FREE_AS_MEM_DISPATCHkeep providing.Changes
proxy_operationandproxy_reflectionand replaced ProAccessible with ProAccess.operator_access,explicit_conversion_accessandimplicit_conversion_access, which hold the accessors moved out ofoperator_dispatchand the conversion dispatches, so that a convention can name them with any dispatch type.cast_dispatch_basetocast_access_baseand moved it todispatch.h, its only user.format_traitsthe namespace-scopeformat_dispatch.basic_facade_builderresolve default access types throughdefault_access_traitswhen the convention or reflection type is instantiated, so that a dispatch type or a reflector may still be incomplete when it is added.lockconvention ofweak_facadewithweak_lock_dispatchand a hand-writtenweak_lock_accessfor its single descriptor, replacing the macro-definedweak_mem_lock.PRO5D_DEF_LEGACY_*block ahead of the dispatch macros that use them.proxy.v5module.proxyandproxy_indirect_accessor, and the access types that the builder gives.PRO_DEF_FREE_AS_MEM_DISPATCHamong the dispatch types with full accessibility in the notes ofproxy_invoke.as_viewandas_weak, conventions and reflections without an access type, and the access types that the builder gives, including overloads shared across dispatch types and duplicates from supers.