mirror of
https://github.com/matrix-construct/construct
synced 2025-01-20 03:21:54 +01:00
ircd:Ⓜ️:event: Convert modular components to demangled style.
This commit is contained in:
parent
7b12718e66
commit
68be0a321e
5 changed files with 137 additions and 107 deletions
|
@ -39,6 +39,8 @@ struct ircd::m::event::auth
|
||||||
{
|
{
|
||||||
assert(idx);
|
assert(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rebuild();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ircd::m::event::auth::chain
|
struct ircd::m::event::auth::chain
|
||||||
|
|
|
@ -13,16 +13,18 @@
|
||||||
|
|
||||||
struct ircd::m::event::refs
|
struct ircd::m::event::refs
|
||||||
{
|
{
|
||||||
using closure_bool = event::closure_idx_bool;
|
|
||||||
|
|
||||||
event::idx idx;
|
event::idx idx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using closure_bool = event::closure_idx_bool;
|
||||||
|
|
||||||
bool for_each(const closure_bool &) const;
|
bool for_each(const closure_bool &) const;
|
||||||
bool has(const event::idx &) const noexcept;
|
bool has(const event::idx &) const noexcept;
|
||||||
size_t count() const noexcept;
|
size_t count() const noexcept;
|
||||||
|
|
||||||
refs(const event::idx &idx) noexcept;
|
refs(const event::idx &idx) noexcept;
|
||||||
|
|
||||||
|
static void rebuild();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
|
@ -28,14 +28,14 @@ std::ostream &
|
||||||
ircd::m::pretty(std::ostream &s,
|
ircd::m::pretty(std::ostream &s,
|
||||||
const event &e)
|
const event &e)
|
||||||
{
|
{
|
||||||
using prototype = void (std::ostream &, const event &);
|
using prototype = std::ostream &(std::ostream &, const event &);
|
||||||
|
|
||||||
static mods::import<prototype> pretty
|
static mods::import<prototype> pretty
|
||||||
{
|
{
|
||||||
"m_event", "pretty__event"
|
"m_event", "ircd::m::pretty"
|
||||||
};
|
};
|
||||||
|
|
||||||
pretty(s, e);
|
return pretty(s, e);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -55,14 +55,14 @@ ircd::m::pretty_oneline(std::ostream &s,
|
||||||
const event &e,
|
const event &e,
|
||||||
const bool &content_keys)
|
const bool &content_keys)
|
||||||
{
|
{
|
||||||
using prototype = void (std::ostream &, const event &, const bool &);
|
using prototype = std::ostream &(std::ostream &, const event &, const bool &);
|
||||||
|
|
||||||
static mods::import<prototype> pretty_oneline
|
static mods::import<prototype> pretty_oneline
|
||||||
{
|
{
|
||||||
"m_event", "pretty_oneline__event"
|
"m_event", "ircd::m::pretty_oneline"
|
||||||
};
|
};
|
||||||
|
|
||||||
pretty_oneline(s, e, content_keys);
|
return pretty_oneline(s, e, content_keys);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -80,10 +80,11 @@ std::ostream &
|
||||||
ircd::m::pretty_msgline(std::ostream &s,
|
ircd::m::pretty_msgline(std::ostream &s,
|
||||||
const event &e)
|
const event &e)
|
||||||
{
|
{
|
||||||
using prototype = void (std::ostream &, const event &);
|
using prototype = std::ostream &(std::ostream &, const event &);
|
||||||
|
|
||||||
static mods::import<prototype> pretty_msgline
|
static mods::import<prototype> pretty_msgline
|
||||||
{
|
{
|
||||||
"m_event", "pretty_msgline__event"
|
"m_event", "ircd::m::pretty_msgline"
|
||||||
};
|
};
|
||||||
|
|
||||||
pretty_msgline(s, e);
|
pretty_msgline(s, e);
|
||||||
|
@ -105,10 +106,11 @@ std::ostream &
|
||||||
ircd::m::pretty(std::ostream &s,
|
ircd::m::pretty(std::ostream &s,
|
||||||
const event::prev &prev)
|
const event::prev &prev)
|
||||||
{
|
{
|
||||||
using prototype = void (std::ostream &, const event::prev &);
|
using prototype = std::ostream &(std::ostream &, const event::prev &);
|
||||||
|
|
||||||
static mods::import<prototype> pretty
|
static mods::import<prototype> pretty
|
||||||
{
|
{
|
||||||
"m_event", "pretty__prev"
|
"m_event", "ircd::m::pretty"
|
||||||
};
|
};
|
||||||
|
|
||||||
pretty(s, prev);
|
pretty(s, prev);
|
||||||
|
@ -130,10 +132,11 @@ std::ostream &
|
||||||
ircd::m::pretty_oneline(std::ostream &s,
|
ircd::m::pretty_oneline(std::ostream &s,
|
||||||
const event::prev &prev)
|
const event::prev &prev)
|
||||||
{
|
{
|
||||||
using prototype = void (std::ostream &, const event::prev &);
|
using prototype = std::ostream &(std::ostream &, const event::prev &);
|
||||||
|
|
||||||
static mods::import<prototype> pretty_oneline
|
static mods::import<prototype> pretty_oneline
|
||||||
{
|
{
|
||||||
"m_event", "pretty_oneline__prev"
|
"m_event", "ircd::m::pretty_oneline"
|
||||||
};
|
};
|
||||||
|
|
||||||
pretty_oneline(s, prev);
|
pretty_oneline(s, prev);
|
||||||
|
@ -1129,6 +1132,19 @@ ircd::m::is_power_event(const m::event &event)
|
||||||
// event::auth::chain
|
// event::auth::chain
|
||||||
//
|
//
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::m::event::auth::rebuild()
|
||||||
|
{
|
||||||
|
using prototype = void ();
|
||||||
|
|
||||||
|
static mods::import<prototype> rebuild
|
||||||
|
{
|
||||||
|
"m_event", "ircd::m::event::auth::rebuild"
|
||||||
|
};
|
||||||
|
|
||||||
|
rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::event::auth::chain::for_each(const closure &closure)
|
ircd::m::event::auth::chain::for_each(const closure &closure)
|
||||||
const
|
const
|
||||||
|
@ -1141,14 +1157,14 @@ ircd::m::event::auth::chain::for_each(const string_view &type,
|
||||||
const closure &c)
|
const closure &c)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
using prototype = bool (event::auth, const string_view &, const closure &);
|
using prototype = bool (chain::*)(const string_view &, const closure &) const;
|
||||||
|
|
||||||
static mods::import<prototype> auth_chain_for_each
|
static mods::import<prototype> call
|
||||||
{
|
{
|
||||||
"m_event", "auth_chain_for_each"
|
"m_event", "ircd::m::event::auth::chain::for_each"
|
||||||
};
|
};
|
||||||
|
|
||||||
return auth_chain_for_each(auth, type, c);
|
return (*this.**call)(type, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1271,6 +1287,19 @@ const
|
||||||
// event/refs.h
|
// event/refs.h
|
||||||
//
|
//
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::m::event::refs::rebuild()
|
||||||
|
{
|
||||||
|
using prototype = void ();
|
||||||
|
|
||||||
|
static mods::import<prototype> rebuild
|
||||||
|
{
|
||||||
|
"m_event", "ircd::m::event::refs::rebuild"
|
||||||
|
};
|
||||||
|
|
||||||
|
rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ircd::m::event::refs::count()
|
ircd::m::event::refs::count()
|
||||||
const noexcept
|
const noexcept
|
||||||
|
@ -1981,7 +2010,7 @@ ircd::m::event::essential(json::iov &event,
|
||||||
|
|
||||||
static mods::import<prototype> _essential
|
static mods::import<prototype> _essential
|
||||||
{
|
{
|
||||||
"m_event", "_essential__iov"
|
"m_event", "ircd::m::event::essential"
|
||||||
};
|
};
|
||||||
|
|
||||||
_essential(event, contents, closure);
|
_essential(event, contents, closure);
|
||||||
|
@ -1991,11 +2020,11 @@ ircd::m::event
|
||||||
ircd::m::essential(m::event event,
|
ircd::m::essential(m::event event,
|
||||||
const mutable_buffer &contentbuf)
|
const mutable_buffer &contentbuf)
|
||||||
{
|
{
|
||||||
using prototype = m::event &(m::event &, const mutable_buffer &);
|
using prototype = m::event (m::event, const mutable_buffer &);
|
||||||
|
|
||||||
static mods::import<prototype> _essential
|
static mods::import<prototype> _essential
|
||||||
{
|
{
|
||||||
"m_event", "_essential"
|
"m_event", "ircd::m::essential"
|
||||||
};
|
};
|
||||||
|
|
||||||
return _essential(event, contentbuf);
|
return _essential(event, contentbuf);
|
||||||
|
|
|
@ -5862,13 +5862,7 @@ console_cmd__event__refs(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__event__refs__rebuild(opt &out, const string_view &line)
|
console_cmd__event__refs__rebuild(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
using prototype = void ();
|
m::event::refs::rebuild();
|
||||||
static mods::import<prototype> rebuild
|
|
||||||
{
|
|
||||||
"m_event", "event_refs__rebuild"
|
|
||||||
};
|
|
||||||
|
|
||||||
rebuild();
|
|
||||||
out << "done" << std::endl;
|
out << "done" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5964,13 +5958,7 @@ console_cmd__event__auth__chain(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__event__auth__rebuild(opt &out, const string_view &line)
|
console_cmd__event__auth__rebuild(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
using prototype = void ();
|
m::event::refs::rebuild();
|
||||||
static mods::import<prototype> rebuild
|
|
||||||
{
|
|
||||||
"m_event", "event_auth__rebuild"
|
|
||||||
};
|
|
||||||
|
|
||||||
rebuild();
|
|
||||||
out << "done" << std::endl;
|
out << "done" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,6 @@
|
||||||
using namespace ircd::m;
|
using namespace ircd::m;
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
namespace ircd::m
|
|
||||||
{
|
|
||||||
extern "C" void
|
|
||||||
_essential__iov(json::iov &event,
|
|
||||||
const json::iov &contents,
|
|
||||||
const event::closure_iov_mutable &closure);
|
|
||||||
|
|
||||||
extern "C" m::event &
|
|
||||||
_essential(m::event &event,
|
|
||||||
const mutable_buffer &contentbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
mapi::header
|
mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
|
@ -30,9 +18,10 @@ IRCD_MODULE
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::m::_essential__iov(json::iov &event,
|
IRCD_MODULE_EXPORT
|
||||||
const json::iov &contents,
|
ircd::m::event::essential(json::iov &event,
|
||||||
const event::closure_iov_mutable &closure)
|
const json::iov &contents,
|
||||||
|
const event::closure_iov_mutable &closure)
|
||||||
{
|
{
|
||||||
const auto &type
|
const auto &type
|
||||||
{
|
{
|
||||||
|
@ -152,9 +141,10 @@ ircd::m::_essential__iov(json::iov &event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::m::event &
|
ircd::m::event
|
||||||
ircd::m::_essential(m::event &event,
|
IRCD_MODULE_EXPORT
|
||||||
const mutable_buffer &contentbuf)
|
ircd::m::essential(m::event event,
|
||||||
|
const mutable_buffer &contentbuf)
|
||||||
{
|
{
|
||||||
const auto &type
|
const auto &type
|
||||||
{
|
{
|
||||||
|
@ -234,9 +224,10 @@ ircd::m::_essential(m::event &event,
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
std::ostream &
|
||||||
pretty__event(std::ostream &s,
|
IRCD_MODULE_EXPORT
|
||||||
const event &event)
|
ircd::m::pretty(std::ostream &s,
|
||||||
|
const event &event)
|
||||||
{
|
{
|
||||||
const auto out{[&s]
|
const auto out{[&s]
|
||||||
(const string_view &key, auto&& val)
|
(const string_view &key, auto&& val)
|
||||||
|
@ -343,12 +334,15 @@ pretty__event(std::ostream &s,
|
||||||
<< std::setw(5) << std::right << size(string_view{content.second}) << " bytes "
|
<< std::setw(5) << std::right << size(string_view{content.second}) << " bytes "
|
||||||
<< ':' << content.first
|
<< ':' << content.first
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
std::ostream &
|
||||||
pretty_oneline__event(std::ostream &s,
|
IRCD_MODULE_EXPORT
|
||||||
const event &event,
|
ircd::m::pretty_oneline(std::ostream &s,
|
||||||
const bool &content_keys)
|
const event &event,
|
||||||
|
const bool &content_keys)
|
||||||
{
|
{
|
||||||
const auto out{[&s]
|
const auto out{[&s]
|
||||||
(const string_view &key, auto&& val)
|
(const string_view &key, auto&& val)
|
||||||
|
@ -442,11 +436,14 @@ pretty_oneline__event(std::ostream &s,
|
||||||
for(const auto &content : contents)
|
for(const auto &content : contents)
|
||||||
s << content.first << " ";
|
s << content.first << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
std::ostream &
|
||||||
pretty_msgline__event(std::ostream &s,
|
IRCD_MODULE_EXPORT
|
||||||
const event &event)
|
ircd::m::pretty_msgline(std::ostream &s,
|
||||||
|
const event &event)
|
||||||
{
|
{
|
||||||
s << json::get<"depth"_>(event) << " :";
|
s << json::get<"depth"_>(event) << " :";
|
||||||
s << json::get<"type"_>(event) << " ";
|
s << json::get<"type"_>(event) << " ";
|
||||||
|
@ -481,11 +478,14 @@ pretty_msgline__event(std::ostream &s,
|
||||||
s << string_view{content};
|
s << string_view{content};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
std::ostream &
|
||||||
pretty__prev(std::ostream &s,
|
IRCD_MODULE_EXPORT
|
||||||
const event::prev &prev)
|
ircd::m::pretty(std::ostream &s,
|
||||||
|
const event::prev &prev)
|
||||||
{
|
{
|
||||||
const auto out{[&s]
|
const auto out{[&s]
|
||||||
(const string_view &key, auto&& val)
|
(const string_view &key, auto&& val)
|
||||||
|
@ -532,11 +532,14 @@ pretty__prev(std::ostream &s,
|
||||||
|
|
||||||
s << std::endl;
|
s << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
std::ostream &
|
||||||
pretty_oneline__prev(std::ostream &s,
|
IRCD_MODULE_EXPORT
|
||||||
const event::prev &prev)
|
ircd::m::pretty_oneline(std::ostream &s,
|
||||||
|
const event::prev &prev)
|
||||||
{
|
{
|
||||||
const auto &auth_events{json::get<"auth_events"_>(prev)};
|
const auto &auth_events{json::get<"auth_events"_>(prev)};
|
||||||
s << "A[ ";
|
s << "A[ ";
|
||||||
|
@ -555,10 +558,13 @@ pretty_oneline__prev(std::ostream &s,
|
||||||
for(const json::array prev_event : prev_events)
|
for(const json::array prev_event : prev_events)
|
||||||
s << unquote(prev_event[0]) << " ";
|
s << unquote(prev_event[0]) << " ";
|
||||||
s << "] ";
|
s << "] ";
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
void
|
||||||
event_refs__rebuild()
|
IRCD_MODULE_EXPORT
|
||||||
|
ircd::m::event::refs::rebuild()
|
||||||
{
|
{
|
||||||
static const size_t pool_size{64};
|
static const size_t pool_size{64};
|
||||||
static const size_t log_interval{8192};
|
static const size_t log_interval{8192};
|
||||||
|
@ -618,8 +624,43 @@ event_refs__rebuild()
|
||||||
txn();
|
txn();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
bool
|
||||||
event_auth__rebuild()
|
IRCD_MODULE_EXPORT
|
||||||
|
ircd::m::event::auth::chain::for_each(const string_view &type,
|
||||||
|
const event::auth::chain::closure &closure)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
event::idx next(0);
|
||||||
|
event::auth auth(this->auth);
|
||||||
|
uint64_t depth[2] {uint64_t(-1), 0}; do
|
||||||
|
{
|
||||||
|
auth.for_each(type, [&depth, &next]
|
||||||
|
(const event::idx &event_idx)
|
||||||
|
{
|
||||||
|
if(!m::get(event_idx, "depth", depth[1]))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(depth[1] >= depth[0])
|
||||||
|
return true;
|
||||||
|
|
||||||
|
depth[0] = depth[1];
|
||||||
|
next = event_idx;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!closure(next))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auth.idx = next;
|
||||||
|
next = 0;
|
||||||
|
}
|
||||||
|
while(auth.idx);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
IRCD_MODULE_EXPORT
|
||||||
|
ircd::m::event::auth::rebuild()
|
||||||
{
|
{
|
||||||
static const size_t pool_size{96};
|
static const size_t pool_size{96};
|
||||||
static const size_t log_interval{8192};
|
static const size_t log_interval{8192};
|
||||||
|
@ -682,35 +723,3 @@ event_auth__rebuild()
|
||||||
|
|
||||||
txn();
|
txn();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" bool
|
|
||||||
auth_chain_for_each(event::auth auth,
|
|
||||||
const string_view &type,
|
|
||||||
const event::auth::chain::closure &closure)
|
|
||||||
{
|
|
||||||
event::idx next(0);
|
|
||||||
uint64_t depth[2] {uint64_t(-1), 0}; do
|
|
||||||
{
|
|
||||||
auth.for_each(type, [&depth, &next]
|
|
||||||
(const event::idx &event_idx)
|
|
||||||
{
|
|
||||||
if(!m::get(event_idx, "depth", depth[1]))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if(depth[1] >= depth[0])
|
|
||||||
return true;
|
|
||||||
|
|
||||||
depth[0] = depth[1];
|
|
||||||
next = event_idx;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!closure(next))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
auth.idx = next;
|
|
||||||
next = 0;
|
|
||||||
}
|
|
||||||
while(auth.idx);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue