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;
|
int definition_type;
|
||||||
string type_name;
|
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 {
|
enum {
|
||||||
C_SEGMENT_DEF,
|
C_SEGMENT_DEF,
|
||||||
|
@ -379,9 +384,13 @@ opt_func_attrs: attr_list opt_ws
|
||||||
event_def: event_prefix opt_ws plain_head opt_func_attrs
|
event_def: event_prefix opt_ws plain_head opt_func_attrs
|
||||||
{ fprintf(fp_bro_init, "%s", $4); } end_of_head ';'
|
{ fprintf(fp_bro_init, "%s", $4); } end_of_head ';'
|
||||||
{
|
{
|
||||||
print_event_c_prototype(fp_func_h, true);
|
if ( events.find(decl.bro_fullname) == events.end() )
|
||||||
print_event_c_prototype(fp_func_def, false);
|
{
|
||||||
print_event_c_body(fp_func_def);
|
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
|
func_def: func_prefix opt_ws typed_head opt_func_attrs
|
||||||
|
@ -556,23 +565,25 @@ head_1: TOK_ID opt_ws arg_begin
|
||||||
}
|
}
|
||||||
else if ( definition_type == EVENT_DEF )
|
else if ( definition_type == EVENT_DEF )
|
||||||
{
|
{
|
||||||
// TODO: add namespace for events here
|
if ( events.find(decl.bro_fullname) == events.end() )
|
||||||
fprintf(fp_netvar_h,
|
{
|
||||||
"%sextern EventHandlerPtr %s; %s\n",
|
// TODO: add namespace for events here
|
||||||
decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
|
fprintf(fp_netvar_h,
|
||||||
|
"%sextern EventHandlerPtr %s; %s\n",
|
||||||
|
decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
|
||||||
|
|
||||||
fprintf(fp_netvar_def,
|
fprintf(fp_netvar_def,
|
||||||
"%sEventHandlerPtr %s; %s\n",
|
"%sEventHandlerPtr %s; %s\n",
|
||||||
decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
|
decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
|
||||||
|
|
||||||
fprintf(fp_netvar_init,
|
fprintf(fp_netvar_init,
|
||||||
"\t%s = internal_handler(\"%s\");\n",
|
"\t%s = internal_handler(\"%s\");\n",
|
||||||
decl.c_fullname.c_str(), decl.bro_fullname.c_str());
|
decl.c_fullname.c_str(), decl.bro_fullname.c_str());
|
||||||
|
|
||||||
record_bif_item(decl.bro_fullname.c_str(), "EVENT");
|
record_bif_item(decl.bro_fullname.c_str(), "EVENT");
|
||||||
|
// C++ prototypes of bro_event_* functions will
|
||||||
// C++ prototypes of bro_event_* functions will
|
// be generated later.
|
||||||
// be generated later.
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue