Merge remote branch 'origin/topic/robin/logging-internals'

Includes some additional cleanup.
This commit is contained in:
Robin Sommer 2011-04-20 20:27:00 -07:00
commit 13a492091f
119 changed files with 5266 additions and 183 deletions

View file

@ -32,6 +32,7 @@ typedef enum {
TYPE_FUNC,
TYPE_FILE,
TYPE_VECTOR,
TYPE_TYPE,
TYPE_ERROR
#define NUM_TYPES (int(TYPE_ERROR) + 1)
} TypeTag;
@ -60,6 +61,7 @@ class ListExpr;
class EnumType;
class Serializer;
class VectorType;
class TypeType;
const int DOES_NOT_MATCH_INDEX = 0;
const int MATCHES_INDEX_SCALAR = 1;
@ -153,6 +155,7 @@ public:
CHECK_TYPE_TAG(TYPE_SUBNET, "BroType::AsSubNetType");
return (const SubNetType*) this;
}
SubNetType* AsSubNetType()
{
CHECK_TYPE_TAG(TYPE_SUBNET, "BroType::AsSubNetType");
@ -194,6 +197,18 @@ public:
return (VectorType*) this;
}
const TypeType* AsTypeType() const
{
CHECK_TYPE_TAG(TYPE_TYPE, "BroType::AsTypeType");
return (TypeType*) this;
}
TypeType* AsTypeType()
{
CHECK_TYPE_TAG(TYPE_TYPE, "BroType::AsTypeType");
return (TypeType*) this;
}
int IsSet() const
{
return tag == TYPE_TABLE && (YieldType() == 0);
@ -371,9 +386,22 @@ protected:
ID* return_value;
};
class TypeType : public BroType {
public:
TypeType(BroType* t) : BroType(TYPE_TYPE) { type = t->Ref(); }
~TypeType() { Unref(type); }
BroType* Type() { return type; }
protected:
TypeType() {}
BroType* type;
};
class TypeDecl {
public:
TypeDecl(BroType* t, const char* i, attr_list* attrs = 0);
TypeDecl(BroType* t, const char* i, attr_list* attrs = 0, bool in_record = false);
virtual ~TypeDecl();
const Attr* FindAttr(attr_tag a) const
@ -434,6 +462,10 @@ public:
int NumFields() const { return num_fields; }
// Returns 0 if all is ok, otherwise a pointer to an error message.
// Takes ownership of list.
const char* AddFields(type_decl_list* types, attr_list* attr);
void Describe(ODesc* d) const;
void DescribeReST(ODesc* d) const;
void DescribeFields(ODesc* d) const;
@ -542,6 +574,10 @@ public:
int MatchesIndex(ListExpr*& index) const;
// Returns true if this table type is "unspecified", which is what one
// gets using an empty "vector()" constructor.
bool IsUnspecifiedVector() const;
protected:
VectorType() { yield_type = 0; }
@ -564,6 +600,9 @@ inline BroType* error_type() { return base_type(TYPE_ERROR); }
// test is done in the context of an initialization.
extern int same_type(const BroType* t1, const BroType* t2, int is_init=0);
// True if the two attribute lists are equivalent.
extern int same_attrs(const Attributes* a1, const Attributes* a2);
// Returns true if the record sub_rec can be promoted to the record
// super_rec.
extern int record_promotion_compatible(const RecordType* super_rec,