mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
simplifications to the Frame class now that it no longer has to support old-style captures
This commit is contained in:
parent
82588ca311
commit
6ac348d77d
2 changed files with 9 additions and 32 deletions
19
src/Frame.cc
19
src/Frame.cc
|
@ -139,11 +139,8 @@ static bool val_is_func(const ValPtr& v, ScriptFunc* func)
|
|||
return v->AsFunc() == func;
|
||||
}
|
||||
|
||||
broker::expected<broker::data> Frame::SerializeCopyFrame()
|
||||
broker::expected<broker::data> Frame::Serialize()
|
||||
{
|
||||
broker::vector rval;
|
||||
rval.emplace_back(std::string("CopyFrame"));
|
||||
|
||||
broker::vector body;
|
||||
|
||||
for ( int i = 0; i < size; ++i )
|
||||
|
@ -158,28 +155,18 @@ broker::expected<broker::data> Frame::SerializeCopyFrame()
|
|||
body.emplace_back(std::move(val_tuple));
|
||||
}
|
||||
|
||||
broker::vector rval;
|
||||
rval.emplace_back(std::move(body));
|
||||
|
||||
return {std::move(rval)};
|
||||
}
|
||||
|
||||
std::pair<bool, FramePtr> Frame::Unserialize(const broker::vector& data,
|
||||
const std::optional<FuncType::CaptureList>& captures)
|
||||
std::pair<bool, FramePtr> Frame::Unserialize(const broker::vector& data)
|
||||
{
|
||||
if ( data.size() == 0 )
|
||||
return std::make_pair(true, nullptr);
|
||||
|
||||
auto where = data.begin();
|
||||
|
||||
auto has_name = broker::get_if<std::string>(*where);
|
||||
if ( ! has_name )
|
||||
return std::make_pair(false, nullptr);
|
||||
|
||||
std::advance(where, 1);
|
||||
|
||||
if ( captures )
|
||||
ASSERT(*has_name == "CopyFrame");
|
||||
|
||||
auto has_body = broker::get_if<broker::vector>(*where);
|
||||
if ( ! has_body )
|
||||
return std::make_pair(false, nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue