mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Val: use C++ initializers
This commit is contained in:
parent
4a5473c572
commit
59b5e6b7dc
2 changed files with 14 additions and 41 deletions
19
src/Val.cc
19
src/Val.cc
|
@ -38,28 +38,23 @@
|
||||||
#include "threading/formatters/JSON.h"
|
#include "threading/formatters/JSON.h"
|
||||||
|
|
||||||
Val::Val(Func* f)
|
Val::Val(Func* f)
|
||||||
:val(f)
|
:val(f), type(f->FType()->Ref())
|
||||||
{
|
{
|
||||||
::Ref(val.func_val);
|
::Ref(val.func_val);
|
||||||
type = f->FType()->Ref();
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Val::Val(BroFile* f)
|
static FileType *GetStringFileType() noexcept
|
||||||
:val(f)
|
|
||||||
{
|
{
|
||||||
static FileType* string_file_type = 0;
|
static FileType* string_file_type = 0;
|
||||||
if ( ! string_file_type )
|
if ( ! string_file_type )
|
||||||
string_file_type = new FileType(base_type(TYPE_STRING));
|
string_file_type = new FileType(base_type(TYPE_STRING));
|
||||||
|
return string_file_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
Val::Val(BroFile* f)
|
||||||
|
:val(f), type(GetStringFileType()->Ref())
|
||||||
|
{
|
||||||
assert(f->FType()->Tag() == TYPE_STRING);
|
assert(f->FType()->Tag() == TYPE_STRING);
|
||||||
type = string_file_type->Ref();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Val::~Val()
|
Val::~Val()
|
||||||
|
|
36
src/Val.h
36
src/Val.h
|
@ -128,12 +128,8 @@ union BroValUnion {
|
||||||
class Val : public BroObj {
|
class Val : public BroObj {
|
||||||
public:
|
public:
|
||||||
Val(double d, TypeTag t)
|
Val(double d, TypeTag t)
|
||||||
:val(d)
|
:val(d), type(base_type(t))
|
||||||
{
|
{
|
||||||
type = base_type(t);
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit Val(Func* f);
|
explicit Val(Func* f);
|
||||||
|
@ -143,20 +139,13 @@ public:
|
||||||
explicit Val(BroFile* f);
|
explicit Val(BroFile* f);
|
||||||
|
|
||||||
Val(BroType* t, bool type_type) // Extra arg to differentiate from protected version.
|
Val(BroType* t, bool type_type) // Extra arg to differentiate from protected version.
|
||||||
|
:type(new TypeType(t->Ref()))
|
||||||
{
|
{
|
||||||
type = new TypeType(t->Ref());
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Val()
|
Val()
|
||||||
:val(bro_int_t(0))
|
:val(bro_int_t(0)), type(base_type(TYPE_ERROR))
|
||||||
{
|
{
|
||||||
type = base_type(TYPE_ERROR);
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Val() override;
|
~Val() override;
|
||||||
|
@ -364,30 +353,19 @@ protected:
|
||||||
|
|
||||||
template<typename V>
|
template<typename V>
|
||||||
Val(V &&v, TypeTag t) noexcept
|
Val(V &&v, TypeTag t) noexcept
|
||||||
:val(std::forward<V>(v))
|
:val(std::forward<V>(v)), type(base_type(t))
|
||||||
{
|
{
|
||||||
type = base_type(t);
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename V>
|
template<typename V>
|
||||||
Val(V &&v, BroType* t) noexcept
|
Val(V &&v, BroType* t) noexcept
|
||||||
:val(std::forward<V>(v))
|
:val(std::forward<V>(v)), type(t->Ref())
|
||||||
{
|
{
|
||||||
type = t->Ref();
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit Val(BroType* t)
|
explicit Val(BroType* t)
|
||||||
|
:type(t->Ref())
|
||||||
{
|
{
|
||||||
type = t->Ref();
|
|
||||||
#ifdef DEBUG
|
|
||||||
bound_id = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ACCESSOR(TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsNonConstTable)
|
ACCESSOR(TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsNonConstTable)
|
||||||
|
@ -415,7 +393,7 @@ protected:
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// For debugging, we keep the name of the ID to which a Val is bound.
|
// For debugging, we keep the name of the ID to which a Val is bound.
|
||||||
const char* bound_id;
|
const char* bound_id = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue