mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
modules/vm: Rename/export core functions.
This commit is contained in:
parent
82378db816
commit
4b7bc1d5b1
2 changed files with 34 additions and 36 deletions
23
ircd/m.cc
23
ircd/m.cc
|
@ -1389,12 +1389,12 @@ ircd::m::vm::eval::operator()(const room &room,
|
||||||
{
|
{
|
||||||
using prototype = fault (eval &, const m::room &, json::iov &, const json::iov &);
|
using prototype = fault (eval &, const m::room &, json::iov &, const json::iov &);
|
||||||
|
|
||||||
static mods::import<prototype> function
|
static mods::import<prototype> call
|
||||||
{
|
{
|
||||||
"vm", "eval__commit_room"
|
"vm", "ircd::m::vm::inject"
|
||||||
};
|
};
|
||||||
|
|
||||||
return function(*this, room, event, contents);
|
return call(*this, room, event, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inject a new event originating from this server.
|
/// Inject a new event originating from this server.
|
||||||
|
@ -1405,12 +1405,12 @@ ircd::m::vm::eval::operator()(json::iov &event,
|
||||||
{
|
{
|
||||||
using prototype = fault (eval &, json::iov &, const json::iov &);
|
using prototype = fault (eval &, json::iov &, const json::iov &);
|
||||||
|
|
||||||
static mods::import<prototype> function
|
static mods::import<prototype> call
|
||||||
{
|
{
|
||||||
"vm", "eval__commit"
|
"vm", "ircd::m::vm::inject"
|
||||||
};
|
};
|
||||||
|
|
||||||
return function(*this, event, contents);
|
return call(*this, event, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ircd::m::vm::fault
|
enum ircd::m::vm::fault
|
||||||
|
@ -1418,17 +1418,12 @@ ircd::m::vm::eval::operator()(const event &event)
|
||||||
{
|
{
|
||||||
using prototype = fault (eval &, const m::event &);
|
using prototype = fault (eval &, const m::event &);
|
||||||
|
|
||||||
static mods::import<prototype> function
|
static mods::import<prototype> call
|
||||||
{
|
{
|
||||||
"vm", "eval__event"
|
"vm", "ircd::m::vm::execute"
|
||||||
};
|
};
|
||||||
|
|
||||||
const vm::fault ret
|
return call(*this, event);
|
||||||
{
|
|
||||||
function(*this, event)
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -13,15 +13,15 @@ namespace ircd::m::vm
|
||||||
static void write_commit(eval &);
|
static void write_commit(eval &);
|
||||||
static void write_append(eval &, const event &);
|
static void write_append(eval &, const event &);
|
||||||
static void write_prepare(eval &, const event &);
|
static void write_prepare(eval &, const event &);
|
||||||
static fault _eval_edu(eval &, const event &);
|
static fault execute_edu(eval &, const event &);
|
||||||
static fault _eval_pdu(eval &, const event &);
|
static fault execute_pdu(eval &, const event &);
|
||||||
|
|
||||||
template<class... args>
|
template<class... args>
|
||||||
static fault handle_error(const opts &opts, const fault &code, const string_view &fmt, args&&... a);
|
static fault handle_error(const opts &opts, const fault &code, const string_view &fmt, args&&... a);
|
||||||
|
|
||||||
extern "C" fault eval__event(eval &, const event &);
|
fault execute(eval &, const event &);
|
||||||
extern "C" fault eval__commit(eval &, json::iov &, const json::iov &);
|
fault inject(eval &, json::iov &, const json::iov &);
|
||||||
extern "C" fault eval__commit_room(eval &, const room &, json::iov &, const json::iov &);
|
fault inject(eval &, const room &, json::iov &, const json::iov &);
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void fini();
|
static void fini();
|
||||||
|
@ -190,10 +190,11 @@ ircd::m::vm::fini()
|
||||||
//
|
//
|
||||||
|
|
||||||
enum ircd::m::vm::fault
|
enum ircd::m::vm::fault
|
||||||
ircd::m::vm::eval__commit_room(eval &eval,
|
IRCD_MODULE_EXPORT
|
||||||
const room &room,
|
ircd::m::vm::inject(eval &eval,
|
||||||
json::iov &event,
|
const room &room,
|
||||||
const json::iov &contents)
|
json::iov &event,
|
||||||
|
const json::iov &contents)
|
||||||
{
|
{
|
||||||
// This eval entry point is only used for commits. We try to find the
|
// This eval entry point is only used for commits. We try to find the
|
||||||
// commit opts the user supplied directly to this eval or with the room.
|
// commit opts the user supplied directly to this eval or with the room.
|
||||||
|
@ -325,13 +326,14 @@ ircd::m::vm::eval__commit_room(eval &eval,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return eval(event, contents);
|
return inject(eval, event, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ircd::m::vm::fault
|
enum ircd::m::vm::fault
|
||||||
ircd::m::vm::eval__commit(eval &eval,
|
IRCD_MODULE_EXPORT
|
||||||
json::iov &event,
|
ircd::m::vm::inject(eval &eval,
|
||||||
const json::iov &contents)
|
json::iov &event,
|
||||||
|
const json::iov &contents)
|
||||||
{
|
{
|
||||||
// This eval entry point is only used for commits. If the user did not
|
// This eval entry point is only used for commits. If the user did not
|
||||||
// supply commit opts we supply the default ones here.
|
// supply commit opts we supply the default ones here.
|
||||||
|
@ -477,12 +479,13 @@ ircd::m::vm::eval__commit(eval &eval,
|
||||||
event, { "content", content },
|
event, { "content", content },
|
||||||
};
|
};
|
||||||
|
|
||||||
return eval(event);
|
return execute(eval, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ircd::m::vm::fault
|
enum ircd::m::vm::fault
|
||||||
ircd::m::vm::eval__event(eval &eval,
|
IRCD_MODULE_EXPORT
|
||||||
const event &event)
|
ircd::m::vm::execute(eval &eval,
|
||||||
|
const event &event)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Set a member pointer to the event currently being evaluated. This
|
// Set a member pointer to the event currently being evaluated. This
|
||||||
|
@ -519,8 +522,8 @@ try
|
||||||
const fault ret
|
const fault ret
|
||||||
{
|
{
|
||||||
json::get<"event_id"_>(event)?
|
json::get<"event_id"_>(event)?
|
||||||
_eval_pdu(eval, event):
|
execute_pdu(eval, event):
|
||||||
_eval_edu(eval, event)
|
execute_edu(eval, event)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(ret != fault::ACCEPT)
|
if(ret != fault::ACCEPT)
|
||||||
|
@ -621,8 +624,8 @@ ircd::m::vm::handle_error(const vm::opts &opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ircd::m::vm::fault
|
enum ircd::m::vm::fault
|
||||||
ircd::m::vm::_eval_edu(eval &eval,
|
ircd::m::vm::execute_edu(eval &eval,
|
||||||
const event &event)
|
const event &event)
|
||||||
{
|
{
|
||||||
if(eval.opts->eval)
|
if(eval.opts->eval)
|
||||||
eval_hook(event, eval);
|
eval_hook(event, eval);
|
||||||
|
@ -631,8 +634,8 @@ ircd::m::vm::_eval_edu(eval &eval,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ircd::m::vm::fault
|
enum ircd::m::vm::fault
|
||||||
ircd::m::vm::_eval_pdu(eval &eval,
|
ircd::m::vm::execute_pdu(eval &eval,
|
||||||
const event &event)
|
const event &event)
|
||||||
{
|
{
|
||||||
assert(eval.opts);
|
assert(eval.opts);
|
||||||
const auto &opts
|
const auto &opts
|
||||||
|
|
Loading…
Reference in a new issue