mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
bifcl: Support multiple/alternate event prototype definitions
This commit is contained in:
parent
b6b094b43a
commit
e5c62c01a4
1 changed files with 28 additions and 17 deletions
|
@ -32,6 +32,11 @@ string current_module = GLOBAL_MODULE_NAME;
|
|||
int definition_type;
|
||||
string type_name;
|
||||
|
||||
// Alternate event prototypes are only written to the .zeek file, but
|
||||
// don't need any further changes to C++ source/header files, so this
|
||||
// set keeps track of whether the first event prototype information has
|
||||
// already been defined/written to the C++ files.
|
||||
static std::set<std::string> events;
|
||||
|
||||
enum {
|
||||
C_SEGMENT_DEF,
|
||||
|
@ -378,10 +383,14 @@ opt_func_attrs: attr_list opt_ws
|
|||
|
||||
event_def: event_prefix opt_ws plain_head opt_func_attrs
|
||||
{ fprintf(fp_bro_init, "%s", $4); } end_of_head ';'
|
||||
{
|
||||
if ( events.find(decl.bro_fullname) == events.end() )
|
||||
{
|
||||
print_event_c_prototype(fp_func_h, true);
|
||||
print_event_c_prototype(fp_func_def, false);
|
||||
print_event_c_body(fp_func_def);
|
||||
events.insert(decl.bro_fullname);
|
||||
}
|
||||
}
|
||||
|
||||
func_def: func_prefix opt_ws typed_head opt_func_attrs
|
||||
|
@ -555,6 +564,8 @@ head_1: TOK_ID opt_ws arg_begin
|
|||
record_bif_item(decl.bro_fullname.c_str(), "FUNCTION");
|
||||
}
|
||||
else if ( definition_type == EVENT_DEF )
|
||||
{
|
||||
if ( events.find(decl.bro_fullname) == events.end() )
|
||||
{
|
||||
// TODO: add namespace for events here
|
||||
fprintf(fp_netvar_h,
|
||||
|
@ -570,11 +581,11 @@ head_1: TOK_ID opt_ws arg_begin
|
|||
decl.c_fullname.c_str(), decl.bro_fullname.c_str());
|
||||
|
||||
record_bif_item(decl.bro_fullname.c_str(), "EVENT");
|
||||
|
||||
// C++ prototypes of bro_event_* functions will
|
||||
// be generated later.
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
arg_begin: TOK_LPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue