mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Type: use class IntrusivePtr in FileType
This commit is contained in:
parent
43af5f8349
commit
7704d52d28
4 changed files with 11 additions and 17 deletions
14
src/Type.cc
14
src/Type.cc
|
@ -1004,20 +1004,16 @@ void SubNetType::Describe(ODesc* d) const
|
||||||
d->Add(int(Tag()));
|
d->Add(int(Tag()));
|
||||||
}
|
}
|
||||||
|
|
||||||
FileType::FileType(BroType* yield_type)
|
FileType::FileType(IntrusivePtr<BroType> yield_type)
|
||||||
: BroType(TYPE_FILE)
|
: BroType(TYPE_FILE), yield(std::move(yield_type))
|
||||||
{
|
{
|
||||||
yield = yield_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileType::~FileType()
|
FileType::~FileType() = default;
|
||||||
{
|
|
||||||
Unref(yield);
|
|
||||||
}
|
|
||||||
|
|
||||||
BroType* FileType::YieldType()
|
BroType* FileType::YieldType()
|
||||||
{
|
{
|
||||||
return yield;
|
return yield.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileType::Describe(ODesc* d) const
|
void FileType::Describe(ODesc* d) const
|
||||||
|
@ -1949,7 +1945,7 @@ BroType* merge_types(const BroType* t1, const BroType* t2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FileType(merge_types(t1->YieldType(), t2->YieldType()));
|
return new FileType({AdoptRef{}, merge_types(t1->YieldType(), t2->YieldType())});
|
||||||
|
|
||||||
case TYPE_UNION:
|
case TYPE_UNION:
|
||||||
reporter->InternalError("union type in merge_types()");
|
reporter->InternalError("union type in merge_types()");
|
||||||
|
|
|
@ -567,8 +567,8 @@ public:
|
||||||
|
|
||||||
class FileType : public BroType {
|
class FileType : public BroType {
|
||||||
public:
|
public:
|
||||||
explicit FileType(BroType* yield_type);
|
explicit FileType(IntrusivePtr<BroType> yield_type);
|
||||||
FileType* ShallowClone() override { return new FileType(yield->Ref()); }
|
FileType* ShallowClone() override { return new FileType(yield); }
|
||||||
~FileType() override;
|
~FileType() override;
|
||||||
|
|
||||||
BroType* YieldType() override;
|
BroType* YieldType() override;
|
||||||
|
@ -576,9 +576,7 @@ public:
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileType() { yield = 0; }
|
IntrusivePtr<BroType> yield;
|
||||||
|
|
||||||
BroType* yield;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpaqueType : public BroType {
|
class OpaqueType : public BroType {
|
||||||
|
|
|
@ -49,7 +49,7 @@ static FileType* GetStringFileType() noexcept
|
||||||
{
|
{
|
||||||
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({AdoptRef{}, base_type(TYPE_STRING)});
|
||||||
return string_file_type;
|
return string_file_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -991,13 +991,13 @@ type:
|
||||||
| TOK_FILE TOK_OF type
|
| TOK_FILE TOK_OF type
|
||||||
{
|
{
|
||||||
set_location(@1, @3);
|
set_location(@1, @3);
|
||||||
$$ = new FileType($3);
|
$$ = new FileType({AdoptRef{}, $3});
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_FILE
|
| TOK_FILE
|
||||||
{
|
{
|
||||||
set_location(@1);
|
set_location(@1);
|
||||||
$$ = new FileType(base_type(TYPE_STRING));
|
$$ = new FileType({AdoptRef{}, base_type(TYPE_STRING)});
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_OPAQUE TOK_OF TOK_ID
|
| TOK_OPAQUE TOK_OF TOK_ID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue