diff --git a/NEWS b/NEWS index 32fc430fcf..b373a5c250 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,10 @@ Breaking Changes values as well as the LDAP message identifier. The value within the LDAP logs will be the most recently observed one. +- BIF methods now return a ``ValPtr`` directly instead of a ``BifReturnVal`` object + which was just a thin wrapper around ``ValPtr``. This may cause compilation errors + in C++ code that was calling BIF methods directly. + New Functionality ----------------- diff --git a/auxil/bifcl b/auxil/bifcl index cfbd7e905e..22c0317628 160000 --- a/auxil/bifcl +++ b/auxil/bifcl @@ -1 +1 @@ -Subproject commit cfbd7e905eae6d84542b7b5f761a9e67c20e50c5 +Subproject commit 22c031762832b72c2f7b4ac8bbe8102d66b09ccc diff --git a/src/BifReturnVal.cc b/src/BifReturnVal.cc deleted file mode 100644 index 0a2e3593e4..0000000000 --- a/src/BifReturnVal.cc +++ /dev/null @@ -1,11 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#include "zeek/BifReturnVal.h" - -#include "zeek/Val.h" - -namespace zeek::detail { - -BifReturnVal::BifReturnVal(std::nullptr_t) noexcept {} - -} // namespace zeek::detail diff --git a/src/BifReturnVal.h b/src/BifReturnVal.h deleted file mode 100644 index 79445b741f..0000000000 --- a/src/BifReturnVal.h +++ /dev/null @@ -1,32 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#pragma once - -#include "zeek/zeek-config.h" - -#include "zeek/IntrusivePtr.h" - -namespace zeek { - -class Val; -using ValPtr = IntrusivePtr; - -namespace detail { - -/** - * A simple wrapper class to use for the return value of BIFs so that - * they may return either a Val* or IntrusivePtr (the former could - * potentially be deprecated). - */ -class BifReturnVal { -public: - template - BifReturnVal(IntrusivePtr v) noexcept : rval(AdoptRef{}, v.release()) {} - - BifReturnVal(std::nullptr_t) noexcept; - - ValPtr rval; -}; - -} // namespace detail -} // namespace zeek diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8b1007416f..febe2d3e4e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -295,7 +295,6 @@ set(MAIN_SRCS Anon.cc Attr.cc Base64.cc - BifReturnVal.cc CCL.cc CompHash.cc Conn.cc diff --git a/src/Func.cc b/src/Func.cc index b399c80600..817f57fa6c 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -729,7 +729,7 @@ ValPtr BuiltinFunc::Invoke(Args* args, Frame* parent) const { const CallExpr* call_expr = parent ? parent->GetCall() : nullptr; call_stack.emplace_back(CallInfo{call_expr, this, *args}); - auto result = std::move(func(parent, args).rval); + auto result = func(parent, args); call_stack.pop_back(); if ( result && g_trace_state.DoTrace() ) { diff --git a/src/Func.h b/src/Func.h index 1a247123e5..fc01ba53d6 100644 --- a/src/Func.h +++ b/src/Func.h @@ -9,7 +9,6 @@ #include #include -#include "zeek/BifReturnVal.h" #include "zeek/Obj.h" #include "zeek/Scope.h" #include "zeek/Stmt.h" @@ -314,7 +313,7 @@ private: int current_priority = 0; }; -using built_in_func = BifReturnVal (*)(Frame* frame, const Args* args); +using built_in_func = ValPtr (*)(Frame* frame, const Args* args); class BuiltinFunc final : public Func { public: diff --git a/src/Hash.h b/src/Hash.h index 3ef55b20ac..aaee8d3df3 100644 --- a/src/Hash.h +++ b/src/Hash.h @@ -37,12 +37,11 @@ class ODesc; namespace zeek::detail { class Frame; -class BifReturnVal; } // namespace zeek::detail namespace zeek::BifFunc { -extern zeek::detail::BifReturnVal md5_hmac_bif(zeek::detail::Frame* frame, const zeek::Args*); +zeek::ValPtr md5_hmac_bif(zeek::detail::Frame* frame, const zeek::Args*); } namespace zeek::detail { @@ -211,7 +210,7 @@ private: inline static bool seeds_initialized = false; friend void util::detail::hmac_md5(size_t size, const unsigned char* bytes, unsigned char digest[16]); - friend BifReturnVal BifFunc::md5_hmac_bif(zeek::detail::Frame* frame, const Args*); + friend ValPtr BifFunc::md5_hmac_bif(zeek::detail::Frame* frame, const Args*); }; enum HashKeyTag { HASH_KEY_INT, HASH_KEY_DOUBLE, HASH_KEY_STRING }; diff --git a/src/zeek-bif.h b/src/zeek-bif.h index 392b4f754f..3e7a53da9e 100644 --- a/src/zeek-bif.h +++ b/src/zeek-bif.h @@ -1,7 +1,6 @@ #pragma once // Headers to include by generated BiF code. -#include "zeek/BifReturnVal.h" #include "zeek/Conn.h" #include "zeek/Event.h" #include "zeek/EventRegistry.h" diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 54da694fa1..cb1b019c74 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -747,7 +747,7 @@ SetupResult setup(int argc, char** argv, Options* zopts) { auto ipbft = make_intrusive(make_intrusive(nullptr), base_type(TYPE_BOOL), FUNC_FLAVOR_FUNCTION); ipbid->SetType(std::move(ipbft)); - auto init_bifs = [](Frame* frame, const Args* args) -> BifReturnVal { + auto init_bifs = [](Frame* frame, const Args* args) -> ValPtr { init_primary_bifs(); return val_mgr->True(); }; diff --git a/src/zeek.bif b/src/zeek.bif index 770524ebda..8086ffed48 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -1461,7 +1461,7 @@ function sort%(v: any, ...%) : any auto vv = v->As(); vv->Sort(comp); - return std::move(rval); + return rval; %} ## Returns the order of the elements in a vector according to some @@ -2721,7 +2721,7 @@ function to_addr%(ip: string%): addr } delete [] s; - return std::move(ret); + return ret; %} ## Checks if a string is a valid IPv4 or IPv6 address.