mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 11:08:20 +00:00
support "any" coercions for "-O gen-C++"
This commit is contained in:
parent
7a96d2fa61
commit
47783cb9fd
3 changed files with 43 additions and 0 deletions
|
@ -75,6 +75,25 @@ ValPtr cast_value_to_type__CPP(const ValPtr& v, const TypePtr& t)
|
|||
return result;
|
||||
}
|
||||
|
||||
ValPtr from_any__CPP(const ValPtr& v, const TypePtr& t)
|
||||
{
|
||||
auto vt = v->GetType()->Tag();
|
||||
|
||||
if ( vt != t->Tag() && vt != TYPE_ERROR )
|
||||
reporter->CPPRuntimeError("incompatible \"any\" type (%s vs. %s)",
|
||||
type_name(vt), type_name(t->Tag()));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
ValPtr from_any_vec__CPP(const ValPtr& v, const TypePtr& t)
|
||||
{
|
||||
if ( ! v->AsVectorVal()->Concretize(t) )
|
||||
reporter->CPPRuntimeError("incompatible \"vector of any\" type");
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
SubNetValPtr addr_mask__CPP(const IPAddr& a, uint32_t mask)
|
||||
{
|
||||
if ( a.GetFamily() == IPv4 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue