From 994fc377c7eb6ea9f91e5b125cda0e7350a1bd13 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 21 Mar 2022 15:26:15 -0700 Subject: [PATCH] ircd::m: Dissolve m::matrix instance object; burden user instead. --- construct/construct.cc | 5 +---- construct/homeserver.cc | 33 +++++++++++++++++++++++---------- construct/homeserver.h | 10 ++++++++-- include/ircd/m/m.h | 33 --------------------------------- 4 files changed, 32 insertions(+), 49 deletions(-) diff --git a/construct/construct.cc b/construct/construct.cc index 2ba248eff..25abcea67 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -197,13 +197,10 @@ noexcept try { [&opts](const ircd::main_continuation &main) { - // Load the matrix module - ircd::matrix matrix; - // Construct the homeserver. construct::homeserver homeserver { - matrix, opts + opts }; // Bail for debug/testing purposes. diff --git a/construct/homeserver.cc b/construct/homeserver.cc index e7024cb5e..0431b0b3c 100644 --- a/construct/homeserver.cc +++ b/construct/homeserver.cc @@ -12,23 +12,36 @@ #include "construct.h" #include "homeserver.h" -construct::homeserver::homeserver(ircd::matrix &matrix, - struct ircd::m::homeserver::opts opts) +namespace fs = ircd::fs; +using ircd::string_view; + +construct::homeserver::homeserver(struct ircd::m::homeserver::opts opts) try -:matrix -{ - matrix -} -,opts +:opts { std::move(opts) } +,module_path +{ + fs::path_string(fs::path_views{fs::base::lib, "libircd_matrix"}), +} +,module +{ + string_view{module_path[0]}, +} +,init +{ + module[0], "ircd::m::homeserver::init", +} +,fini +{ + module[0], "ircd::m::homeserver::fini", +} ,hs { - matrix.init(&this->opts), - [&matrix](ircd::m::homeserver *const hs) + this->init(&this->opts), [this](ircd::m::homeserver *const hs) { - matrix.fini(hs); + this->fini(hs); } } { diff --git a/construct/homeserver.h b/construct/homeserver.h index 68538a18e..a8b449840 100644 --- a/construct/homeserver.h +++ b/construct/homeserver.h @@ -10,11 +10,17 @@ struct construct::homeserver { - ircd::matrix &matrix; + using init_proto = ircd::m::homeserver *(const struct ircd::m::homeserver::opts *); + using fini_proto = void (ircd::m::homeserver *); + struct ircd::m::homeserver::opts opts; + std::string module_path[1]; + ircd::module module[1]; + ircd::mods::import init; + ircd::mods::import fini; ircd::custom_ptr hs; public: - homeserver(ircd::matrix &, struct ircd::m::homeserver::opts); + homeserver(struct ircd::m::homeserver::opts); ~homeserver() noexcept; }; diff --git a/include/ircd/m/m.h b/include/ircd/m/m.h index d2a8a1744..bce513859 100644 --- a/include/ircd/m/m.h +++ b/include/ircd/m/m.h @@ -34,7 +34,6 @@ namespace ircd::m /// Matrix Protocol System namespace ircd::m { - struct matrix; struct homeserver; IRCD_OVERLOAD(generate) @@ -44,7 +43,6 @@ namespace ircd::m extern const uint16_t canon_port; extern const string_view canon_service; - using m::matrix; extern const std::vector module_names; extern const std::vector module_names_optional; } @@ -100,34 +98,3 @@ namespace ircd::m #include "burst.h" #include "resource.h" #include "homeserver.h" - -struct ircd::m::matrix -{ - static const std::vector module_names; - static const std::vector module_names_optional; - - std::string module_path - { - fs::path_string(fs::path_views - { - fs::base::lib, "libircd_matrix" - }) - }; - - ircd::module module - { - module_path - }; - - using init_proto = m::homeserver *(const struct m::homeserver::opts *); - mods::import init - { - module, "ircd::m::homeserver::init" - }; - - using fini_proto = void (m::homeserver *); - mods::import fini - { - module, "ircd::m::homeserver::fini" - }; -};