Merge remote branch 'origin/topic/gregor/bif-tuning'

* origin/topic/gregor/bif-tuning:
  Refactor: BifTypePtr --> BifType
  Bif const: make sure const is indeed a constant.
  Support any type in bif const declaration.
  Tweak for bifcl
  Fix to bifcl wrt namespaces.
  Enable declaration of set, vector, and table types in bifs.
  Moving type declarations into its own bif file
  Support namespaces / modules in bif. Checkpoint.
  Support namespaces / modules in bif. Checkpoint.
  Remove leftovers from removing "declare enum" from bifcl
  Use namespaces for NetVar type pointers.
  Remove unused and unnecessary "declare enum" from bifcl
  Bif: add record type declaration.
  Minor tweaks for bif language.
  enum type: don't allow mixing of explicit value and auto-increment.
  Add support for enum with explicit enumerator values.

Closes #403.
This commit is contained in:
Robin Sommer 2011-02-25 15:37:06 -08:00
commit 12139e9faf
48 changed files with 864 additions and 459 deletions

View file

@ -452,31 +452,37 @@ protected:
class EnumType : public BroType {
public:
EnumType(bool arg_is_export);
EnumType();
~EnumType();
// The value of this name is next counter value, which is returned.
// A return value of -1 means that the identifier already existed
// (and thus could not be used).
int AddName(const string& module_name, const char* name);
// The value of this name is next internal counter value, starting
// with zero. The internal counter is incremented.
void AddName(const string& module_name, const char* name, bool is_export);
// Add in names from the suppled EnumType; the return value is
// the value of the last enum added.
int AddNamesFrom(const string& module_name, EnumType* et);
// The value of this name is set to val. Once a value has been
// explicitly assigned using this method, no further names can be
// added that aren't likewise explicitly initalized.
void AddName(const string& module_name, const char* name, bro_int_t val, bool is_export);
// -1 indicates not found.
int Lookup(const string& module_name, const char* name);
const char* Lookup(int value); // Returns 0 if not found
bro_int_t Lookup(const string& module_name, const char* name);
const char* Lookup(bro_int_t value); // Returns 0 if not found
protected:
EnumType() {}
DECLARE_SERIAL(EnumType)
typedef std::map< const char*, int, ltstr > NameMap;
void AddNameInternal(const string& module_name, const char* name, bro_int_t val, bool is_export);
typedef std::map< const char*, bro_int_t, ltstr > NameMap;
NameMap names;
int counter;
bool is_export;
// The counter is initialized to 0 and incremented on every implicit
// auto-increment name that gets added (thus its > 0 if
// auto-increment is used). Once an explicit value has been
// specified, the counter is set to -1. This way counter can be used
// as a flag to prevent mixing of auto-increment and explicit
// enumerator specifications.
bro_int_t counter;
};
class VectorType : public BroType {