mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Change BIFs to return a wrapper object
That allows returning either Val* or IntrusivePtr<T>. The former could eventually be deprecated, but it's used extensively at the moment.
This commit is contained in:
parent
8843f69002
commit
eb77411dbf
3 changed files with 29 additions and 3 deletions
24
src/Func.h
24
src/Func.h
|
@ -188,7 +188,29 @@ private:
|
|||
bool weak_closure_ref = false;
|
||||
};
|
||||
|
||||
using built_in_func = Val* (*)(Frame* frame, const zeek::Args* args);
|
||||
/**
|
||||
* A simple wrapper class to use for the return value of BIFs so that
|
||||
* they may return either a Val* or IntrusivePtr<Val> (the former could
|
||||
* potentially be deprecated).
|
||||
*/
|
||||
class BifReturnVal {
|
||||
public:
|
||||
|
||||
template <typename T>
|
||||
BifReturnVal(IntrusivePtr<T> v) noexcept
|
||||
: rval(AdoptRef{}, v.release())
|
||||
{ }
|
||||
|
||||
BifReturnVal(Val* v) noexcept;
|
||||
|
||||
private:
|
||||
|
||||
friend class BuiltinFunc;
|
||||
|
||||
IntrusivePtr<Val> rval;
|
||||
};
|
||||
|
||||
using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args);
|
||||
|
||||
class BuiltinFunc final : public Func {
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue