@@ -11,22 +11,71 @@ BOOST_OPENMETHOD(ID, (PARAMETERS...), RETURN_TYPE [, REGISTRY]);
1111
1212### Description
1313
14- Declares a method.
14+ Declares a method, called `ID`, with the given `PARAMETERS` and `RETURN_TYPE`,
15+ and adds it to `REGISTRY`.
1516
16- The macro expands to several constructs:
17+ `PARAMETERS` is a comma-separated list of types, possibly followed by parameter
18+ names, just like in a function declaration. Parameters with a type in the form
19+ `virtual_ptr<T>` or `virtual_<T>` are called virtual parameters. The dynamic
20+ type of the arguments passed in virtual parameters determines which overrider to
21+ call, following the same rules as overloaded function resolution:
22+
23+ 1. Form the set of all applicable overriders. An overrider is applicable
24+ if it can be called with the arguments passed to the method.
25+ 2. If the set is empty, call the error handler (if present in the
26+ registry), then terminate the program with `abort`.
27+ 3. Remove the overriders that are dominated by other overriders in the
28+ set. Overrider A dominates overrider B if any of its virtual formal
29+ parameters is more specialized than B's, and if none of B's virtual
30+ parameters is more specialized than A's.
31+ 4. If the resulting set contains exactly one overrider, call it.
32+
33+ If a single most specialized overrider does not exist, the program is
34+ terminated via `abort`. If the registry contains an `error_handler`
35+ policy, its `error` function is called with an object that describes the
36+ error, prior calling `abort`. `error` may prevent termination by throwing an
37+ exception.
38+
39+ []
40+
41+ For each virtual argument `arg`, the dispatch mechanism calls
42+ `virtual_traits::peek(arg)` and deduces the v-table pointer from the
43+ `result`, using the first of the following methods that applies:
44+
45+ 1. If `result` is a `virtual_ptr`, get the pointer to the v-table from it.
46+ 2. If `boost_openmethod_vptr` can be called with `result` and a `Registry*`,
47+ and it returns a `vptr_type`, call it.
48+ 3. Call `Registry::rtti::dynamic_vptr(result)`.
49+
50+
51+ The macro creates an ordinary inline function in the current scope, with the
52+ `virtual_` decorators removed from the parameter types. `virtual_ptr`{empty}s
53+ are preserved.
54+
55+ NOTE: `ID` must be an *identifier*. Qualified names are not allowed.
56+
57+ NOTE: The default value for `REGISTRY` is the value of
58+ `BOOST_OPENMETHOD_DEFAULT_REGISTRY` at the point `<boost/openmethod/core.hpp>` is
59+ included. Changing the value of this symbol has no effect after that point.
60+
61+ ### Implementation Notes
62+
63+ The macro creates several additional constructs:
1764
1865* A `struct` forward declaration that acts as the method's identifier:
1966
2067```c++
2168struct BOOST_OPENMETHOD_ID(ID);
2269```
2370
24- * An inline function template, constrained to take the same `PARAMETERS`,
25- without the `virtual_` decorators, returning a `RETURN_TYPE`. The function
26- forwards to +
27- `method<BOOST_OPENMETHOD_ID(ID)(PARAMETERS...), RETURN_TYPE, REGISTRY>::fn`.
71+ * A class template declaration that acts as a container for the method's
72+ overriders in the current scope:
73+
74+ ```c++
75+ template<typename...> struct BOOST_OPENMETHOD_OVERRIDERS(NAME);
76+ ```
2877
29- * A guide function used to match overriders with the method:
78+ * A _guide_ function used to match overriders with the method:
3079
3180```c++
3281auto BOOST_OPENMETHOD_ID(ID)_guide(...)
@@ -36,9 +85,3 @@ auto BOOST_OPENMETHOD_ID(ID)_guide(...)
3685
3786* A xref:BOOST_OPENMETHOD_REGISTER.adoc[registrar] that adds the method to the
3887registry.
39-
40- NOTE: `ID` must be an *identifier*. Qualified names are not allowed.
41-
42- NOTE: The default value for `REGISTRY` is the value of
43- `BOOST_OPENMETHOD_DEFAULT_REGISTRY` at the point `<boost/openmethod/core.hpp>` is
44- included. Changing the value of this symbol has no effect after that point.
0 commit comments