mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Deprecate ID::ID_Val(), replace with ID::GetVal()
This commit is contained in:
parent
16a8bf3318
commit
32b895f4ba
23 changed files with 69 additions and 68 deletions
2
NEWS
2
NEWS
|
@ -157,6 +157,8 @@ Deprecated Functionality
|
||||||
|
|
||||||
- ``ID::Type()`` is deprecated, use ``ID::GetType()``.
|
- ``ID::Type()`` is deprecated, use ``ID::GetType()``.
|
||||||
|
|
||||||
|
- ``ID::ID_Val()`` is deprecated, use ``ID::GetVal()``.
|
||||||
|
|
||||||
Zeek 3.1.0
|
Zeek 3.1.0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Func* func = id->ID_Val()->AsFunc();
|
const Func* func = id->GetVal()->AsFunc();
|
||||||
const vector<Func::Body>& bodies = func->GetBodies();
|
const vector<Func::Body>& bodies = func->GetBodies();
|
||||||
|
|
||||||
if ( bodies.size() == 0 )
|
if ( bodies.size() == 0 )
|
||||||
|
|
|
@ -236,7 +236,7 @@ IntrusivePtr<Val> NameExpr::Eval(Frame* f) const
|
||||||
return make_intrusive<Val>(id->GetType(), true);
|
return make_intrusive<Val>(id->GetType(), true);
|
||||||
|
|
||||||
if ( id->IsGlobal() )
|
if ( id->IsGlobal() )
|
||||||
v = {NewRef{}, id->ID_Val()};
|
v = id->GetVal();
|
||||||
|
|
||||||
else if ( f )
|
else if ( f )
|
||||||
v = {NewRef{}, f->GetElement(id.get())};
|
v = {NewRef{}, f->GetElement(id.get())};
|
||||||
|
|
29
src/ID.cc
29
src/ID.cc
|
@ -25,7 +25,6 @@ ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
||||||
scope = arg_scope;
|
scope = arg_scope;
|
||||||
is_export = arg_is_export;
|
is_export = arg_is_export;
|
||||||
is_option = false;
|
is_option = false;
|
||||||
val = nullptr;
|
|
||||||
is_const = false;
|
is_const = false;
|
||||||
is_enum_const = false;
|
is_enum_const = false;
|
||||||
is_type = false;
|
is_type = false;
|
||||||
|
@ -41,8 +40,8 @@ ID::~ID()
|
||||||
{
|
{
|
||||||
delete [] name;
|
delete [] name;
|
||||||
|
|
||||||
if ( ! weak_ref )
|
if ( weak_ref )
|
||||||
Unref(val);
|
val.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ID::ModuleName() const
|
std::string ID::ModuleName() const
|
||||||
|
@ -57,18 +56,16 @@ void ID::SetType(IntrusivePtr<BroType> t)
|
||||||
|
|
||||||
void ID::ClearVal()
|
void ID::ClearVal()
|
||||||
{
|
{
|
||||||
if ( ! weak_ref )
|
if ( weak_ref )
|
||||||
Unref(val);
|
val.release();
|
||||||
|
|
||||||
val = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::SetVal(IntrusivePtr<Val> v, bool arg_weak_ref)
|
void ID::SetVal(IntrusivePtr<Val> v, bool arg_weak_ref)
|
||||||
{
|
{
|
||||||
if ( ! weak_ref )
|
if ( weak_ref )
|
||||||
Unref(val);
|
val.release();
|
||||||
|
|
||||||
val = v.release();
|
val = std::move(v);
|
||||||
weak_ref = arg_weak_ref;
|
weak_ref = arg_weak_ref;
|
||||||
Modified();
|
Modified();
|
||||||
|
|
||||||
|
@ -124,12 +121,12 @@ void ID::SetVal(IntrusivePtr<Val> v, init_class c)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
v->AddTo(val, false);
|
v->AddTo(val.get(), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( val )
|
if ( val )
|
||||||
v->RemoveFrom(val);
|
v->RemoveFrom(val.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +264,7 @@ void ID::SetOption()
|
||||||
|
|
||||||
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
||||||
{
|
{
|
||||||
auto arg1 = make_intrusive<ConstExpr>(IntrusivePtr{NewRef{}, val});
|
auto arg1 = make_intrusive<ConstExpr>(val);
|
||||||
auto args = make_intrusive<ListExpr>();
|
auto args = make_intrusive<ListExpr>();
|
||||||
args->Append(std::move(arg1));
|
args->Append(std::move(arg1));
|
||||||
args->Append(std::move(ev));
|
args->Append(std::move(ev));
|
||||||
|
@ -488,10 +485,8 @@ void ID::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
d->Add(":Default:");
|
d->Add(":Default:");
|
||||||
auto ii = zeekygen_mgr->GetIdentifierInfo(Name());
|
auto ii = zeekygen_mgr->GetIdentifierInfo(Name());
|
||||||
auto redefs = ii->GetRedefs();
|
auto redefs = ii->GetRedefs();
|
||||||
auto iv = val;
|
const auto& iv = ! redefs.empty() && ii->InitialVal() ? ii->InitialVal()
|
||||||
|
: val;
|
||||||
if ( ! redefs.empty() && ii->InitialVal() )
|
|
||||||
iv = ii->InitialVal();
|
|
||||||
|
|
||||||
if ( type->InternalType() == TYPE_INTERNAL_OTHER )
|
if ( type->InternalType() == TYPE_INTERNAL_OTHER )
|
||||||
{
|
{
|
||||||
|
|
13
src/ID.h
13
src/ID.h
|
@ -70,8 +70,15 @@ public:
|
||||||
void SetVal(IntrusivePtr<Expr> ev, init_class c);
|
void SetVal(IntrusivePtr<Expr> ev, init_class c);
|
||||||
|
|
||||||
bool HasVal() const { return val != nullptr; }
|
bool HasVal() const { return val != nullptr; }
|
||||||
Val* ID_Val() { return val; }
|
|
||||||
const Val* ID_Val() const { return val; }
|
[[deprecated("Remove in v4.1. Use GetVal().")]]
|
||||||
|
Val* ID_Val() { return val.get(); }
|
||||||
|
[[deprecated("Remove in v4.1. Use GetVal().")]]
|
||||||
|
const Val* ID_Val() const { return val.get(); }
|
||||||
|
|
||||||
|
const IntrusivePtr<Val>& GetVal() const
|
||||||
|
{ return val; }
|
||||||
|
|
||||||
void ClearVal();
|
void ClearVal();
|
||||||
|
|
||||||
void SetConst() { is_const = true; }
|
void SetConst() { is_const = true; }
|
||||||
|
@ -139,7 +146,7 @@ protected:
|
||||||
IntrusivePtr<BroType> type;
|
IntrusivePtr<BroType> type;
|
||||||
bool is_const, is_enum_const, is_type, is_option;
|
bool is_const, is_enum_const, is_type, is_option;
|
||||||
int offset;
|
int offset;
|
||||||
Val* val;
|
IntrusivePtr<Val> val;
|
||||||
IntrusivePtr<Attributes> attrs;
|
IntrusivePtr<Attributes> attrs;
|
||||||
// contains list of functions that are called when an option changes
|
// contains list of functions that are called when an option changes
|
||||||
std::multimap<int, IntrusivePtr<Func>> option_handlers;
|
std::multimap<int, IntrusivePtr<Func>> option_handlers;
|
||||||
|
|
|
@ -164,7 +164,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( id->GetType()->Tag() != TYPE_FUNC )
|
if ( id->GetType()->Tag() != TYPE_FUNC )
|
||||||
return id->ID_Val()->AsBool();
|
return id->GetVal()->AsBool();
|
||||||
|
|
||||||
// Call function with a signature_state value as argument.
|
// Call function with a signature_state value as argument.
|
||||||
zeek::Args args;
|
zeek::Args args;
|
||||||
|
@ -180,7 +180,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto val = id->ID_Val()->AsFunc()->Call(args);
|
auto val = id->GetVal()->AsFunc()->Call(args);
|
||||||
result = val && val->AsBool();
|
result = val && val->AsBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1278,7 +1278,7 @@ static Val* get_bro_val(const char* label)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return id->ID_Val();
|
return id->GetVal().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -257,9 +257,9 @@ void ProfileLogger::Log()
|
||||||
// contained in some other global user-visible container.
|
// contained in some other global user-visible container.
|
||||||
if ( id->HasVal() )
|
if ( id->HasVal() )
|
||||||
{
|
{
|
||||||
Val* v = id->ID_Val();
|
const auto& v = id->GetVal();
|
||||||
|
|
||||||
size = id->ID_Val()->MemoryAllocation();
|
size = v->MemoryAllocation();
|
||||||
mem += size;
|
mem += size;
|
||||||
|
|
||||||
bool print = false;
|
bool print = false;
|
||||||
|
|
|
@ -50,7 +50,8 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
||||||
if ( e->Id()->IsGlobal() )
|
if ( e->Id()->IsGlobal() )
|
||||||
trigger->Register(e->Id());
|
trigger->Register(e->Id());
|
||||||
|
|
||||||
Val* v = e->Id()->ID_Val();
|
Val* v = e->Id()->GetVal().get();
|
||||||
|
|
||||||
if ( v && v->Modifiable() )
|
if ( v && v->Modifiable() )
|
||||||
trigger->Register(v);
|
trigger->Register(v);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
||||||
// cyclic dependencies.
|
// cyclic dependencies.
|
||||||
string fullname = make_full_var_name(module_name.c_str(), name);
|
string fullname = make_full_var_name(module_name.c_str(), name);
|
||||||
if ( id->Name() != fullname
|
if ( id->Name() != fullname
|
||||||
|| (id->HasVal() && val != id->ID_Val()->AsEnum())
|
|| (id->HasVal() && val != id->GetVal()->AsEnum())
|
||||||
|| (names.find(fullname) != names.end() && names[fullname] != val) )
|
|| (names.find(fullname) != names.end() && names[fullname] != val) )
|
||||||
{
|
{
|
||||||
reporter->Error("identifier or enumerator value in enumerated type definition already exists");
|
reporter->Error("identifier or enumerator value in enumerated type definition already exists");
|
||||||
|
|
14
src/Var.cc
14
src/Var.cc
|
@ -525,7 +525,7 @@ void begin_func(ID* id, const char* module_name, function_flavor flavor,
|
||||||
|
|
||||||
if ( id->HasVal() )
|
if ( id->HasVal() )
|
||||||
{
|
{
|
||||||
function_flavor id_flavor = id->ID_Val()->AsFunc()->Flavor();
|
function_flavor id_flavor = id->GetVal()->AsFunc()->Flavor();
|
||||||
|
|
||||||
if ( id_flavor != flavor )
|
if ( id_flavor != flavor )
|
||||||
id->Error("inconsistent function flavor", t.get());
|
id->Error("inconsistent function flavor", t.get());
|
||||||
|
@ -630,7 +630,7 @@ void end_func(IntrusivePtr<Stmt> body)
|
||||||
auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body));
|
auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body));
|
||||||
|
|
||||||
if ( ingredients->id->HasVal() )
|
if ( ingredients->id->HasVal() )
|
||||||
ingredients->id->ID_Val()->AsFunc()->AddBody(
|
ingredients->id->GetVal()->AsFunc()->AddBody(
|
||||||
ingredients->body,
|
ingredients->body,
|
||||||
ingredients->inits,
|
ingredients->inits,
|
||||||
ingredients->frame_size,
|
ingredients->frame_size,
|
||||||
|
@ -648,7 +648,7 @@ void end_func(IntrusivePtr<Stmt> body)
|
||||||
ingredients->id->SetConst();
|
ingredients->id->SetConst();
|
||||||
}
|
}
|
||||||
|
|
||||||
ingredients->id->ID_Val()->AsFunc()->SetScope(ingredients->scope);
|
ingredients->id->GetVal()->AsFunc()->SetScope(ingredients->scope);
|
||||||
// Note: ideally, something would take ownership of this memory until the
|
// Note: ideally, something would take ownership of this memory until the
|
||||||
// end of script execution, but that's essentially the same as the
|
// end of script execution, but that's essentially the same as the
|
||||||
// lifetime of the process at the moment, so ok to "leak" it.
|
// lifetime of the process at the moment, so ok to "leak" it.
|
||||||
|
@ -662,7 +662,7 @@ Val* internal_val(const char* name)
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
reporter->InternalError("internal variable %s missing", name);
|
reporter->InternalError("internal variable %s missing", name);
|
||||||
|
|
||||||
return id->ID_Val();
|
return id->GetVal().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
id_list gather_outer_ids(Scope* scope, Stmt* body)
|
id_list gather_outer_ids(Scope* scope, Stmt* body)
|
||||||
|
@ -694,13 +694,13 @@ Val* internal_const_val(const char* name)
|
||||||
if ( ! id->IsConst() )
|
if ( ! id->IsConst() )
|
||||||
reporter->InternalError("internal variable %s is not constant", name);
|
reporter->InternalError("internal variable %s is not constant", name);
|
||||||
|
|
||||||
return id->ID_Val();
|
return id->GetVal().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* opt_internal_val(const char* name)
|
Val* opt_internal_val(const char* name)
|
||||||
{
|
{
|
||||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||||
return id ? id->ID_Val() : nullptr;
|
return id ? id->GetVal().get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
double opt_internal_double(const char* name)
|
double opt_internal_double(const char* name)
|
||||||
|
@ -739,7 +739,7 @@ ListVal* internal_list_val(const char* name)
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
Val* v = id->ID_Val();
|
Val* v = id->GetVal().get();
|
||||||
|
|
||||||
if ( v )
|
if ( v )
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,10 +92,10 @@ void Manager::InitPostScript()
|
||||||
{
|
{
|
||||||
auto id = global_scope()->Lookup("Tunnel::vxlan_ports");
|
auto id = global_scope()->Lookup("Tunnel::vxlan_ports");
|
||||||
|
|
||||||
if ( ! (id && id->ID_Val()) )
|
if ( ! (id && id->GetVal()) )
|
||||||
reporter->FatalError("Tunnel::vxlan_ports not defined");
|
reporter->FatalError("Tunnel::vxlan_ports not defined");
|
||||||
|
|
||||||
auto table_val = id->ID_Val()->AsTableVal();
|
auto table_val = id->GetVal()->AsTableVal();
|
||||||
auto port_list = table_val->ToPureListVal();
|
auto port_list = table_val->ToPureListVal();
|
||||||
|
|
||||||
for ( auto i = 0; i < port_list->Length(); ++i )
|
for ( auto i = 0; i < port_list->Length(); ++i )
|
||||||
|
|
|
@ -31,7 +31,7 @@ refine flow MQTT_Flow += {
|
||||||
reinterpret_cast<const char*>(${msg.topic.str}.begin())));
|
reinterpret_cast<const char*>(${msg.topic.str}.begin())));
|
||||||
|
|
||||||
auto len = ${msg.payload}.length();
|
auto len = ${msg.payload}.length();
|
||||||
auto max = analyzer::MQTT::MQTT_Analyzer::max_payload_size->ID_Val()->AsCount();
|
auto max = analyzer::MQTT::MQTT_Analyzer::max_payload_size->GetVal()->AsCount();
|
||||||
|
|
||||||
if ( len > static_cast<int>(max) )
|
if ( len > static_cast<int>(max) )
|
||||||
len = max;
|
len = max;
|
||||||
|
|
|
@ -357,7 +357,7 @@ struct val_converter {
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto rval = id->ID_Val();
|
const auto& rval = id->GetVal();
|
||||||
if ( ! rval )
|
if ( ! rval )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ struct type_checker {
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto rval = id->ID_Val();
|
const auto& rval = id->GetVal();
|
||||||
if ( ! rval )
|
if ( ! rval )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ static inline Val* get_option(const char* option)
|
||||||
{
|
{
|
||||||
auto id = global_scope()->Lookup(option);
|
auto id = global_scope()->Lookup(option);
|
||||||
|
|
||||||
if ( ! (id && id->ID_Val()) )
|
if ( ! (id && id->GetVal()) )
|
||||||
reporter->FatalError("Unknown Broker option %s", option);
|
reporter->FatalError("Unknown Broker option %s", option);
|
||||||
|
|
||||||
return id->ID_Val();
|
return id->GetVal().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
class BrokerConfig : public broker::configuration {
|
class BrokerConfig : public broker::configuration {
|
||||||
|
@ -418,14 +418,14 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
|
||||||
if ( ! i )
|
if ( ! i )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto val = i->ID_Val();
|
const auto& val = i->GetVal();
|
||||||
|
|
||||||
if ( ! val )
|
if ( ! val )
|
||||||
// Probably could have a special case to also unset the value on the
|
// Probably could have a special case to also unset the value on the
|
||||||
// receiving side, but not sure what use that would be.
|
// receiving side, but not sure what use that would be.
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto data = val_to_data(val);
|
auto data = val_to_data(val.get());
|
||||||
|
|
||||||
if ( ! data )
|
if ( ! data )
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,7 +185,7 @@ function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
|
||||||
static Func* topic_func = 0;
|
static Func* topic_func = 0;
|
||||||
|
|
||||||
if ( ! topic_func )
|
if ( ! topic_func )
|
||||||
topic_func = global_scope()->Lookup("Cluster::rr_topic")->ID_Val()->AsFunc();
|
topic_func = global_scope()->Lookup("Cluster::rr_topic")->GetVal()->AsFunc();
|
||||||
|
|
||||||
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
|
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
|
||||||
auto topic = topic_func->Call(vl);
|
auto topic = topic_func->Call(vl);
|
||||||
|
@ -222,7 +222,7 @@ function Cluster::publish_hrw%(pool: Pool, key: any, ...%): bool
|
||||||
static Func* topic_func = 0;
|
static Func* topic_func = 0;
|
||||||
|
|
||||||
if ( ! topic_func )
|
if ( ! topic_func )
|
||||||
topic_func = global_scope()->Lookup("Cluster::hrw_topic")->ID_Val()->AsFunc();
|
topic_func = global_scope()->Lookup("Cluster::hrw_topic")->GetVal()->AsFunc();
|
||||||
|
|
||||||
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
|
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
|
||||||
auto topic = topic_func->Call(vl);
|
auto topic = topic_func->Call(vl);
|
||||||
|
|
|
@ -1184,7 +1184,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
|
||||||
{
|
{
|
||||||
ID* id = global_scope()->Lookup("Log::default_rotation_interval");
|
ID* id = global_scope()->Lookup("Log::default_rotation_interval");
|
||||||
assert(id);
|
assert(id);
|
||||||
winfo->interval = id->ID_Val()->AsInterval();
|
winfo->interval = id->GetVal()->AsInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->writers.insert(
|
stream->writers.insert(
|
||||||
|
@ -1527,7 +1527,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
|
||||||
{
|
{
|
||||||
ID* id = global_scope()->Lookup("Log::__default_rotation_postprocessor");
|
ID* id = global_scope()->Lookup("Log::__default_rotation_postprocessor");
|
||||||
assert(id);
|
assert(id);
|
||||||
func = id->ID_Val()->AsFunc();
|
func = id->GetVal()->AsFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(func);
|
assert(func);
|
||||||
|
|
|
@ -104,7 +104,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
|
||||||
// Just coerce an empty/unspecified table to the right type.
|
// Just coerce an empty/unspecified table to the right type.
|
||||||
auto tv = make_intrusive<TableVal>(
|
auto tv = make_intrusive<TableVal>(
|
||||||
cast_intrusive<TableType>(i->GetType()),
|
cast_intrusive<TableType>(i->GetType()),
|
||||||
IntrusivePtr{NewRef{}, i->ID_Val()->AsTableVal()->Attrs()});
|
IntrusivePtr{NewRef{}, i->GetVal()->AsTableVal()->Attrs()});
|
||||||
auto rval = call_option_handlers_and_set_value(ID, i, std::move(tv), location);
|
auto rval = call_option_handlers_and_set_value(ID, i, std::move(tv), location);
|
||||||
return val_mgr->Bool(rval);
|
return val_mgr->Bool(rval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1195,7 +1195,7 @@ bool Supervisor::SupervisedNode::InitCluster() const
|
||||||
auto cluster_node_type = global_scope()->Lookup("Cluster::Node")->GetType()->AsRecordType();
|
auto cluster_node_type = global_scope()->Lookup("Cluster::Node")->GetType()->AsRecordType();
|
||||||
auto cluster_nodes_id = global_scope()->Lookup("Cluster::nodes");
|
auto cluster_nodes_id = global_scope()->Lookup("Cluster::nodes");
|
||||||
auto cluster_manager_is_logger_id = global_scope()->Lookup("Cluster::manager_is_logger");
|
auto cluster_manager_is_logger_id = global_scope()->Lookup("Cluster::manager_is_logger");
|
||||||
auto cluster_nodes = cluster_nodes_id->ID_Val()->AsTableVal();
|
auto cluster_nodes = cluster_nodes_id->GetVal()->AsTableVal();
|
||||||
auto has_logger = false;
|
auto has_logger = false;
|
||||||
std::optional<std::string> manager_name;
|
std::optional<std::string> manager_name;
|
||||||
|
|
||||||
|
|
|
@ -631,11 +631,11 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
// initialization).
|
// initialization).
|
||||||
binpac::FlowBuffer::Policy flowbuffer_policy;
|
binpac::FlowBuffer::Policy flowbuffer_policy;
|
||||||
flowbuffer_policy.max_capacity = global_scope()->Lookup(
|
flowbuffer_policy.max_capacity = global_scope()->Lookup(
|
||||||
"BinPAC::flowbuffer_capacity_max")->ID_Val()->AsCount();
|
"BinPAC::flowbuffer_capacity_max")->GetVal()->AsCount();
|
||||||
flowbuffer_policy.min_capacity = global_scope()->Lookup(
|
flowbuffer_policy.min_capacity = global_scope()->Lookup(
|
||||||
"BinPAC::flowbuffer_capacity_min")->ID_Val()->AsCount();
|
"BinPAC::flowbuffer_capacity_min")->GetVal()->AsCount();
|
||||||
flowbuffer_policy.contract_threshold = global_scope()->Lookup(
|
flowbuffer_policy.contract_threshold = global_scope()->Lookup(
|
||||||
"BinPAC::flowbuffer_contract_threshold")->ID_Val()->AsCount();
|
"BinPAC::flowbuffer_contract_threshold")->GetVal()->AsCount();
|
||||||
binpac::init(&flowbuffer_policy);
|
binpac::init(&flowbuffer_policy);
|
||||||
|
|
||||||
plugin_mgr->InitBifs();
|
plugin_mgr->InitBifs();
|
||||||
|
|
16
src/zeek.bif
16
src/zeek.bif
|
@ -1926,7 +1926,7 @@ function global_sizes%(%): var_sizes
|
||||||
if ( id->HasVal() )
|
if ( id->HasVal() )
|
||||||
{
|
{
|
||||||
auto id_name = make_intrusive<StringVal>(id->Name());
|
auto id_name = make_intrusive<StringVal>(id->Name());
|
||||||
auto id_size = val_mgr->Count(id->ID_Val()->MemoryAllocation());
|
auto id_size = val_mgr->Count(id->GetVal()->MemoryAllocation());
|
||||||
sizes->Assign(id_name.get(), std::move(id_size));
|
sizes->Assign(id_name.get(), std::move(id_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1959,11 +1959,7 @@ function global_ids%(%): id_table
|
||||||
rec->Assign(5, val_mgr->Bool(id->IsRedefinable()));
|
rec->Assign(5, val_mgr->Bool(id->IsRedefinable()));
|
||||||
|
|
||||||
if ( id->HasVal() )
|
if ( id->HasVal() )
|
||||||
{
|
rec->Assign(6, id->GetVal());
|
||||||
Val* val = id->ID_Val();
|
|
||||||
Ref(val);
|
|
||||||
rec->Assign(6, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto id_name = make_intrusive<StringVal>(id->Name());
|
auto id_name = make_intrusive<StringVal>(id->Name());
|
||||||
ids->Assign(id_name.get(), std::move(rec));
|
ids->Assign(id_name.get(), std::move(rec));
|
||||||
|
@ -1984,10 +1980,10 @@ function lookup_ID%(id: string%) : any
|
||||||
if ( ! i )
|
if ( ! i )
|
||||||
return make_intrusive<StringVal>("<unknown id>");
|
return make_intrusive<StringVal>("<unknown id>");
|
||||||
|
|
||||||
if ( ! i->ID_Val() )
|
if ( ! i->GetVal() )
|
||||||
return make_intrusive<StringVal>("<no ID value>");
|
return make_intrusive<StringVal>("<no ID value>");
|
||||||
|
|
||||||
return IntrusivePtr{NewRef{}, i->ID_Val()};
|
return i->GetVal();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
## Generates metadata about a record's fields. The returned information
|
## Generates metadata about a record's fields. The returned information
|
||||||
|
@ -3908,7 +3904,7 @@ static Val* mmdb_getvalue(MMDB_entry_data_s* entry_data, int status,
|
||||||
static bool mmdb_try_open_loc ()
|
static bool mmdb_try_open_loc ()
|
||||||
{
|
{
|
||||||
// City database is always preferred over Country database.
|
// City database is always preferred over Country database.
|
||||||
auto mmdb_dir_val = global_scope()->Lookup("mmdb_dir")->ID_Val();
|
const auto& mmdb_dir_val = global_scope()->Lookup("mmdb_dir")->GetVal();
|
||||||
std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString();
|
std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString();
|
||||||
|
|
||||||
if ( ! mmdb_dir.empty() )
|
if ( ! mmdb_dir.empty() )
|
||||||
|
@ -3936,7 +3932,7 @@ static bool mmdb_try_open_loc ()
|
||||||
|
|
||||||
static bool mmdb_try_open_asn ()
|
static bool mmdb_try_open_asn ()
|
||||||
{
|
{
|
||||||
auto mmdb_dir_val = global_scope()->Lookup("mmdb_dir")->ID_Val();
|
const auto& mmdb_dir_val = global_scope()->Lookup("mmdb_dir")->GetVal();
|
||||||
std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString();
|
std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString();
|
||||||
|
|
||||||
if ( ! mmdb_dir.empty() )
|
if ( ! mmdb_dir.empty() )
|
||||||
|
|
|
@ -16,8 +16,8 @@ IdentifierInfo::IdentifierInfo(IntrusivePtr<ID> arg_id, ScriptInfo* script)
|
||||||
comments(), id(std::move(arg_id)), initial_val(), redefs(), fields(),
|
comments(), id(std::move(arg_id)), initial_val(), redefs(), fields(),
|
||||||
last_field_seen(), declaring_script(script)
|
last_field_seen(), declaring_script(script)
|
||||||
{
|
{
|
||||||
if ( id->ID_Val() && (id->IsOption() || id->IsRedefinable()) )
|
if ( id->GetVal() && (id->IsOption() || id->IsRedefinable()) )
|
||||||
initial_val = id->ID_Val()->Clone();
|
initial_val = id->GetVal()->Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifierInfo::~IdentifierInfo()
|
IdentifierInfo::~IdentifierInfo()
|
||||||
|
|
|
@ -42,8 +42,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the initial value of the identifier.
|
* Returns the initial value of the identifier.
|
||||||
*/
|
*/
|
||||||
Val* InitialVal() const
|
const IntrusivePtr<Val>& InitialVal() const
|
||||||
{ return initial_val.get(); }
|
{ return initial_val; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a comment associated with the identifier. If the identifier is a
|
* Add a comment associated with the identifier. If the identifier is a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue