mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +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()));
|
||||
}
|
||||
|
||||
FileType::FileType(BroType* yield_type)
|
||||
: BroType(TYPE_FILE)
|
||||
FileType::FileType(IntrusivePtr<BroType> yield_type)
|
||||
: BroType(TYPE_FILE), yield(std::move(yield_type))
|
||||
{
|
||||
yield = yield_type;
|
||||
}
|
||||
|
||||
FileType::~FileType()
|
||||
{
|
||||
Unref(yield);
|
||||
}
|
||||
FileType::~FileType() = default;
|
||||
|
||||
BroType* FileType::YieldType()
|
||||
{
|
||||
return yield;
|
||||
return yield.get();
|
||||
}
|
||||
|
||||
void FileType::Describe(ODesc* d) const
|
||||
|
@ -1949,7 +1945,7 @@ BroType* merge_types(const BroType* t1, const BroType* t2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return new FileType(merge_types(t1->YieldType(), t2->YieldType()));
|
||||
return new FileType({AdoptRef{}, merge_types(t1->YieldType(), t2->YieldType())});
|
||||
|
||||
case TYPE_UNION:
|
||||
reporter->InternalError("union type in merge_types()");
|
||||
|
|
|
@ -567,8 +567,8 @@ public:
|
|||
|
||||
class FileType : public BroType {
|
||||
public:
|
||||
explicit FileType(BroType* yield_type);
|
||||
FileType* ShallowClone() override { return new FileType(yield->Ref()); }
|
||||
explicit FileType(IntrusivePtr<BroType> yield_type);
|
||||
FileType* ShallowClone() override { return new FileType(yield); }
|
||||
~FileType() override;
|
||||
|
||||
BroType* YieldType() override;
|
||||
|
@ -576,9 +576,7 @@ public:
|
|||
void Describe(ODesc* d) const override;
|
||||
|
||||
protected:
|
||||
FileType() { yield = 0; }
|
||||
|
||||
BroType* yield;
|
||||
IntrusivePtr<BroType> yield;
|
||||
};
|
||||
|
||||
class OpaqueType : public BroType {
|
||||
|
|
|
@ -49,7 +49,7 @@ static FileType* GetStringFileType() noexcept
|
|||
{
|
||||
static FileType* string_file_type = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -991,13 +991,13 @@ type:
|
|||
| TOK_FILE TOK_OF type
|
||||
{
|
||||
set_location(@1, @3);
|
||||
$$ = new FileType($3);
|
||||
$$ = new FileType({AdoptRef{}, $3});
|
||||
}
|
||||
|
||||
| TOK_FILE
|
||||
{
|
||||
set_location(@1);
|
||||
$$ = new FileType(base_type(TYPE_STRING));
|
||||
$$ = new FileType({AdoptRef{}, base_type(TYPE_STRING)});
|
||||
}
|
||||
|
||||
| TOK_OPAQUE TOK_OF TOK_ID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue