mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Improve auto-generated enum documentation.
The names of enum types are tracked so that variables holding a value of a given enum type can generate a reference to it instead of just listing the type as a generic "enum".
This commit is contained in:
parent
5508a5bb80
commit
9e49703087
6 changed files with 54 additions and 8 deletions
13
src/parse.y
13
src/parse.y
|
@ -131,16 +131,18 @@ const char* cur_enum_elem_id = 0;
|
|||
type_decl_list* fake_type_decl_list = 0;
|
||||
TypeDecl* last_fake_type_decl = 0;
|
||||
|
||||
static ID* cur_decl_type_id = 0;
|
||||
|
||||
static void parser_new_enum (void)
|
||||
{
|
||||
/* Starting a new enum definition. */
|
||||
assert(cur_enum_type == NULL);
|
||||
cur_enum_type = new EnumType();
|
||||
cur_enum_type = new EnumType(cur_decl_type_id->Name());
|
||||
|
||||
// For documentation purposes, a separate type object is created
|
||||
// in order to avoid overlap that can be caused by redefs.
|
||||
if ( generate_documentation )
|
||||
cur_enum_type_doc = new CommentedEnumType();
|
||||
cur_enum_type_doc = new CommentedEnumType(cur_decl_type_id->Name());
|
||||
}
|
||||
|
||||
static void parser_redef_enum (ID *id)
|
||||
|
@ -158,7 +160,7 @@ static void parser_redef_enum (ID *id)
|
|||
}
|
||||
|
||||
if ( generate_documentation )
|
||||
cur_enum_type_doc = new CommentedEnumType();
|
||||
cur_enum_type_doc = new CommentedEnumType(id->Name());
|
||||
}
|
||||
|
||||
static void add_enum_comment (std::list<std::string>* comments)
|
||||
|
@ -1098,9 +1100,10 @@ decl:
|
|||
}
|
||||
}
|
||||
|
||||
| TOK_TYPE global_id ':' type opt_attr ';'
|
||||
| TOK_TYPE global_id ':' { cur_decl_type_id = $2; } type opt_attr ';'
|
||||
{
|
||||
add_type($2, $4, $5, 0);
|
||||
cur_decl_type_id = 0;
|
||||
add_type($2, $5, $6, 0);
|
||||
|
||||
if ( generate_documentation )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue