mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 05:28:20 +00:00
Merge remote-tracking branch 'origin/topic/matthias/opaque'
* origin/topic/matthias/opaque: Add new unit test for opaque serialization. Migrate entropy testing to opaque. C++ify RandTest.* Fix a hard-to-spot bug. Use more descriptive error message. Fix the fix :-/. Fix initialization of hash values. Be clearer about delegation. Implement serialization of opaque types. Update hash BiF documentation. Migrate free SHA* functions to SHA*Val::digest(). Add missing type name that caused failing tests. Update base scripts and unit tests. Simplify hash function BiFs. Add support for opaque hash values. Adapt BiF & Bro parser to handle opaque types. More lexer/parser work. Implement equivalence relation for opaque types. Support basic serialization of opaque. Add opaque type to lexer, parser, and BroType. Closes #925 Conflicts: aux/broccoli
This commit is contained in:
commit
da90976170
27 changed files with 1072 additions and 428 deletions
45
src/Type.cc
45
src/Type.cc
|
@ -30,6 +30,7 @@ const char* type_name(TypeTag t)
|
|||
"table", "union", "record", "types",
|
||||
"func",
|
||||
"file",
|
||||
"opaque",
|
||||
"vector",
|
||||
"type",
|
||||
"error",
|
||||
|
@ -96,6 +97,7 @@ BroType::BroType(TypeTag t, bool arg_base_type)
|
|||
case TYPE_LIST:
|
||||
case TYPE_FUNC:
|
||||
case TYPE_FILE:
|
||||
case TYPE_OPAQUE:
|
||||
case TYPE_VECTOR:
|
||||
case TYPE_TYPE:
|
||||
internal_tag = TYPE_INTERNAL_OTHER;
|
||||
|
@ -1262,6 +1264,41 @@ bool FileType::DoUnserialize(UnserialInfo* info)
|
|||
return yield != 0;
|
||||
}
|
||||
|
||||
OpaqueType::OpaqueType(const string& arg_name) : BroType(TYPE_OPAQUE)
|
||||
{
|
||||
name = arg_name;
|
||||
}
|
||||
|
||||
void OpaqueType::Describe(ODesc* d) const
|
||||
{
|
||||
if ( d->IsReadable() )
|
||||
d->AddSP("opaque of");
|
||||
else
|
||||
d->Add(int(Tag()));
|
||||
|
||||
d->Add(name.c_str());
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(OpaqueType, SER_OPAQUE_TYPE);
|
||||
|
||||
bool OpaqueType::DoSerialize(SerialInfo* info) const
|
||||
{
|
||||
DO_SERIALIZE(SER_OPAQUE_TYPE, BroType);
|
||||
return SERIALIZE(name);
|
||||
}
|
||||
|
||||
bool OpaqueType::DoUnserialize(UnserialInfo* info)
|
||||
{
|
||||
DO_UNSERIALIZE(BroType);
|
||||
|
||||
char const* n;
|
||||
if ( ! UNSERIALIZE_STR(&n, 0) )
|
||||
return false;
|
||||
|
||||
name = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
EnumType::EnumType(const string& arg_name)
|
||||
: BroType(TYPE_ENUM)
|
||||
{
|
||||
|
@ -1716,6 +1753,13 @@ int same_type(const BroType* t1, const BroType* t2, int is_init)
|
|||
case TYPE_FILE:
|
||||
return same_type(t1->YieldType(), t2->YieldType(), is_init);
|
||||
|
||||
case TYPE_OPAQUE:
|
||||
{
|
||||
const OpaqueType* ot1 = (const OpaqueType*) t1;
|
||||
const OpaqueType* ot2 = (const OpaqueType*) t2;
|
||||
return ot1->Name() == ot2->Name() ? 1 : 0;
|
||||
}
|
||||
|
||||
case TYPE_TYPE:
|
||||
return same_type(t1, t2, is_init);
|
||||
|
||||
|
@ -1805,6 +1849,7 @@ int is_assignable(BroType* t)
|
|||
|
||||
case TYPE_VECTOR:
|
||||
case TYPE_FILE:
|
||||
case TYPE_OPAQUE:
|
||||
case TYPE_TABLE:
|
||||
case TYPE_TYPE:
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue