From 6ac348d77de7934f88a0887ac460a5b975297170 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Fri, 16 Jun 2023 15:39:58 -0700 Subject: [PATCH] simplifications to the Frame class now that it no longer has to support old-style captures --- src/Frame.cc | 19 +++---------------- src/Frame.h | 22 ++++++---------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/Frame.cc b/src/Frame.cc index 642440d2c2..6d60a34401 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -139,11 +139,8 @@ static bool val_is_func(const ValPtr& v, ScriptFunc* func) return v->AsFunc() == func; } -broker::expected Frame::SerializeCopyFrame() +broker::expected 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 Frame::SerializeCopyFrame() body.emplace_back(std::move(val_tuple)); } + broker::vector rval; rval.emplace_back(std::move(body)); return {std::move(rval)}; } -std::pair Frame::Unserialize(const broker::vector& data, - const std::optional& captures) +std::pair 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(*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(*where); if ( ! has_body ) return std::make_pair(false, nullptr); diff --git a/src/Frame.h b/src/Frame.h index a0fc5146d5..8b169b42df 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -172,16 +172,11 @@ public: Frame* CloneForTrigger() const; /** - * Serializes the frame in support of copy semantics for lambdas: - * - * [ "CopyFrame", serialized_values ] - * - * where serialized_values are two-element vectors. A serialized_value - * has the result of calling broker::data_to_val on the value in the - * first index, and an integer representing that value's type in the - * second index. + * Serializes the frame (only done for lambda/when captures) as a + * sequence of two-element vectors, the first element reflecting + * the frame value, the second its type. */ - broker::expected SerializeCopyFrame(); + broker::expected Serialize(); /** * Instantiates a Frame from a serialized one. @@ -189,13 +184,8 @@ public: * @return a pair in which the first item is the status of the serialization; * and the second is the unserialized frame with reference count +1, or * null if the serialization wasn't successful. - * - * The *captures* argument, if non-nil, specifies that the frame - * reflects captures with copy-semantics rather than deprecated - * reference semantics. */ - static std::pair - Unserialize(const broker::vector& data, const std::optional& captures); + static std::pair Unserialize(const broker::vector& data); // If the frame is run in the context of a trigger condition evaluation, // the trigger needs to be registered. @@ -246,7 +236,7 @@ private: */ int current_offset; - /** Frame used for captures (if any) with copy semantics. */ + /** Frame used for lambda/when captures. */ Frame* captures; /** Maps IDs to offsets into the "captures" frame. If the ID