mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 21:18:20 +00:00
Merge remote-tracking branch 'origin/topic/vern/cpp-record-constructor'
* origin/topic/vern/cpp-record-constructor: update script-to-C++ compilation for new record constructor internals
This commit is contained in:
commit
79326ba62c
5 changed files with 44 additions and 3 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
4.2.0-dev.436 | 2021-12-10 13:11:36 -0700
|
||||||
|
|
||||||
|
* update script-to-C++ compilation for new record constructor internals (Vern Paxson, Corelight)
|
||||||
|
|
||||||
4.2.0-dev.434 | 2021-12-10 13:11:10 -0700
|
4.2.0-dev.434 | 2021-12-10 13:11:10 -0700
|
||||||
|
|
||||||
* updates to ZAM to track recent changes in script semantics (Vern Paxson, Corelight)
|
* updates to ZAM to track recent changes in script semantics (Vern Paxson, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.2.0-dev.434
|
4.2.0-dev.436
|
||||||
|
|
|
@ -670,8 +670,30 @@ string CPPCompile::GenRecordConstructorExpr(const Expr* e)
|
||||||
vals += ", ";
|
vals += ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return string("record_constructor__CPP({") + vals + "}, " + "cast_intrusive<RecordType>(" +
|
vals = string("{") + vals + "}";
|
||||||
GenTypeName(t) + "))";
|
|
||||||
|
const auto& map = rc->Map();
|
||||||
|
|
||||||
|
if ( map )
|
||||||
|
{
|
||||||
|
string map_vals;
|
||||||
|
for ( auto m : *map )
|
||||||
|
{
|
||||||
|
if ( ! map_vals.empty() )
|
||||||
|
map_vals += ", ";
|
||||||
|
|
||||||
|
map_vals += to_string(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
map_vals = string("{") + map_vals + "}";
|
||||||
|
|
||||||
|
return string("record_constructor_map__CPP(") + vals + ", " + map_vals +
|
||||||
|
", cast_intrusive<RecordType>(" + GenTypeName(t) + "))";
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return string("record_constructor__CPP(") + vals + ", cast_intrusive<RecordType>(" +
|
||||||
|
GenTypeName(t) + "))";
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::GenSetConstructorExpr(const Expr* e)
|
string CPPCompile::GenSetConstructorExpr(const Expr* e)
|
||||||
|
|
|
@ -224,6 +224,17 @@ RecordValPtr record_constructor__CPP(vector<ValPtr> vals, RecordTypePtr t)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecordValPtr record_constructor_map__CPP(vector<ValPtr> vals, vector<int> map, RecordTypePtr t)
|
||||||
|
{
|
||||||
|
auto rv = make_intrusive<RecordVal>(move(t));
|
||||||
|
auto n = vals.size();
|
||||||
|
|
||||||
|
for ( auto i = 0u; i < n; ++i )
|
||||||
|
rv->Assign(map[i], vals[i]);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
VectorValPtr vector_constructor__CPP(vector<ValPtr> vals, VectorTypePtr t)
|
VectorValPtr vector_constructor__CPP(vector<ValPtr> vals, VectorTypePtr t)
|
||||||
{
|
{
|
||||||
auto vv = make_intrusive<VectorVal>(move(t));
|
auto vv = make_intrusive<VectorVal>(move(t));
|
||||||
|
|
|
@ -140,6 +140,10 @@ extern TableValPtr table_constructor__CPP(std::vector<ValPtr> indices, std::vect
|
||||||
// assigned to the corresponding elements of the given vector of values.
|
// assigned to the corresponding elements of the given vector of values.
|
||||||
extern RecordValPtr record_constructor__CPP(std::vector<ValPtr> vals, RecordTypePtr t);
|
extern RecordValPtr record_constructor__CPP(std::vector<ValPtr> vals, RecordTypePtr t);
|
||||||
|
|
||||||
|
// Same, but with a map when using a named constructor.
|
||||||
|
extern RecordValPtr record_constructor_map__CPP(std::vector<ValPtr> vals, std::vector<int> map,
|
||||||
|
RecordTypePtr t);
|
||||||
|
|
||||||
// Constructs a vector of the given type, populated with the given values.
|
// Constructs a vector of the given type, populated with the given values.
|
||||||
extern VectorValPtr vector_constructor__CPP(std::vector<ValPtr> vals, VectorTypePtr t);
|
extern VectorValPtr vector_constructor__CPP(std::vector<ValPtr> vals, VectorTypePtr t);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue