Merge remote-tracking branch 'origin/topic/timw/restore-settype-methods'
Some checks are pending
pre-commit / pre-commit (push) Waiting to run

* origin/topic/timw/restore-settype-methods:
  Restore the SetType constructor and destructor
This commit is contained in:
Tim Wojtulewicz 2025-09-22 07:45:57 -07:00
commit 416d997263
3 changed files with 49 additions and 1 deletions

View file

@ -1,3 +1,7 @@
8.1.0-dev.565 | 2025-09-22 07:45:57 -0700
* Restore the SetType constructor and destructor (Tim Wojtulewicz, Corelight)
8.1.0-dev.563 | 2025-09-22 07:33:42 -0700 8.1.0-dev.563 | 2025-09-22 07:33:42 -0700
* Bump libkqueue to latest upstream master (Tim Wojtulewicz, Corelight) * Bump libkqueue to latest upstream master (Tim Wojtulewicz, Corelight)

View file

@ -1 +1 @@
8.1.0-dev.563 8.1.0-dev.565

View file

@ -569,6 +569,50 @@ bool TableType::DoExpireCheck(const detail::AttrPtr& attr) {
return true; return true;
} }
SetType::SetType(TypeListPtr ind, detail::ListExprPtr arg_elements)
: TableType(std::move(ind), nullptr), elements(std::move(arg_elements)) {
if ( elements ) {
if ( indices ) { // We already have a type.
if ( ! check_and_promote_exprs(elements.get(), indices) )
SetError();
}
else {
TypeList* tl_type = elements->GetType()->AsTypeList();
const auto& tl = tl_type->GetTypes();
if ( tl.size() < 1 ) {
Error("no type given for set");
SetError();
}
else if ( tl.size() == 1 ) {
TypePtr ft{NewRef{}, flatten_type(tl[0].get())};
indices = make_intrusive<TypeList>(ft);
indices->Append(std::move(ft));
}
else {
auto t = merge_types(tl[0], tl[1]);
for ( size_t i = 2; t && i < tl.size(); ++i )
t = merge_types(t, tl[i]);
if ( ! t ) {
Error("bad set type");
return;
}
indices = make_intrusive<TypeList>(t);
indices->Append(std::move(t));
}
}
}
}
TypePtr SetType::ShallowClone() { return make_intrusive<SetType>(indices, elements); }
SetType::~SetType() = default;
FuncType::Capture::Capture(detail::IDPtr _id, bool _deep_copy) : id(std::move(_id)), deep_copy(_deep_copy) { FuncType::Capture::Capture(detail::IDPtr _id, bool _deep_copy) : id(std::move(_id)), deep_copy(_deep_copy) {
is_managed = id ? ZVal::IsManagedType(id->GetType()) : false; is_managed = id ? ZVal::IsManagedType(id->GetType()) : false;
if ( ! is_managed ) if ( ! is_managed )