mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 16:46:50 +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);
|
||||
}
|
||||
|
||||
static void rebuild();
|
||||
};
|
||||
|
||||
struct ircd::m::event::auth::chain
|
||||
|
|
|
@ -13,16 +13,18 @@
|
|||
|
||||
struct ircd::m::event::refs
|
||||
{
|
||||
using closure_bool = event::closure_idx_bool;
|
||||
|
||||
event::idx idx;
|
||||
|
||||
public:
|
||||
using closure_bool = event::closure_idx_bool;
|
||||
|
||||
bool for_each(const closure_bool &) const;
|
||||
bool has(const event::idx &) const noexcept;
|
||||
size_t count() const noexcept;
|
||||
|
||||
refs(const event::idx &idx) noexcept;
|
||||
|
||||
static void rebuild();
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
|
@ -28,14 +28,14 @@ std::ostream &
|
|||
ircd::m::pretty(std::ostream &s,
|
||||
const event &e)
|
||||
{
|
||||
using prototype = void (std::ostream &, const event &);
|
||||
using prototype = std::ostream &(std::ostream &, const event &);
|
||||
|
||||
static mods::import<prototype> pretty
|
||||
{
|
||||
"m_event", "pretty__event"
|
||||
"m_event", "ircd::m::pretty"
|
||||
};
|
||||
|
||||
pretty(s, e);
|
||||
return s;
|
||||
return pretty(s, e);
|
||||
}
|
||||
|
||||
std::string
|
||||
|
@ -55,14 +55,14 @@ ircd::m::pretty_oneline(std::ostream &s,
|
|||
const event &e,
|
||||
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
|
||||
{
|
||||
"m_event", "pretty_oneline__event"
|
||||
"m_event", "ircd::m::pretty_oneline"
|
||||
};
|
||||
|
||||
pretty_oneline(s, e, content_keys);
|
||||
return s;
|
||||
return pretty_oneline(s, e, content_keys);
|
||||
}
|
||||
|
||||
std::string
|
||||
|
@ -80,10 +80,11 @@ std::ostream &
|
|||
ircd::m::pretty_msgline(std::ostream &s,
|
||||
const event &e)
|
||||
{
|
||||
using prototype = void (std::ostream &, const event &);
|
||||
using prototype = std::ostream &(std::ostream &, const event &);
|
||||
|
||||
static mods::import<prototype> pretty_msgline
|
||||
{
|
||||
"m_event", "pretty_msgline__event"
|
||||
"m_event", "ircd::m::pretty_msgline"
|
||||
};
|
||||
|
||||
pretty_msgline(s, e);
|
||||
|
@ -105,10 +106,11 @@ std::ostream &
|
|||
ircd::m::pretty(std::ostream &s,
|
||||
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
|
||||
{
|
||||
"m_event", "pretty__prev"
|
||||
"m_event", "ircd::m::pretty"
|
||||
};
|
||||
|
||||
pretty(s, prev);
|
||||
|
@ -130,10 +132,11 @@ std::ostream &
|
|||
ircd::m::pretty_oneline(std::ostream &s,
|
||||
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
|
||||
{
|
||||
"m_event", "pretty_oneline__prev"
|
||||
"m_event", "ircd::m::pretty_oneline"
|
||||
};
|
||||
|
||||
pretty_oneline(s, prev);
|
||||
|
@ -1129,6 +1132,19 @@ ircd::m::is_power_event(const m::event &event)
|
|||
// 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
|
||||
ircd::m::event::auth::chain::for_each(const closure &closure)
|
||||
const
|
||||
|
@ -1141,14 +1157,14 @@ ircd::m::event::auth::chain::for_each(const string_view &type,
|
|||
const closure &c)
|
||||
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
|
||||
//
|
||||
|
||||
void
|
||||
ircd::m::event::refs::rebuild()
|
||||
{
|
||||
using prototype = void ();
|
||||
|
||||
static mods::import<prototype> rebuild
|
||||
{
|
||||
"m_event", "ircd::m::event::refs::rebuild"
|
||||
};
|
||||
|
||||
rebuild();
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::event::refs::count()
|
||||
const noexcept
|
||||
|
@ -1981,7 +2010,7 @@ ircd::m::event::essential(json::iov &event,
|
|||
|
||||
static mods::import<prototype> _essential
|
||||
{
|
||||
"m_event", "_essential__iov"
|
||||
"m_event", "ircd::m::event::essential"
|
||||
};
|
||||
|
||||
_essential(event, contents, closure);
|
||||
|
@ -1991,11 +2020,11 @@ ircd::m::event
|
|||
ircd::m::essential(m::event event,
|
||||
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
|
||||
{
|
||||
"m_event", "_essential"
|
||||
"m_event", "ircd::m::essential"
|
||||
};
|
||||
|
||||
return _essential(event, contentbuf);
|
||||
|
|
|
@ -5862,13 +5862,7 @@ console_cmd__event__refs(opt &out, const string_view &line)
|
|||
bool
|
||||
console_cmd__event__refs__rebuild(opt &out, const string_view &line)
|
||||
{
|
||||
using prototype = void ();
|
||||
static mods::import<prototype> rebuild
|
||||
{
|
||||
"m_event", "event_refs__rebuild"
|
||||
};
|
||||
|
||||
rebuild();
|
||||
m::event::refs::rebuild();
|
||||
out << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
@ -5964,13 +5958,7 @@ console_cmd__event__auth__chain(opt &out, const string_view &line)
|
|||
bool
|
||||
console_cmd__event__auth__rebuild(opt &out, const string_view &line)
|
||||
{
|
||||
using prototype = void ();
|
||||
static mods::import<prototype> rebuild
|
||||
{
|
||||
"m_event", "event_auth__rebuild"
|
||||
};
|
||||
|
||||
rebuild();
|
||||
m::event::refs::rebuild();
|
||||
out << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,18 +11,6 @@
|
|||
using namespace ircd::m;
|
||||
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
|
||||
IRCD_MODULE
|
||||
{
|
||||
|
@ -30,9 +18,10 @@ IRCD_MODULE
|
|||
};
|
||||
|
||||
void
|
||||
ircd::m::_essential__iov(json::iov &event,
|
||||
const json::iov &contents,
|
||||
const event::closure_iov_mutable &closure)
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::event::essential(json::iov &event,
|
||||
const json::iov &contents,
|
||||
const event::closure_iov_mutable &closure)
|
||||
{
|
||||
const auto &type
|
||||
{
|
||||
|
@ -152,9 +141,10 @@ ircd::m::_essential__iov(json::iov &event,
|
|||
}
|
||||
}
|
||||
|
||||
ircd::m::event &
|
||||
ircd::m::_essential(m::event &event,
|
||||
const mutable_buffer &contentbuf)
|
||||
ircd::m::event
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::essential(m::event event,
|
||||
const mutable_buffer &contentbuf)
|
||||
{
|
||||
const auto &type
|
||||
{
|
||||
|
@ -234,9 +224,10 @@ ircd::m::_essential(m::event &event,
|
|||
return event;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
pretty__event(std::ostream &s,
|
||||
const event &event)
|
||||
std::ostream &
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::pretty(std::ostream &s,
|
||||
const event &event)
|
||||
{
|
||||
const auto out{[&s]
|
||||
(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 "
|
||||
<< ':' << content.first
|
||||
<< std::endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
pretty_oneline__event(std::ostream &s,
|
||||
const event &event,
|
||||
const bool &content_keys)
|
||||
std::ostream &
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::pretty_oneline(std::ostream &s,
|
||||
const event &event,
|
||||
const bool &content_keys)
|
||||
{
|
||||
const auto out{[&s]
|
||||
(const string_view &key, auto&& val)
|
||||
|
@ -442,11 +436,14 @@ pretty_oneline__event(std::ostream &s,
|
|||
for(const auto &content : contents)
|
||||
s << content.first << " ";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
pretty_msgline__event(std::ostream &s,
|
||||
const event &event)
|
||||
std::ostream &
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::pretty_msgline(std::ostream &s,
|
||||
const event &event)
|
||||
{
|
||||
s << json::get<"depth"_>(event) << " :";
|
||||
s << json::get<"type"_>(event) << " ";
|
||||
|
@ -481,11 +478,14 @@ pretty_msgline__event(std::ostream &s,
|
|||
s << string_view{content};
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
pretty__prev(std::ostream &s,
|
||||
const event::prev &prev)
|
||||
std::ostream &
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::pretty(std::ostream &s,
|
||||
const event::prev &prev)
|
||||
{
|
||||
const auto out{[&s]
|
||||
(const string_view &key, auto&& val)
|
||||
|
@ -532,11 +532,14 @@ pretty__prev(std::ostream &s,
|
|||
|
||||
s << std::endl;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
pretty_oneline__prev(std::ostream &s,
|
||||
const event::prev &prev)
|
||||
std::ostream &
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::pretty_oneline(std::ostream &s,
|
||||
const event::prev &prev)
|
||||
{
|
||||
const auto &auth_events{json::get<"auth_events"_>(prev)};
|
||||
s << "A[ ";
|
||||
|
@ -555,10 +558,13 @@ pretty_oneline__prev(std::ostream &s,
|
|||
for(const json::array prev_event : prev_events)
|
||||
s << unquote(prev_event[0]) << " ";
|
||||
s << "] ";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
event_refs__rebuild()
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::event::refs::rebuild()
|
||||
{
|
||||
static const size_t pool_size{64};
|
||||
static const size_t log_interval{8192};
|
||||
|
@ -618,8 +624,43 @@ event_refs__rebuild()
|
|||
txn();
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
event_auth__rebuild()
|
||||
bool
|
||||
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 log_interval{8192};
|
||||
|
@ -682,35 +723,3 @@ event_auth__rebuild()
|
|||
|
||||
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…
Reference in a new issue