Commit dd2c86f
doc: forward-declare the registry instead of including preamble.hpp (#93)
* doc: forward-declare the registry instead of including preamble.hpp
Overriding BOOST_OPENMETHOD_DEFAULT_REGISTRY forced users to learn the header
layering: include a "pre-core" header (preamble.hpp or default_registry.hpp),
define the registry, #define the macro, then include <boost/openmethod.hpp>.
ref_headers.adoc codified that as a "Pre-Core Headers" section, and
custom_rtti.adoc told the reader not to include <boost/openmethod.hpp> yet.
None of it is necessary. Every use of the macro in the headers is a name-only
context - a default template argument, an alias, a deduction guide, or a member
typedef inside a template - so the registry can be forward-declared before the
include and defined after it, where <boost/openmethod.hpp> has already supplied
registry, default_registry, indirect_registry and the five stock policies:
struct my_registry;
#define BOOST_OPENMETHOD_DEFAULT_REGISTRY my_registry
#include <boost/openmethod.hpp>
#include <boost/openmethod/policies/vptr_map.hpp>
struct my_registry
: boost::openmethod::default_registry::with<
boost::openmethod::policies::vptr_map<>> {};
A registry the library provides needs no declaration at all: core.hpp includes
default_registry.hpp *before* it tests the macro, so #define plus the include is
the whole recipe. preamble.hpp and default_registry.hpp now appear nowhere
outside include/.
Three rules, all documented: the registry must be complete before the first
construct that instantiates it (a hard error otherwise, never silent); it must
name a class declared with the same class-key as the definition (a mismatch is
MSVC C4099, an error under /W4 /WX); and the name must be qualified if it could
also be found in namespace boost::openmethod - `registry` in particular, which
otherwise resolves to boost::openmethod::registry and fails with "missing
template arguments".
Migrated the 17 tests that override the default, plus test_policies.cpp.
test_capture_errors.hpp now includes <boost/openmethod.hpp>; test_core.cpp drops
a redundant preamble.hpp; dynamic_loading/registry.hpp loses its whole #ifndef
fallback, which only existed because the alias preceded the include.
The two custom_rtti step-by-step examples get a tag::setup[] region so
tag::policy[] no longer opens with an include. ref_headers.adoc renames
"Pre-Core Headers" to "Policy Headers" and demotes preamble.hpp and
default_registry.hpp to "Headers Included by Other Headers".
registries_and_policies.adoc becomes the canonical home of the recipe; its
reference to <boost/openmethod/registry.hpp>, a file that does not exist, is
fixed. shared_libraries.adoc's my_registry.hpp listing gains the #define and
include it was missing - as written it never actually overrode the default.
Removed doc/modules/ROOT/examples/deferred_custom_rtti.cpp: an orphan no page
included, whose virtual-inheritance and dynamic_cast_ref coverage
test_custom_rtti_virtual_base.cpp already provides.
Also dropped three stray "end::" tags with no opener, and the dead Quickbook
markers in examples/static_rtti.cpp.
Closes #90
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: unbreak the GCC build, and address review of the registry recipe
The doc comment added for BOOST_OPENMETHOD_DEFAULT_REGISTRY ended a `//!` line
with a backslash, making it a line continuation. GCC's -Wcomment (in -Wall)
rejects that under -Werror, so every GCC job on both CIs failed while every
clang, MSVC and Xcode job passed. Put the #define on one line. Verified by
reproducing the exact diagnostic with the pre-fix header and confirming g++
-Wall -Wextra -Werror accepts the fixed one.
Restore the coverage lost with deferred_custom_rtti.cpp. That example was the
only place combining deferred_static_rtti with virtual bases and
dynamic_cast_ref: test_custom_rtti_virtual_base.cpp has the virtual bases and
the cast but derives from policies::rtti, and test_custom_rtti_deferred.cpp had
neither. Add Bat and Owl, virtually derived, plus the dynamic_cast_ref the cast
now needs - `requires_dynamic_cast` is true exactly when static_cast is
ill-formed, so these overriders reach the policy hook. Confirmed by sabotaging
dynamic_cast_ref and watching the test fail.
Name core.hpp, not <boost/openmethod.hpp>, as the point where the macro is read.
initialize.hpp, inplace_vptr.hpp and every interop/*.hpp also include core.hpp,
so a TU that includes one of those before the #define binds silently to
default_registry. Four places still said otherwise.
test_capture_errors.hpp now owns the whole recipe - declaration, #define,
include and test_registry - instead of the seven tests repeating it. There is no
ordering left for a caller to get wrong, which is what the previous version's
comment had claimed without being able to guarantee it. Those tests no longer
name the macro, so test/CMakeLists.txt would have handed them the shared PCH and
silently defeated the override; teach its scan to follow the header too.
Documentation fixes from the same review:
- ref_headers.adoc claimed every stock policy has its own header; indirect_vptr,
runtime_checks and deferred_static_rtti live in preamble.hpp. Say so, and note
runtime_checks joins default_registry under
BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS.
- custom_rtti.adoc pointed at a declaration "at the top of the file" that sits
below the classes listing, and its Deferred RTTI section never showed the
declaration step at all - example 2's setup and registry tags were unrendered.
- error_handling.adoc's listing opened with five lines of registry boilerplate
its prose never introduced.
- shared_libraries.adoc's my_registry.hpp is a complete header now, so give it
the include guard the animals.hpp it is compared to has.
- CLAUDE.md cited a line number that had already moved, pointed at greps in a
section that has none, miscounted the files carrying the macro, and described
an unqualified `registry` as resolving silently when it is a hard error.
Remove doc/modules/ROOT/examples/static_rtti.cpp: an orphan no page references,
left marker-free by the previous commit, duplicating snippets/static_rtti.cpp -
which exercises the same policy, classes and dispatch, is the copy the docs
render, and asserts more.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test: give the registration-error tests a shared registry header
Finishes the deduplication started for the capture-diagnostics tests. The three
test_class_registration_*.cpp files repeated the same six-line prologue and the
same `default_registry::with<runtime_checks, throw_error_handler>` definition
verbatim; test_checked_registry.hpp now owns the whole recipe, so including it
first is all they do and there is no ordering left to get wrong.
Teach the PCH scan in test/CMakeLists.txt about the new header, as with
test_capture_errors.hpp: those files no longer name the macro, and a
force-included PCH would precede the #define and silently bind the macros to
default_registry. Verified from build.ninja that all three stay off the shared
PCH, and that defeating the override makes the tests fail rather than pass
quietly - they assert BOOST_CHECK_THROW(..., missing_class), which needs
runtime_checks and throw_error_handler.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ci: exclude test sources from coverage
The codecov report counted test/ alongside include/, so the only red check on
this PR was three unreachable lines in test_custom_rtti_deferred.cpp: the
cast_aux null return and the Bat/Owl delegation-to-base branches, which exist to
make the custom cast well-formed for every pair but that no call reaches. Test
code is not the thing the coverage target is measuring.
The exclusion was already in the file, commented out, but spelled `test/**/*` as
the boost-ci sample ships it. That spelling does not do what it looks like:
codecov compiles it to (?s:test/.*/[^\/]*)\Z, which requires a second slash, so
it matches only the subdirectories of test/ and leaves every top-level
test/test_*.cpp counted - which is where nearly all the test code is. `test/**`
compiles to (?s:test/.*)\Z and matches at any depth. Verified against the paths
codecov actually reports, which are repo-relative despite boost-ci building
inside the superproject. Comment records the trap and the validate endpoint.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent b3bec3b commit dd2c86f
41 files changed
Lines changed: 506 additions & 488 deletions
File tree
- doc/modules/ROOT
- examples
- custom_rtti
- 1
- 2
- pages
- snippets
- include/boost/openmethod
- policies
- test
- dynamic_loading
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| |||
364 | 367 | | |
365 | 368 | | |
366 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
367 | 429 | | |
368 | 430 | | |
369 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
79 | | - | |
80 | 83 | | |
81 | 84 | | |
82 | | - | |
83 | | - | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | | - | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | | - | |
75 | | - | |
76 | 79 | | |
77 | 80 | | |
78 | | - | |
79 | | - | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments