Support unserializing broker data into type 'any'

The receiver side will wrap the data as a Broker::Data value, which
can then be type-checked/cast via 'is' or 'as' operators to a specific
Bro type.  For example:

Sender:

    Broker::publish("topic", my_event, "hello")

Receiver:

    event my_event(arg: any)
        {
        if ( arg is string )
            print arg as string;
        }
This commit is contained in:
Jon Siwek 2018-05-31 10:39:40 -05:00
parent bd3c16c6d7
commit d873acc9e3
4 changed files with 133 additions and 0 deletions

View file

@ -772,6 +772,9 @@ struct type_checker {
Val* bro_broker::data_to_val(broker::data d, BroType* type)
{
if ( type->Tag() == TYPE_ANY )
return bro_broker::make_data_val(move(d));
return broker::visit(val_converter{type}, std::move(d));
}