diff --git a/src/Var.cc b/src/Var.cc index f265316f17..7880325538 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -242,15 +242,25 @@ 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()); + default: SerializationFormat* form = new BinarySerializationFormat(); form->StartWrite(); CloneSerializer ss(form); @@ -267,7 +277,7 @@ void add_type(ID* id, BroType* t, attr_list* attr, int /* is_event */) tnew = t->Unserialize(&uinfo); delete [] data; - } + } tnew->SetTypeID(copy_string(id->Name())); } diff --git a/testing/btest/Baseline/doc.autogen-reST-record-add/autogen-reST-record-add.rst b/testing/btest/Baseline/doc.autogen-reST-record-add/autogen-reST-record-add.rst deleted file mode 100644 index 333600f179..0000000000 --- a/testing/btest/Baseline/doc.autogen-reST-record-add/autogen-reST-record-add.rst +++ /dev/null @@ -1,99 +0,0 @@ -.. Automatically generated. Do not edit. - -autogen-reST-record-add.bro -=========================== - -:download:`Original Source File ` - -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= - field2= - field3= - } - -.. bro:id:: b - - :Type: :bro:type:`super_record` - :Default: - - :: - - { - rec=[field1=, field2=, field3=] - } - -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` - diff --git a/testing/btest/doc/autogen-reST-record-add.bro b/testing/btest/doc/record-add.bro similarity index 70% rename from testing/btest/doc/autogen-reST-record-add.bro rename to testing/btest/doc/record-add.bro index 4ad33e68ae..a326314093 100644 --- a/testing/btest/doc/autogen-reST-record-add.bro +++ b/testing/btest/doc/record-add.bro @@ -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; + }