mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote branch 'origin/fastpath'
* origin/fastpath: Fix reST markup generated for record redefs. Fixes for more doc mode corner cases caused by type cloning. Jon, I added the line below, please double-check. diff --git a/src/Var.cc b/src/Var.cc index 7880325..00ac734 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -260,6 +260,7 @@ void add_type(ID* id, BroType* t, attr_list* attr, int /* is_event */) tnew = new FuncType(t->AsFuncType()->Args(), t->AsFuncType()->YieldType(), t->AsFuncType()->IsEvent()); + break; default: SerializationFormat* form = new BinarySerializationFormat(); form->StartWrite();
This commit is contained in:
commit
b829c269ff
5 changed files with 35 additions and 117 deletions
27
src/Var.cc
27
src/Var.cc
|
@ -242,15 +242,26 @@ void add_type(ID* id, BroType* t, attr_list* attr, int /* is_event */)
|
|||
// t->GetTypeID() is true.
|
||||
if ( generate_documentation )
|
||||
{
|
||||
if ( t->Tag() == TYPE_RECORD )
|
||||
{
|
||||
// Only "shallow" copy record types because we want to be able
|
||||
// to see additions to the original type's list of fields
|
||||
switch ( t->Tag() ) {
|
||||
// Only "shallow" copy types that may contain records because
|
||||
// we want to be able to see additions to the original record type's
|
||||
// list of fields
|
||||
case TYPE_RECORD:
|
||||
tnew = new RecordType(t->AsRecordType()->Types());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
break;
|
||||
case TYPE_TABLE:
|
||||
tnew = new TableType(t->AsTableType()->Indices(),
|
||||
t->AsTableType()->YieldType());
|
||||
break;
|
||||
case TYPE_VECTOR:
|
||||
tnew = new VectorType(t->AsVectorType()->YieldType());
|
||||
break;
|
||||
case TYPE_FUNC:
|
||||
tnew = new FuncType(t->AsFuncType()->Args(),
|
||||
t->AsFuncType()->YieldType(),
|
||||
t->AsFuncType()->IsEvent());
|
||||
break;
|
||||
default:
|
||||
SerializationFormat* form = new BinarySerializationFormat();
|
||||
form->StartWrite();
|
||||
CloneSerializer ss(form);
|
||||
|
|
|
@ -1092,8 +1092,10 @@ decl:
|
|||
new RecordType(fake_type_decl_list);
|
||||
ID* fake = create_dummy_id($3, fake_record);
|
||||
fake_type_decl_list = 0;
|
||||
current_reST_doc->AddRedef(
|
||||
new BroDocObj(fake, reST_doc_comments, true));
|
||||
BroDocObj* o =
|
||||
new BroDocObj(fake, reST_doc_comments, true);
|
||||
o->SetRole(true);
|
||||
current_reST_doc->AddRedef(o);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -279,7 +279,7 @@ Redefinitions
|
|||
|
||||
document the "SimpleEnum" redef here
|
||||
|
||||
.. bro:type:: Example::SimpleRecord
|
||||
:bro:type:`Example::SimpleRecord`
|
||||
|
||||
:Type: :bro:type:`record`
|
||||
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
.. Automatically generated. Do not edit.
|
||||
|
||||
autogen-reST-record-add.bro
|
||||
===========================
|
||||
|
||||
:download:`Original Source File <autogen-reST-record-add.bro>`
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
|
||||
Summary
|
||||
~~~~~~~
|
||||
State Variables
|
||||
###############
|
||||
===================================== =
|
||||
:bro:id:`a`: :bro:type:`my_record`
|
||||
|
||||
:bro:id:`b`: :bro:type:`super_record`
|
||||
===================================== =
|
||||
|
||||
Types
|
||||
#####
|
||||
============================================ =
|
||||
:bro:type:`my_record`: :bro:type:`record`
|
||||
|
||||
:bro:type:`super_record`: :bro:type:`record`
|
||||
============================================ =
|
||||
|
||||
Functions
|
||||
#########
|
||||
===================================== =
|
||||
:bro:id:`test_func`: :bro:type:`func`
|
||||
===================================== =
|
||||
|
||||
Redefinitions
|
||||
#############
|
||||
========================================= =
|
||||
:bro:type:`my_record`: :bro:type:`record`
|
||||
========================================= =
|
||||
|
||||
Public Interface
|
||||
----------------
|
||||
State Variables
|
||||
~~~~~~~~~~~~~~~
|
||||
.. bro:id:: a
|
||||
|
||||
:Type: :bro:type:`my_record`
|
||||
:Default:
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
field1=<uninitialized>
|
||||
field2=<uninitialized>
|
||||
field3=<uninitialized>
|
||||
}
|
||||
|
||||
.. bro:id:: b
|
||||
|
||||
:Type: :bro:type:`super_record`
|
||||
:Default:
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
rec=[field1=<uninitialized>, field2=<uninitialized>, field3=<uninitialized>]
|
||||
}
|
||||
|
||||
Types
|
||||
~~~~~
|
||||
.. bro:type:: my_record
|
||||
|
||||
:Type: :bro:type:`record`
|
||||
|
||||
field1: :bro:type:`bool`
|
||||
|
||||
field2: :bro:type:`string`
|
||||
|
||||
.. bro:type:: super_record
|
||||
|
||||
:Type: :bro:type:`record`
|
||||
|
||||
rec: :bro:type:`my_record`
|
||||
|
||||
Functions
|
||||
~~~~~~~~~
|
||||
.. bro:id:: test_func
|
||||
|
||||
:Type: :bro:type:`function` () : :bro:type:`void`
|
||||
|
||||
Redefinitions
|
||||
~~~~~~~~~~~~~
|
||||
.. bro:type:: my_record
|
||||
|
||||
:Type: :bro:type:`record`
|
||||
|
||||
field3: :bro:type:`count` :bro:attr:`&optional`
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
# @TEST-EXEC: bro --doc-scripts %INPUT
|
||||
# @TEST-EXEC: btest-diff autogen-reST-record-add.rst
|
||||
|
||||
# When in doc mode, bro will clone declared types (see add_type() in Var.cc)
|
||||
# in order to keep track of the identifier name associated with the new type.
|
||||
# This test makes sure that the cloning is done in a way that's compatible
|
||||
# with adding fields to a record type -- we want to be sure that cloning
|
||||
# a record that contains other record fields will correctly see field
|
||||
# additions to those contained-records.
|
||||
# a type that contains record types will correctly see field additions to
|
||||
# those contained-records.
|
||||
|
||||
type my_record: record {
|
||||
field1: bool;
|
||||
|
@ -16,17 +15,22 @@ type my_record: record {
|
|||
type super_record: record {
|
||||
rec: my_record;
|
||||
};
|
||||
type my_table: table[count] of my_record;
|
||||
type my_vector: vector of my_record;
|
||||
|
||||
redef record my_record += {
|
||||
field3: count &optional;
|
||||
};
|
||||
|
||||
global a: my_record;
|
||||
|
||||
global b: super_record;
|
||||
global c: my_table;
|
||||
global d: my_vector;
|
||||
|
||||
function test_func()
|
||||
{
|
||||
{
|
||||
a?$field3;
|
||||
b$rec?$field3;
|
||||
}
|
||||
c[0]$field3;
|
||||
d[0]$field3;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue