← 输入框|github.com|刷新
Skip to content

Split accessors out of dispatch and reflector types - #99

Merged
mingxwa merged 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/access
Nov 10, 2026
Merged

mingxwa merged 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/access

Conversation

@mingxwa

@mingxwa mingxwa commented Nov 9, 2026

Copy link
Copy Markdown
Member

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.

**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
mingxwa force-pushed the user/mingxwa/access branch from 50f92e4 to 6dc0a89 Compare November 9, 2026 15:27
@mingxwa
mingxwa merged commit 2f1976d into ngcpp:feature/v5 Nov 10, 2026
20 checks passed
@mingxwa
mingxwa deleted the user/mingxwa/access branch November 10, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant