BOOST_OPENMETHOD_NAME -> BOOST_OPENMETHOD_ID

This commit is contained in:
Jean-Louis Leroy
2025-06-21 14:30:07 -04:00
parent 8e439f2934
commit 88832cc96c
12 changed files with 47 additions and 48 deletions

View File

@@ -20,20 +20,20 @@ The macro expands to several constructs:
* A `struct` forward declaration that acts as the method's identifier:
```c++
struct BOOST_OPENMETHOD_NAME(NAME);
struct BOOST_OPENMETHOD_ID(NAME);
```
* An inline function template, constrained to take the same `PARAMETERS`,
without the `virtual_` decorators, returning a `RETURN_TYPE`. The function
forwards to +
`method<BOOST_OPENMETHOD_NAME(NAME)(PARAMETERS...), RETURN_TYPE, POLICY>::fn`.
`method<BOOST_OPENMETHOD_ID(NAME)(PARAMETERS...), RETURN_TYPE, POLICY>::fn`.
* A guide function used to match overriders with the method:
```c++
auto BOOST_OPENMETHOD_NAME(NAME)_guide(...)
auto BOOST_OPENMETHOD_ID(NAME)_guide(...)
-> ::boost::openmethod::method<
BOOST_OPENMETHOD_NAME(NAME)(PARAMETERS...), RETURN_TYPE [, POLICY]>;
BOOST_OPENMETHOD_ID(NAME)(PARAMETERS...), RETURN_TYPE [, POLICY]>;
```
NOTE: `NAME` must be an *identifier*. Qualified names are not allowed.

View File

@@ -1,14 +1,14 @@
[#BOOST_OPENMETHOD_NAME]
[#BOOST_OPENMETHOD_ID]
## BOOST_OPENMETHOD_NAME
## BOOST_OPENMETHOD_ID
### Synopsis
Defined in <boost/openmethod/macros.hpp>.
```c++
#define BOOST_OPENMETHOD_NAME(NAME) /* unspecified */
#define BOOST_OPENMETHOD_ID(NAME) /* unspecified */
```
### Description

View File

@@ -7,7 +7,7 @@ Defined in <boost/openmethod/macros.hpp>.
```c++
#define BOOST_OPENMETHOD_OVERRIDERS(NAME) \
BOOST_PP_CAT(BOOST_OPENMETHOD_NAME(NAME), _overriders)
BOOST_PP_CAT(BOOST_OPENMETHOD_ID(NAME), _overriders)
```
### Description

View File

@@ -32,7 +32,7 @@ name can get tedious, so OpenMethod provides a macro for that:
include::{exampledir}/core_api.cpp[tag=method]
----
NOTE: BOOST_OPENMETHOD and associated macros use `BOOST_OPENMETHOD_NAME` in
NOTE: BOOST_OPENMETHOD and associated macros use `BOOST_OPENMETHOD_ID` in
their implementation. This makes it possible to mix the "macro" and "core"
styles.

View File

@@ -507,7 +507,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#ref_description_6">Description</a></li>
</ul>
</li>
<li><a href="#BOOST_OPENMETHOD_NAME">BOOST_OPENMETHOD_NAME</a>
<li><a href="#BOOST_OPENMETHOD_ID">BOOST_OPENMETHOD_ID</a>
<ul class="sectlevel3">
<li><a href="#ref_synopsis_7">Synopsis</a></li>
<li><a href="#ref_description_7">Description</a></li>
@@ -2030,10 +2030,10 @@ name can get tedious, so OpenMethod provides a macro for that:</p>
<div class="content">
<pre class="rouge highlight"><code data-lang="c++">#include &lt;boost/openmethod/macros.hpp&gt;
class BOOST_OPENMETHOD_NAME(poke);
class BOOST_OPENMETHOD_ID(poke);
using poke = method&lt;
BOOST_OPENMETHOD_NAME(poke),
BOOST_OPENMETHOD_ID(poke),
auto(std::ostream&amp;, virtual_ptr&lt;Animal&gt;)-&gt;void&gt;;</code></pre>
</div>
</div>
@@ -2044,7 +2044,7 @@ using poke = method&lt;
<div class="title">Note</div>
</td>
<td class="content">
BOOST_OPENMETHOD and associated macros use <code>BOOST_OPENMETHOD_NAME</code> in
BOOST_OPENMETHOD and associated macros use <code>BOOST_OPENMETHOD_ID</code> in
their implementation. This makes it possible to mix the "macro" and "core"
styles.
</td>
@@ -3247,7 +3247,7 @@ etc).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="c++">struct BOOST_OPENMETHOD_NAME(NAME);</code></pre>
<pre class="rouge highlight"><code data-lang="c++">struct BOOST_OPENMETHOD_ID(NAME);</code></pre>
</div>
</div>
<div class="ulist">
@@ -3256,7 +3256,7 @@ etc).</p>
<p>An inline function template, constrained to take the same <code>PARAMETERS</code>,
without the <code>virtual_</code> decorators, returning a <code>RETURN_TYPE</code>. The function
forwards to<br>
<code>method&lt;BOOST_OPENMETHOD_NAME(NAME)(PARAMETERS&#8230;&#8203;), RETURN_TYPE, POLICY&gt;::fn</code>.</p>
<code>method&lt;BOOST_OPENMETHOD_ID(NAME)(PARAMETERS&#8230;&#8203;), RETURN_TYPE, POLICY&gt;::fn</code>.</p>
</li>
<li>
<p>A guide function used to match overriders with the method:</p>
@@ -3265,9 +3265,9 @@ forwards to<br>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="c++">auto BOOST_OPENMETHOD_NAME(NAME)_guide(...)
<pre class="rouge highlight"><code data-lang="c++">auto BOOST_OPENMETHOD_ID(NAME)_guide(...)
-&gt; ::boost::openmethod::method&lt;
BOOST_OPENMETHOD_NAME(NAME)(PARAMETERS...), RETURN_TYPE [, POLICY]&gt;;</code></pre>
BOOST_OPENMETHOD_ID(NAME)(PARAMETERS...), RETURN_TYPE [, POLICY]&gt;;</code></pre>
</div>
</div>
<div class="admonitionblock note">
@@ -3580,7 +3580,7 @@ for with the given name, parameter list and return type.</p>
</div>
</div>
<div class="sect2">
<h3 id="BOOST_OPENMETHOD_NAME">BOOST_OPENMETHOD_NAME</h3>
<h3 id="BOOST_OPENMETHOD_ID">BOOST_OPENMETHOD_ID</h3>
<div class="sect3">
<h4 id="ref_synopsis_7">Synopsis</h4>
<div class="paragraph">
@@ -3588,7 +3588,7 @@ for with the given name, parameter list and return type.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="c++">#define BOOST_OPENMETHOD_NAME(NAME) /* unspecified */</code></pre>
<pre class="rouge highlight"><code data-lang="c++">#define BOOST_OPENMETHOD_ID(NAME) /* unspecified */</code></pre>
</div>
</div>
</div>
@@ -3630,7 +3630,7 @@ generated by macros are based on this name.</p>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="c++">#define BOOST_OPENMETHOD_OVERRIDERS(NAME) \
BOOST_PP_CAT(BOOST_OPENMETHOD_NAME(NAME), _overriders)</code></pre>
BOOST_PP_CAT(BOOST_OPENMETHOD_ID(NAME), _overriders)</code></pre>
</div>
</div>
</div>

View File

@@ -12,7 +12,7 @@ include::BOOST_OPENMETHOD_INLINE_OVERRIDE.adoc[]
include::BOOST_OPENMETHOD_DECLARE_OVERRIDER.adoc[]
include::BOOST_OPENMETHOD_DEFINE_OVERRIDER.adoc[]
include::BOOST_OPENMETHOD_OVERRIDER.adoc[]
include::BOOST_OPENMETHOD_NAME.adoc[]
include::BOOST_OPENMETHOD_ID.adoc[]
include::BOOST_OPENMETHOD_GUIDE.adoc[]
include::BOOST_OPENMETHOD_OVERRIDERS.adoc[]
include::BOOST_OPENMETHOD_REGISTER.adoc[]

View File

@@ -24,10 +24,10 @@ using namespace boost::openmethod;
#include <boost/openmethod/macros.hpp>
class BOOST_OPENMETHOD_NAME(poke);
class BOOST_OPENMETHOD_ID(poke);
using poke = method<
BOOST_OPENMETHOD_NAME(poke),
BOOST_OPENMETHOD_ID(poke),
auto(std::ostream&, virtual_ptr<Animal>)->void>;
// end::method[]
@@ -58,7 +58,7 @@ auto poke_bulldog(std::ostream& os, virtual_ptr<Bulldog> dog) -> void {
BOOST_OPENMETHOD_REGISTER(poke::override<poke_bulldog>);
// end::poke_bulldog[]
class BOOST_OPENMETHOD_NAME(pet);
class BOOST_OPENMETHOD_ID(pet);
auto pet_cat(std::ostream& os, virtual_ptr<Cat> /*cat*/) {
os << "purr";
@@ -69,7 +69,7 @@ auto pet_dog(std::ostream& os, virtual_ptr<Dog> /*dog*/) {
}
using pet = method<
BOOST_OPENMETHOD_NAME(pet), auto(std::ostream&, virtual_ptr<Animal>)->void>;
BOOST_OPENMETHOD_ID(pet), auto(std::ostream&, virtual_ptr<Animal>)->void>;
BOOST_OPENMETHOD_REGISTER(pet::override<pet_cat, pet_dog>);

View File

@@ -1492,8 +1492,8 @@ method<Name, ReturnType(Parameters...), Registry>::override_impl<
Function, FnReturnType>::override_impl(FunctionPointer* p_next) {
using namespace detail;
// static variable this->method below is zero-initialized but gcc and clang
// don't always see that.
// static variable this->method below is zero-initialized but gcc and clang
// don't always see that.
#ifdef BOOST_CLANG
#pragma clang diagnostic push

View File

@@ -44,26 +44,26 @@ struct va_args<ReturnType> {
#define BOOST_OPENMETHOD_REGISTER(...) \
static __VA_ARGS__ BOOST_OPENMETHOD_GENSYM
#define BOOST_OPENMETHOD_NAME(NAME) NAME##_boost_openmethod
#define BOOST_OPENMETHOD_ID(NAME) NAME##_boost_openmethod
#define BOOST_OPENMETHOD_OVERRIDERS(NAME) \
BOOST_PP_CAT(BOOST_OPENMETHOD_NAME(NAME), _overriders)
BOOST_PP_CAT(BOOST_OPENMETHOD_ID(NAME), _overriders)
#define BOOST_OPENMETHOD_GUIDE(NAME) \
BOOST_PP_CAT(BOOST_OPENMETHOD_NAME(NAME), _guide)
BOOST_PP_CAT(BOOST_OPENMETHOD_ID(NAME), _guide)
#define BOOST_OPENMETHOD(NAME, ARGS, ...) \
struct BOOST_OPENMETHOD_NAME(NAME); \
struct BOOST_OPENMETHOD_ID(NAME); \
template<typename... ForwarderParameters> \
typename ::boost::openmethod::detail::enable_forwarder< \
void, \
::boost::openmethod::method< \
BOOST_OPENMETHOD_NAME(NAME), \
BOOST_OPENMETHOD_ID(NAME), \
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
ARGS, \
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>, \
typename ::boost::openmethod::method< \
BOOST_OPENMETHOD_NAME(NAME), \
BOOST_OPENMETHOD_ID(NAME), \
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
ARGS, \
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>, \
@@ -74,19 +74,19 @@ struct va_args<ReturnType> {
typename ::boost::openmethod::detail::enable_forwarder< \
void, \
::boost::openmethod::method< \
BOOST_OPENMETHOD_NAME(NAME), \
BOOST_OPENMETHOD_ID(NAME), \
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
ARGS, \
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>, \
typename ::boost::openmethod::method< \
BOOST_OPENMETHOD_NAME(NAME), \
BOOST_OPENMETHOD_ID(NAME), \
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
ARGS, \
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>:: \
return_type, \
ForwarderParameters...>::type { \
return ::boost::openmethod::method< \
BOOST_OPENMETHOD_NAME(NAME), \
BOOST_OPENMETHOD_ID(NAME), \
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
ARGS, \
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>:: \

View File

@@ -363,9 +363,9 @@ struct Bulldog : Dog {};
BOOST_OPENMETHOD_CLASSES(Animal, Dog, Bulldog);
struct BOOST_OPENMETHOD_NAME(poke);
struct BOOST_OPENMETHOD_ID(poke);
using poke =
method<BOOST_OPENMETHOD_NAME(poke), auto(virtual_<Animal&>)->std::string>;
method<BOOST_OPENMETHOD_ID(poke), auto(virtual_<Animal&>)->std::string>;
auto poke_dog(Dog&) -> std::string {
return "bark";

View File

@@ -32,10 +32,9 @@ struct Payroll {
}
private:
struct BOOST_OPENMETHOD_NAME(pay);
struct BOOST_OPENMETHOD_ID(pay);
using pay_method = method<
BOOST_OPENMETHOD_NAME(pay),
auto(Payroll*, virtual_<const Role&>)->void>;
BOOST_OPENMETHOD_ID(pay), auto(Payroll*, virtual_<const Role&>)->void>;
void pay_employee(const Employee&) {
balance -= 2000;

View File

@@ -204,8 +204,8 @@ template<int N>
using policy_types =
boost::mp11::mp_list<test_registry_<N>, indirect_test_registry<N>>;
struct BOOST_OPENMETHOD_NAME(poke);
struct BOOST_OPENMETHOD_NAME(fight);
struct BOOST_OPENMETHOD_ID(poke);
struct BOOST_OPENMETHOD_ID(fight);
namespace BOOST_OPENMETHOD_GENSYM {
@@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
BOOST_OPENMETHOD_REGISTER(
use_classes<Player, Warrior, Object, Axe, Bear, Registry>);
using poke = method<
BOOST_OPENMETHOD_NAME(poke),
BOOST_OPENMETHOD_ID(poke),
auto(virtual_ptr<Player, Registry>)->std::string, Registry>;
BOOST_OPENMETHOD_REGISTER(
typename poke::template override<
@@ -274,14 +274,14 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
use_classes<Player, Warrior, Object, Axe, Bear, Registry>);
using poke = method<
BOOST_OPENMETHOD_NAME(poke),
BOOST_OPENMETHOD_ID(poke),
auto(virtual_ptr<Player, Registry>)->std::string, Registry>;
BOOST_OPENMETHOD_REGISTER(
typename poke::template override<
poke_bear<virtual_ptr<Player, Registry>>>);
using fight = method<
BOOST_OPENMETHOD_NAME(fight),
BOOST_OPENMETHOD_ID(fight),
auto(
virtual_ptr<Player, Registry>, virtual_ptr<Object, Registry>,
virtual_ptr<Player, Registry>)
@@ -317,7 +317,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
use_classes<Player, Warrior, Object, Axe, Bear, Registry>);
using poke = method<
BOOST_OPENMETHOD_NAME(poke),
BOOST_OPENMETHOD_ID(poke),
auto(shared_virtual_ptr<Player, Registry>)->std::string, Registry>;
BOOST_OPENMETHOD_REGISTER(
@@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
poke_bear<shared_virtual_ptr<Player, Registry>>>);
using fight = method<
BOOST_OPENMETHOD_NAME(fight),
BOOST_OPENMETHOD_ID(fight),
auto(
shared_virtual_ptr<Player, Registry>,
shared_virtual_ptr<Object, Registry>,