mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Switch FuncType capture-list storage to optional<vector<Capture>>
May help clarify overall mem-mgmt/ownership semantics.
This commit is contained in:
parent
ab15a98b28
commit
b08112b2e7
8 changed files with 44 additions and 41 deletions
10
src/Type.h
10
src/Type.h
|
@ -492,8 +492,6 @@ public:
|
|||
|
||||
TypePtr ShallowClone() override;
|
||||
|
||||
~FuncType() override;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use Params().")]]
|
||||
RecordType* Args() const { return args.get(); }
|
||||
|
||||
|
@ -549,19 +547,21 @@ public:
|
|||
bool deep_copy;
|
||||
};
|
||||
|
||||
using CaptureList = std::vector<Capture>;
|
||||
|
||||
/**
|
||||
* Sets this function's set of captures. Only valid for lambdas.
|
||||
*
|
||||
* @param captures if non-nil, a list of the lambda's captures
|
||||
*/
|
||||
void SetCaptures(std::vector<Capture*>* captures);
|
||||
void SetCaptures(std::optional<CaptureList> captures);
|
||||
|
||||
/**
|
||||
* Returns the captures declared for this function, or nil if none.
|
||||
*
|
||||
* @return a vector giving the captures
|
||||
*/
|
||||
const std::vector<Capture*>* GetCaptures() const
|
||||
const std::optional<CaptureList>& GetCaptures() const
|
||||
{ return captures; }
|
||||
|
||||
protected:
|
||||
|
@ -574,7 +574,7 @@ protected:
|
|||
FunctionFlavor flavor;
|
||||
std::vector<Prototype> prototypes;
|
||||
|
||||
std::vector<Capture*>* captures; // if nil then no captures specified
|
||||
std::optional<CaptureList> captures; // if nil then no captures specified
|
||||
};
|
||||
|
||||
class TypeType final : public Type {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue