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:
Robin Sommer 2011-05-18 09:06:41 -07:00
commit b829c269ff
5 changed files with 35 additions and 117 deletions

View file

@ -242,15 +242,26 @@ void add_type(ID* id, BroType* t, attr_list* attr, int /* is_event */)
// t->GetTypeID() is true. // t->GetTypeID() is true.
if ( generate_documentation ) if ( generate_documentation )
{ {
if ( t->Tag() == TYPE_RECORD ) switch ( t->Tag() ) {
{ // Only "shallow" copy types that may contain records because
// Only "shallow" copy record types because we want to be able // we want to be able to see additions to the original record type's
// to see additions to the original type's list of fields // list of fields
case TYPE_RECORD:
tnew = new RecordType(t->AsRecordType()->Types()); tnew = new RecordType(t->AsRecordType()->Types());
} break;
case TYPE_TABLE:
else 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(); SerializationFormat* form = new BinarySerializationFormat();
form->StartWrite(); form->StartWrite();
CloneSerializer ss(form); CloneSerializer ss(form);
@ -267,7 +278,7 @@ void add_type(ID* id, BroType* t, attr_list* attr, int /* is_event */)
tnew = t->Unserialize(&uinfo); tnew = t->Unserialize(&uinfo);
delete [] data; delete [] data;
} }
tnew->SetTypeID(copy_string(id->Name())); tnew->SetTypeID(copy_string(id->Name()));
} }

View file

@ -1092,8 +1092,10 @@ decl:
new RecordType(fake_type_decl_list); new RecordType(fake_type_decl_list);
ID* fake = create_dummy_id($3, fake_record); ID* fake = create_dummy_id($3, fake_record);
fake_type_decl_list = 0; fake_type_decl_list = 0;
current_reST_doc->AddRedef( BroDocObj* o =
new BroDocObj(fake, reST_doc_comments, true)); new BroDocObj(fake, reST_doc_comments, true);
o->SetRole(true);
current_reST_doc->AddRedef(o);
} }
else else
{ {

View file

@ -279,7 +279,7 @@ Redefinitions
document the "SimpleEnum" redef here document the "SimpleEnum" redef here
.. bro:type:: Example::SimpleRecord :bro:type:`Example::SimpleRecord`
:Type: :bro:type:`record` :Type: :bro:type:`record`

View file

@ -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`

View file

@ -1,12 +1,11 @@
# @TEST-EXEC: bro --doc-scripts %INPUT # @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) # 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. # 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 # 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 # 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 # a type that contains record types will correctly see field additions to
# additions to those contained-records. # those contained-records.
type my_record: record { type my_record: record {
field1: bool; field1: bool;
@ -16,17 +15,22 @@ type my_record: record {
type super_record: record { type super_record: record {
rec: my_record; rec: my_record;
}; };
type my_table: table[count] of my_record;
type my_vector: vector of my_record;
redef record my_record += { redef record my_record += {
field3: count &optional; field3: count &optional;
}; };
global a: my_record; global a: my_record;
global b: super_record; global b: super_record;
global c: my_table;
global d: my_vector;
function test_func() function test_func()
{ {
a?$field3; a?$field3;
b$rec?$field3; b$rec?$field3;
} c[0]$field3;
d[0]$field3;
}