mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
factored CPP source's main header into collection of per-source-file headers
This commit is contained in:
parent
a2495d028e
commit
744628f115
12 changed files with 920 additions and 957 deletions
50
src/script_opt/CPP/Attrs.h
Normal file
50
src/script_opt/CPP/Attrs.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
// Methods for tracking attributes associated with Zeek variables/types.
|
||||
// Attributes arise mainly in the context of constructing types.
|
||||
//
|
||||
// This file is included by Compile.h to insert into the CPPCompiler class.
|
||||
|
||||
public:
|
||||
// Tracks a use of the given set of attributes, including
|
||||
// initialization dependencies and the generation of any
|
||||
// associated expressions.
|
||||
//
|
||||
// Returns the initialization info associated with the set of
|
||||
// attributes.
|
||||
std::shared_ptr<CPP_InitInfo> RegisterAttributes(const AttributesPtr& attrs);
|
||||
|
||||
// Convenient access to the global offset associated with
|
||||
// a set of Attributes.
|
||||
int AttributesOffset(const AttributesPtr& attrs) { return GI_Offset(RegisterAttributes(attrs)); }
|
||||
|
||||
// The same, for a single attribute.
|
||||
std::shared_ptr<CPP_InitInfo> RegisterAttr(const AttrPtr& attr);
|
||||
|
||||
// Returns a mapping of from Attr objects to their associated
|
||||
// initialization information. The Attr must have previously
|
||||
// been registered.
|
||||
auto& ProcessedAttr() const { return processed_attr; }
|
||||
|
||||
private:
|
||||
// Start of methods related to managing script type attributes.
|
||||
// Attributes arise mainly in the context of constructing types.
|
||||
// See Attrs.cc for definitions.
|
||||
//
|
||||
|
||||
// Populates the 2nd and 3rd arguments with C++ representations
|
||||
// of the tags and (optional) values/expressions associated with
|
||||
// the set of attributes.
|
||||
void BuildAttrs(const AttributesPtr& attrs, std::string& attr_tags, std::string& attr_vals);
|
||||
|
||||
// Returns a string representation of the name associated with
|
||||
// different attribute tags (e.g., "ATTR_DEFAULT").
|
||||
static const char* AttrName(AttrTag t);
|
||||
|
||||
// Similar for attributes, so we can reconstruct record types.
|
||||
CPPTracker<Attributes> attributes = {"attrs", false};
|
||||
|
||||
// Maps Attributes and Attr's to their global initialization
|
||||
// information.
|
||||
std::unordered_map<const Attributes*, std::shared_ptr<CPP_InitInfo>> processed_attrs;
|
||||
std::unordered_map<const Attr*, std::shared_ptr<CPP_InitInfo>> processed_attr;
|
Loading…
Add table
Add a link
Reference in a new issue