mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/266-namespaces'
Merge adjustments: - Preserved original `base_type_no_ref` argument type as ::TypeTag - Removed superfluous #pragma guard around deprecated TableVal ctor - Clarify NEWS regarding MetaHook{Pre,Post} deprecations - Simplify some `::zeek::` qualifications to just `zeek::` - Prefixed FORWARD_DECLARE_NAMESPACED macro with ZEEK_ * origin/topic/timw/266-namespaces: Disable some deprecation diagnostics for GCC Rename BroType to Type Update NEWS Review cleanup Move Type types to zeek namespace Move Flare/Pipe from the bro namespace to zeek::detail Move Attr to the zeek::detail namespace Move Trigger into the zeek::detail namespace Move ID to the zeek::detail namespace Move Anon.h into zeek::detail namespace Mark all of the aliased classes in plugin/Plugin.h deprecated, and fix all of the plugins that were using them Move all of the base plugin classes into the zeek::plugin namespace Expr: move all classes into zeek::detail Stmt: move Stmt classes into zeek::detail namespace Add utility macro for creating namespaced aliases for classes
This commit is contained in:
commit
d4f3cad7d1
256 changed files with 4277 additions and 3501 deletions
102
src/Func.cc
102
src/Func.cc
|
@ -121,8 +121,8 @@ Func::Func(Kind arg_kind) : kind(arg_kind)
|
|||
|
||||
Func::~Func() = default;
|
||||
|
||||
void Func::AddBody(IntrusivePtr<Stmt> /* new_body */,
|
||||
const std::vector<IntrusivePtr<ID>>& /* new_inits */,
|
||||
void Func::AddBody(IntrusivePtr<zeek::detail::Stmt> /* new_body */,
|
||||
const std::vector<IntrusivePtr<zeek::detail::ID>>& /* new_inits */,
|
||||
size_t /* new_frame_size */, int /* priority */)
|
||||
{
|
||||
Internal("Func::AddBody called");
|
||||
|
@ -216,7 +216,7 @@ void Func::CopyStateInto(Func* other) const
|
|||
}
|
||||
|
||||
void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||
function_flavor flavor) const
|
||||
zeek::FunctionFlavor flavor) const
|
||||
{
|
||||
// Helper function factoring out this code from BroFunc:Call() for
|
||||
// better readability.
|
||||
|
@ -232,32 +232,32 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
|||
}
|
||||
|
||||
switch ( flavor ) {
|
||||
case FUNC_FLAVOR_EVENT:
|
||||
case zeek::FUNC_FLAVOR_EVENT:
|
||||
if ( hook_result )
|
||||
reporter->InternalError("plugin returned non-void result for event %s",
|
||||
this->Name());
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_HOOK:
|
||||
if ( hook_result->GetType()->Tag() != TYPE_BOOL )
|
||||
case zeek::FUNC_FLAVOR_HOOK:
|
||||
if ( hook_result->GetType()->Tag() != zeek::TYPE_BOOL )
|
||||
reporter->InternalError("plugin returned non-bool for hook %s",
|
||||
this->Name());
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_FUNCTION:
|
||||
case zeek::FUNC_FLAVOR_FUNCTION:
|
||||
{
|
||||
const auto& yt = GetType()->Yield();
|
||||
|
||||
if ( (! yt) || yt->Tag() == TYPE_VOID )
|
||||
if ( (! yt) || yt->Tag() == zeek::TYPE_VOID )
|
||||
{
|
||||
if ( hook_result )
|
||||
reporter->InternalError("plugin returned non-void result for void method %s",
|
||||
this->Name());
|
||||
}
|
||||
|
||||
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != TYPE_ANY )
|
||||
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != zeek::TYPE_ANY )
|
||||
{
|
||||
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
|
||||
hook_result->GetType()->Tag(), yt->Tag(), this->Name());
|
||||
|
@ -268,13 +268,13 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
|||
}
|
||||
}
|
||||
|
||||
BroFunc::BroFunc(const IntrusivePtr<ID>& arg_id, IntrusivePtr<Stmt> arg_body,
|
||||
const std::vector<IntrusivePtr<ID>>& aggr_inits,
|
||||
BroFunc::BroFunc(const IntrusivePtr<zeek::detail::ID>& arg_id, IntrusivePtr<zeek::detail::Stmt> arg_body,
|
||||
const std::vector<IntrusivePtr<zeek::detail::ID>>& aggr_inits,
|
||||
size_t arg_frame_size, int priority)
|
||||
: Func(BRO_FUNC)
|
||||
{
|
||||
name = arg_id->Name();
|
||||
type = arg_id->GetType<FuncType>();
|
||||
type = arg_id->GetType<zeek::FuncType>();
|
||||
frame_size = arg_frame_size;
|
||||
|
||||
if ( arg_body )
|
||||
|
@ -326,8 +326,8 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
if ( bodies.empty() )
|
||||
{
|
||||
// Can only happen for events and hooks.
|
||||
assert(Flavor() == FUNC_FLAVOR_EVENT || Flavor() == FUNC_FLAVOR_HOOK);
|
||||
return Flavor() == FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
|
||||
assert(Flavor() == zeek::FUNC_FLAVOR_EVENT || Flavor() == zeek::FUNC_FLAVOR_HOOK);
|
||||
return Flavor() == zeek::FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
|
||||
}
|
||||
|
||||
auto f = make_intrusive<Frame>(frame_size, this, args);
|
||||
|
@ -343,7 +343,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
}
|
||||
|
||||
g_frame_stack.push_back(f.get()); // used for backtracing
|
||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||
const zeek::detail::CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||
|
||||
if ( g_trace_state.DoTrace() )
|
||||
|
@ -384,7 +384,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
catch ( InterpreterException& e )
|
||||
{
|
||||
// Already reported, but now determine whether to unwind further.
|
||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
g_frame_stack.pop_back();
|
||||
call_stack.pop_back();
|
||||
|
@ -404,7 +404,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
break;
|
||||
}
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_HOOK )
|
||||
{
|
||||
// Ignore any return values of hook bodies, final return value
|
||||
// depends on whether a body returns as a result of break statement.
|
||||
|
@ -421,7 +421,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
|
||||
call_stack.pop_back();
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_HOOK )
|
||||
{
|
||||
if ( ! result )
|
||||
result = val_mgr->True();
|
||||
|
@ -429,7 +429,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
|
||||
// Warn if the function returns something, but we returned from
|
||||
// the function without an explicit return, or without a value.
|
||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID &&
|
||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != zeek::TYPE_VOID &&
|
||||
(flow != FLOW_RETURN /* we fell off the end */ ||
|
||||
! result /* explicit return with no result */) &&
|
||||
! f->HasDelayed() )
|
||||
|
@ -449,8 +449,8 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
return result;
|
||||
}
|
||||
|
||||
void BroFunc::AddBody(IntrusivePtr<Stmt> new_body,
|
||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
||||
void BroFunc::AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||
size_t new_frame_size, int priority)
|
||||
{
|
||||
if ( new_frame_size > frame_size )
|
||||
|
@ -463,7 +463,7 @@ void BroFunc::AddBody(IntrusivePtr<Stmt> new_body,
|
|||
|
||||
new_body = AddInits(std::move(new_body), new_inits);
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
if ( Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||
{
|
||||
// For functions, we replace the old body with the new one.
|
||||
assert(bodies.size() <= 1);
|
||||
|
@ -574,14 +574,14 @@ void BroFunc::Describe(ODesc* d) const
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<Stmt> BroFunc::AddInits(IntrusivePtr<Stmt> body,
|
||||
const std::vector<IntrusivePtr<ID>>& inits)
|
||||
IntrusivePtr<zeek::detail::Stmt> BroFunc::AddInits(IntrusivePtr<zeek::detail::Stmt> body,
|
||||
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits)
|
||||
{
|
||||
if ( inits.empty() )
|
||||
return body;
|
||||
|
||||
auto stmt_series = make_intrusive<StmtList>();
|
||||
stmt_series->Stmts().push_back(new InitStmt(inits));
|
||||
auto stmt_series = make_intrusive<zeek::detail::StmtList>();
|
||||
stmt_series->Stmts().push_back(new zeek::detail::InitStmt(inits));
|
||||
stmt_series->Stmts().push_back(body.release());
|
||||
|
||||
return stmt_series;
|
||||
|
@ -601,7 +601,7 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name,
|
|||
if ( id->HasVal() )
|
||||
reporter->InternalError("built-in function %s multiply defined", Name());
|
||||
|
||||
type = id->GetType<FuncType>();
|
||||
type = id->GetType<zeek::FuncType>();
|
||||
id->SetVal(make_intrusive<Val>(IntrusivePtr{NewRef{}, this}));
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
HookCallFunction(this, parent, args),
|
||||
empty_hook_result);
|
||||
|
||||
CheckPluginResult(handled, hook_result, FUNC_FLAVOR_FUNCTION);
|
||||
CheckPluginResult(handled, hook_result, zeek::FUNC_FLAVOR_FUNCTION);
|
||||
|
||||
if ( handled )
|
||||
return hook_result;
|
||||
|
@ -641,7 +641,7 @@ IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
|
|||
g_trace_state.LogTrace("\tBuiltin Function called: %s\n", d.Description());
|
||||
}
|
||||
|
||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||
const zeek::detail::CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||
auto result = std::move(func(parent, args).rval);
|
||||
call_stack.pop_back();
|
||||
|
@ -675,7 +675,7 @@ void builtin_error(const char* msg, IntrusivePtr<Val> arg)
|
|||
|
||||
void builtin_error(const char* msg, BroObj* arg)
|
||||
{
|
||||
auto emit = [=](const CallExpr* ce)
|
||||
auto emit = [=](const zeek::detail::CallExpr* ce)
|
||||
{
|
||||
if ( ce )
|
||||
ce->Error(msg, arg);
|
||||
|
@ -758,19 +758,19 @@ void builtin_error(const char* msg, BroObj* arg)
|
|||
|
||||
void init_builtin_funcs()
|
||||
{
|
||||
ProcStats = zeek::id::find_type<RecordType>("ProcStats");
|
||||
NetStats = zeek::id::find_type<RecordType>("NetStats");
|
||||
MatcherStats = zeek::id::find_type<RecordType>("MatcherStats");
|
||||
ConnStats = zeek::id::find_type<RecordType>("ConnStats");
|
||||
ReassemblerStats = zeek::id::find_type<RecordType>("ReassemblerStats");
|
||||
DNSStats = zeek::id::find_type<RecordType>("DNSStats");
|
||||
GapStats = zeek::id::find_type<RecordType>("GapStats");
|
||||
EventStats = zeek::id::find_type<RecordType>("EventStats");
|
||||
TimerStats = zeek::id::find_type<RecordType>("TimerStats");
|
||||
FileAnalysisStats = zeek::id::find_type<RecordType>("FileAnalysisStats");
|
||||
ThreadStats = zeek::id::find_type<RecordType>("ThreadStats");
|
||||
BrokerStats = zeek::id::find_type<RecordType>("BrokerStats");
|
||||
ReporterStats = zeek::id::find_type<RecordType>("ReporterStats");
|
||||
ProcStats = zeek::id::find_type<zeek::RecordType>("ProcStats");
|
||||
NetStats = zeek::id::find_type<zeek::RecordType>("NetStats");
|
||||
MatcherStats = zeek::id::find_type<zeek::RecordType>("MatcherStats");
|
||||
ConnStats = zeek::id::find_type<zeek::RecordType>("ConnStats");
|
||||
ReassemblerStats = zeek::id::find_type<zeek::RecordType>("ReassemblerStats");
|
||||
DNSStats = zeek::id::find_type<zeek::RecordType>("DNSStats");
|
||||
GapStats = zeek::id::find_type<zeek::RecordType>("GapStats");
|
||||
EventStats = zeek::id::find_type<zeek::RecordType>("EventStats");
|
||||
TimerStats = zeek::id::find_type<zeek::RecordType>("TimerStats");
|
||||
FileAnalysisStats = zeek::id::find_type<zeek::RecordType>("FileAnalysisStats");
|
||||
ThreadStats = zeek::id::find_type<zeek::RecordType>("ThreadStats");
|
||||
BrokerStats = zeek::id::find_type<zeek::RecordType>("BrokerStats");
|
||||
ReporterStats = zeek::id::find_type<zeek::RecordType>("ReporterStats");
|
||||
|
||||
var_sizes = zeek::id::find_type("var_sizes")->AsTableType();
|
||||
|
||||
|
@ -789,7 +789,7 @@ void init_builtin_funcs_subdirs()
|
|||
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
|
||||
}
|
||||
|
||||
bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
||||
bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call)
|
||||
{
|
||||
if ( f->TheFunc() != zeek::BifFunc::fmt_bif)
|
||||
return true;
|
||||
|
@ -802,8 +802,8 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
|||
return true;
|
||||
}
|
||||
|
||||
const Expr* fmt_str_arg = args[0];
|
||||
if ( fmt_str_arg->GetType()->Tag() != TYPE_STRING )
|
||||
const zeek::detail::Expr* fmt_str_arg = args[0];
|
||||
if ( fmt_str_arg->GetType()->Tag() != zeek::TYPE_STRING )
|
||||
{
|
||||
call->Error("first argument to fmt() needs to be a format string");
|
||||
return false;
|
||||
|
@ -844,16 +844,16 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
|||
|
||||
// Gets a function's priority from its Scope's attributes. Errors if it sees any
|
||||
// problems.
|
||||
static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
|
||||
static int get_func_priority(const std::vector<IntrusivePtr<zeek::detail::Attr>>& attrs)
|
||||
{
|
||||
int priority = 0;
|
||||
|
||||
for ( const auto& a : attrs )
|
||||
{
|
||||
if ( a->Tag() == ATTR_DEPRECATED )
|
||||
if ( a->Tag() == zeek::detail::ATTR_DEPRECATED )
|
||||
continue;
|
||||
|
||||
if ( a->Tag() != ATTR_PRIORITY )
|
||||
if ( a->Tag() != zeek::detail::ATTR_PRIORITY )
|
||||
{
|
||||
a->Error("illegal attribute for function body");
|
||||
continue;
|
||||
|
@ -867,7 +867,7 @@ static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( ! IsIntegral(v->GetType()->Tag()) )
|
||||
if ( ! zeek::IsIntegral(v->GetType()->Tag()) )
|
||||
{
|
||||
a->Error("expression is not of integral type");
|
||||
continue;
|
||||
|
@ -879,7 +879,7 @@ static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
|
|||
return priority;
|
||||
}
|
||||
|
||||
function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<Stmt> body)
|
||||
function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body)
|
||||
{
|
||||
frame_size = scope->Length();
|
||||
inits = scope->GetInits();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue