THRIFT-2729: C++ - .clang-format created and applied
Client: C++
Patch: Konrad Grochowski
make style command added
diff --git a/compiler/cpp/src/parse/parse.cc b/compiler/cpp/src/parse/parse.cc
index 0a0c2c0..7f94bab 100644
--- a/compiler/cpp/src/parse/parse.cc
+++ b/compiler/cpp/src/parse/parse.cc
@@ -24,7 +24,7 @@
#include "main.h"
void t_type::generate_fingerprint() {
- if (! has_fingerprint()) {
+ if (!has_fingerprint()) {
pdebug("generating fingerprint for %s", get_name().c_str());
std::string material = get_fingerprint_material();
md5_state_t ctx;
diff --git a/compiler/cpp/src/parse/t_base_type.h b/compiler/cpp/src/parse/t_base_type.h
index d76772b..34ff961 100644
--- a/compiler/cpp/src/parse/t_base_type.h
+++ b/compiler/cpp/src/parse/t_base_type.h
@@ -29,7 +29,7 @@
*
*/
class t_base_type : public t_type {
- public:
+public:
/**
* Enumeration of thrift base types
*/
@@ -44,64 +44,34 @@
TYPE_DOUBLE
};
- t_base_type(std::string name, t_base base) :
- t_type(name),
- base_(base),
- string_list_(false),
- binary_(false),
- string_enum_(false){}
+ t_base_type(std::string name, t_base base)
+ : t_type(name), base_(base), string_list_(false), binary_(false), string_enum_(false) {}
- t_base get_base() const {
- return base_;
- }
+ t_base get_base() const { return base_; }
- bool is_void() const {
- return base_ == TYPE_VOID;
- }
+ bool is_void() const { return base_ == TYPE_VOID; }
- bool is_string() const {
- return base_ == TYPE_STRING;
- }
+ bool is_string() const { return base_ == TYPE_STRING; }
- bool is_bool() const {
- return base_ == TYPE_BOOL;
- }
+ bool is_bool() const { return base_ == TYPE_BOOL; }
- void set_string_list(bool val) {
- string_list_ = val;
- }
+ void set_string_list(bool val) { string_list_ = val; }
- bool is_string_list() const {
- return (base_ == TYPE_STRING) && string_list_;
- }
+ bool is_string_list() const { return (base_ == TYPE_STRING) && string_list_; }
- void set_binary(bool val) {
- binary_ = val;
- }
+ void set_binary(bool val) { binary_ = val; }
- bool is_binary() const {
- return (base_ == TYPE_STRING) && binary_;
- }
+ bool is_binary() const { return (base_ == TYPE_STRING) && binary_; }
- void set_string_enum(bool val) {
- string_enum_ = val;
- }
+ void set_string_enum(bool val) { string_enum_ = val; }
- bool is_string_enum() const {
- return base_ == TYPE_STRING && string_enum_;
- }
+ bool is_string_enum() const { return base_ == TYPE_STRING && string_enum_; }
- void add_string_enum_val(std::string val) {
- string_enum_vals_.push_back(val);
- }
+ void add_string_enum_val(std::string val) { string_enum_vals_.push_back(val); }
- const std::vector<std::string>& get_string_enum_vals() const {
- return string_enum_vals_;
- }
+ const std::vector<std::string>& get_string_enum_vals() const { return string_enum_vals_; }
- bool is_base_type() const {
- return true;
- }
+ bool is_base_type() const { return true; }
virtual std::string get_fingerprint_material() const {
std::string rv = t_base_name(base_);
@@ -113,19 +83,37 @@
static std::string t_base_name(t_base tbase) {
switch (tbase) {
- case TYPE_VOID : return "void"; break;
- case TYPE_STRING : return "string"; break;
- case TYPE_BOOL : return "bool"; break;
- case TYPE_BYTE : return "byte"; break;
- case TYPE_I16 : return "i16"; break;
- case TYPE_I32 : return "i32"; break;
- case TYPE_I64 : return "i64"; break;
- case TYPE_DOUBLE : return "double"; break;
- default : return "(unknown)"; break;
+ case TYPE_VOID:
+ return "void";
+ break;
+ case TYPE_STRING:
+ return "string";
+ break;
+ case TYPE_BOOL:
+ return "bool";
+ break;
+ case TYPE_BYTE:
+ return "byte";
+ break;
+ case TYPE_I16:
+ return "i16";
+ break;
+ case TYPE_I32:
+ return "i32";
+ break;
+ case TYPE_I64:
+ return "i64";
+ break;
+ case TYPE_DOUBLE:
+ return "double";
+ break;
+ default:
+ return "(unknown)";
+ break;
}
}
- private:
+private:
t_base base_;
bool string_list_;
diff --git a/compiler/cpp/src/parse/t_const.h b/compiler/cpp/src/parse/t_const.h
index 7fd81bd..0f64bb1 100644
--- a/compiler/cpp/src/parse/t_const.h
+++ b/compiler/cpp/src/parse/t_const.h
@@ -31,29 +31,20 @@
*
*/
class t_const : public t_doc {
- public:
- t_const(t_type* type, std::string name, t_const_value* value) :
- type_(type),
- name_(name),
- value_(value) {}
+public:
+ t_const(t_type* type, std::string name, t_const_value* value)
+ : type_(type), name_(name), value_(value) {}
- t_type* get_type() const {
- return type_;
- }
+ t_type* get_type() const { return type_; }
- std::string get_name() const {
- return name_;
- }
+ std::string get_name() const { return name_; }
- t_const_value* get_value() const {
- return value_;
- }
+ t_const_value* get_value() const { return value_; }
- private:
+private:
t_type* type_;
std::string name_;
t_const_value* value_;
};
#endif
-
diff --git a/compiler/cpp/src/parse/t_const_value.h b/compiler/cpp/src/parse/t_const_value.h
index ff422ae..7e6e3f6 100644
--- a/compiler/cpp/src/parse/t_const_value.h
+++ b/compiler/cpp/src/parse/t_const_value.h
@@ -32,35 +32,21 @@
*
*/
class t_const_value {
- public:
-
- enum t_const_value_type {
- CV_INTEGER,
- CV_DOUBLE,
- CV_STRING,
- CV_MAP,
- CV_LIST,
- CV_IDENTIFIER
- };
+public:
+ enum t_const_value_type { CV_INTEGER, CV_DOUBLE, CV_STRING, CV_MAP, CV_LIST, CV_IDENTIFIER };
t_const_value() {}
- t_const_value(int64_t val) {
- set_integer(val);
- }
+ t_const_value(int64_t val) { set_integer(val); }
- t_const_value(std::string val) {
- set_string(val);
- }
+ t_const_value(std::string val) { set_string(val); }
void set_string(std::string val) {
valType_ = CV_STRING;
stringVal_ = val;
}
- std::string get_string() const {
- return stringVal_;
- }
+ std::string get_string() const { return stringVal_; }
void set_integer(int64_t val) {
valType_ = CV_INTEGER;
@@ -75,13 +61,12 @@
std::string identifier = get_identifier();
std::string::size_type dot = identifier.rfind('.');
if (dot != std::string::npos) {
- identifier = identifier.substr(dot+1);
+ identifier = identifier.substr(dot + 1);
}
t_enum_value* val = enum_->get_constant_by_name(identifier);
if (val == NULL) {
- throw
- "Unable to find enum value \"" + identifier +
- "\" in enum \"" + enum_->get_name() + "\"";
+ throw "Unable to find enum value \"" + identifier + "\" in enum \"" + enum_->get_name()
+ + "\"";
}
return val->get_value();
} else {
@@ -94,42 +79,26 @@
doubleVal_ = val;
}
- double get_double() const {
- return doubleVal_;
- }
+ double get_double() const { return doubleVal_; }
- void set_map() {
- valType_ = CV_MAP;
- }
+ void set_map() { valType_ = CV_MAP; }
- void add_map(t_const_value* key, t_const_value* val) {
- mapVal_[key] = val;
- }
+ void add_map(t_const_value* key, t_const_value* val) { mapVal_[key] = val; }
- const std::map<t_const_value*, t_const_value*>& get_map() const {
- return mapVal_;
- }
+ const std::map<t_const_value*, t_const_value*>& get_map() const { return mapVal_; }
- void set_list() {
- valType_ = CV_LIST;
- }
+ void set_list() { valType_ = CV_LIST; }
- void add_list(t_const_value* val) {
- listVal_.push_back(val);
- }
+ void add_list(t_const_value* val) { listVal_.push_back(val); }
- const std::vector<t_const_value*>& get_list() const {
- return listVal_;
- }
+ const std::vector<t_const_value*>& get_list() const { return listVal_; }
void set_identifier(std::string val) {
valType_ = CV_IDENTIFIER;
identifierVal_ = val;
}
- std::string get_identifier() const {
- return identifierVal_;
- }
+ std::string get_identifier() const { return identifierVal_; }
std::string get_identifier_name() const {
std::string ret = get_identifier();
@@ -137,10 +106,10 @@
if (s == std::string::npos) {
throw "error: identifier " + ret + " is unqualified!";
}
- ret = ret.substr(s+1);
+ ret = ret.substr(s + 1);
s = ret.find('.');
if (s != std::string::npos) {
- ret = ret.substr(s+1);
+ ret = ret.substr(s + 1);
}
return ret;
}
@@ -151,22 +120,18 @@
if (s == std::string::npos) {
throw "error: identifier " + ret + " is unqualified!";
}
- size_t s2 = ret.find('.', s+1);
+ size_t s2 = ret.find('.', s + 1);
if (s2 != std::string::npos) {
- ret = ret.substr(s+1);
+ ret = ret.substr(s + 1);
}
return ret;
}
- void set_enum(t_enum* tenum) {
- enum_ = tenum;
- }
+ void set_enum(t_enum* tenum) { enum_ = tenum; }
- t_const_value_type get_type() const {
- return valType_;
- }
+ t_const_value_type get_type() const { return valType_; }
- private:
+private:
std::map<t_const_value*, t_const_value*> mapVal_;
std::vector<t_const_value*> listVal_;
std::string stringVal_;
@@ -176,8 +141,6 @@
t_enum* enum_;
t_const_value_type valType_;
-
};
#endif
-
diff --git a/compiler/cpp/src/parse/t_container.h b/compiler/cpp/src/parse/t_container.h
index 6753493..0d992b7 100644
--- a/compiler/cpp/src/parse/t_container.h
+++ b/compiler/cpp/src/parse/t_container.h
@@ -23,10 +23,8 @@
#include "t_type.h"
class t_container : public t_type {
- public:
- t_container() :
- cpp_name_(),
- has_cpp_name_(false) {}
+public:
+ t_container() : cpp_name_(), has_cpp_name_(false) {}
virtual ~t_container() {}
@@ -35,22 +33,15 @@
has_cpp_name_ = true;
}
- bool has_cpp_name() {
- return has_cpp_name_;
- }
+ bool has_cpp_name() { return has_cpp_name_; }
- std::string get_cpp_name() {
- return cpp_name_;
- }
+ std::string get_cpp_name() { return cpp_name_; }
- bool is_container() const {
- return true;
- }
+ bool is_container() const { return true; }
- private:
+private:
std::string cpp_name_;
bool has_cpp_name_;
-
};
#endif
diff --git a/compiler/cpp/src/parse/t_doc.h b/compiler/cpp/src/parse/t_doc.h
index 2c63b5a..9d310b7 100644
--- a/compiler/cpp/src/parse/t_doc.h
+++ b/compiler/cpp/src/parse/t_doc.h
@@ -29,30 +29,26 @@
*/
class t_doc {
- public:
+public:
t_doc() : has_doc_(false) {}
void set_doc(const std::string& doc) {
doc_ = doc;
has_doc_ = true;
- if( (g_program_doctext_lineno == g_doctext_lineno) && (g_program_doctext_status == STILL_CANDIDATE)) {
+ if ((g_program_doctext_lineno == g_doctext_lineno)
+ && (g_program_doctext_status == STILL_CANDIDATE)) {
g_program_doctext_status = ALREADY_PROCESSED;
- pdebug("%s","program doctext set to ALREADY_PROCESSED");
+ pdebug("%s", "program doctext set to ALREADY_PROCESSED");
}
}
- const std::string& get_doc() const {
- return doc_;
- }
+ const std::string& get_doc() const { return doc_; }
- bool has_doc() {
- return has_doc_;
- }
+ bool has_doc() { return has_doc_; }
- private:
+private:
std::string doc_;
bool has_doc_;
-
};
#endif
diff --git a/compiler/cpp/src/parse/t_enum.h b/compiler/cpp/src/parse/t_enum.h
index 94cb26e..59941e3 100644
--- a/compiler/cpp/src/parse/t_enum.h
+++ b/compiler/cpp/src/parse/t_enum.h
@@ -28,21 +28,14 @@
*
*/
class t_enum : public t_type {
- public:
- t_enum(t_program* program) :
- t_type(program) {}
+public:
+ t_enum(t_program* program) : t_type(program) {}
- void set_name(const std::string& name) {
- name_ = name;
- }
+ void set_name(const std::string& name) { name_ = name; }
- void append(t_enum_value* constant) {
- constants_.push_back(constant);
- }
+ void append(t_enum_value* constant) { constants_.push_back(constant); }
- const std::vector<t_enum_value*>& get_constants() {
- return constants_;
- }
+ const std::vector<t_enum_value*>& get_constants() { return constants_; }
t_enum_value* get_constant_by_name(const std::string name) {
const std::vector<t_enum_value*>& enum_values = get_constants();
@@ -72,8 +65,7 @@
t_enum_value* min_value;
if (enum_values.size() == 0) {
min_value = NULL;
- }
- else {
+ } else {
int min_value_value;
min_value = enum_values.front();
min_value_value = min_value->get_value();
@@ -93,8 +85,7 @@
t_enum_value* max_value;
if (enum_values.size() == 0) {
max_value = NULL;
- }
- else {
+ } else {
int max_value_value;
max_value = enum_values.back();
max_value_value = max_value->get_value();
@@ -108,16 +99,11 @@
return max_value;
}
- bool is_enum() const {
- return true;
- }
+ bool is_enum() const { return true; }
- virtual std::string get_fingerprint_material() const {
- return "enum";
- }
+ virtual std::string get_fingerprint_material() const { return "enum"; }
-
- private:
+private:
std::vector<t_enum_value*> constants_;
};
diff --git a/compiler/cpp/src/parse/t_enum_value.h b/compiler/cpp/src/parse/t_enum_value.h
index 26798d7..5979f06 100644
--- a/compiler/cpp/src/parse/t_enum_value.h
+++ b/compiler/cpp/src/parse/t_enum_value.h
@@ -30,24 +30,18 @@
*
*/
class t_enum_value : public t_doc {
- public:
- t_enum_value(std::string name, int value) :
- name_(name),
- value_(value) {}
+public:
+ t_enum_value(std::string name, int value) : name_(name), value_(value) {}
~t_enum_value() {}
- const std::string& get_name() const {
- return name_;
- }
+ const std::string& get_name() const { return name_; }
- int get_value() const {
- return value_;
- }
+ int get_value() const { return value_; }
std::map<std::string, std::string> annotations_;
- private:
+private:
std::string name_;
int value_;
};
diff --git a/compiler/cpp/src/parse/t_field.h b/compiler/cpp/src/parse/t_field.h
index c05fdf3..c4e30e3 100644
--- a/compiler/cpp/src/parse/t_field.h
+++ b/compiler/cpp/src/parse/t_field.h
@@ -34,96 +34,65 @@
*
*/
class t_field : public t_doc {
- public:
- t_field(t_type* type, std::string name) :
- type_(type),
- name_(name),
- key_(0),
- value_(NULL),
- xsd_optional_(false),
- xsd_nillable_(false),
- xsd_attrs_(NULL),
- reference_(false) {}
+public:
+ t_field(t_type* type, std::string name)
+ : type_(type),
+ name_(name),
+ key_(0),
+ value_(NULL),
+ xsd_optional_(false),
+ xsd_nillable_(false),
+ xsd_attrs_(NULL),
+ reference_(false) {}
- t_field(t_type* type, std::string name, int32_t key) :
- type_(type),
- name_(name),
- key_(key),
- req_(T_OPT_IN_REQ_OUT),
- value_(NULL),
- xsd_optional_(false),
- xsd_nillable_(false),
- xsd_attrs_(NULL),
- reference_(false) {}
+ t_field(t_type* type, std::string name, int32_t key)
+ : type_(type),
+ name_(name),
+ key_(key),
+ req_(T_OPT_IN_REQ_OUT),
+ value_(NULL),
+ xsd_optional_(false),
+ xsd_nillable_(false),
+ xsd_attrs_(NULL),
+ reference_(false) {}
~t_field() {}
- t_type* get_type() const {
- return type_;
- }
+ t_type* get_type() const { return type_; }
- const std::string& get_name() const {
- return name_;
- }
+ const std::string& get_name() const { return name_; }
- int32_t get_key() const {
- return key_;
- }
+ int32_t get_key() const { return key_; }
- enum e_req {
- T_REQUIRED,
- T_OPTIONAL,
- T_OPT_IN_REQ_OUT
- };
+ enum e_req { T_REQUIRED, T_OPTIONAL, T_OPT_IN_REQ_OUT };
- void set_req(e_req req) {
- req_ = req;
- }
+ void set_req(e_req req) { req_ = req; }
- e_req get_req() const {
- return req_;
- }
+ e_req get_req() const { return req_; }
- void set_value(t_const_value* value) {
- value_ = value;
- }
+ void set_value(t_const_value* value) { value_ = value; }
- t_const_value* get_value() {
- return value_;
- }
+ t_const_value* get_value() { return value_; }
- void set_xsd_optional(bool xsd_optional) {
- xsd_optional_ = xsd_optional;
- }
+ void set_xsd_optional(bool xsd_optional) { xsd_optional_ = xsd_optional; }
- bool get_xsd_optional() const {
- return xsd_optional_;
- }
+ bool get_xsd_optional() const { return xsd_optional_; }
- void set_xsd_nillable(bool xsd_nillable) {
- xsd_nillable_ = xsd_nillable;
- }
+ void set_xsd_nillable(bool xsd_nillable) { xsd_nillable_ = xsd_nillable; }
- bool get_xsd_nillable() const {
- return xsd_nillable_;
- }
+ bool get_xsd_nillable() const { return xsd_nillable_; }
- void set_xsd_attrs(t_struct* xsd_attrs) {
- xsd_attrs_ = xsd_attrs;
- }
+ void set_xsd_attrs(t_struct* xsd_attrs) { xsd_attrs_ = xsd_attrs; }
- t_struct* get_xsd_attrs() {
- return xsd_attrs_;
- }
+ t_struct* get_xsd_attrs() { return xsd_attrs_; }
// This is not the same function as t_type::get_fingerprint_material,
// but it does the same thing.
std::string get_fingerprint_material() const {
std::ostringstream keystm;
keystm << key_;
- return keystm.str() + ":" +
- ((req_ == T_OPTIONAL) ? "opt-" : "") +
- type_->get_fingerprint_material();
+ return keystm.str() + ":" + ((req_ == T_OPTIONAL) ? "opt-" : "")
+ + type_->get_fingerprint_material();
}
/**
@@ -132,22 +101,18 @@
* The arguments are (const) references to const pointers to const t_fields.
*/
struct key_compare {
- bool operator()(t_field const * const & a, t_field const * const & b) {
+ bool operator()(t_field const* const& a, t_field const* const& b) {
return a->get_key() < b->get_key();
}
};
std::map<std::string, std::string> annotations_;
- bool get_reference() {
- return reference_;
- }
+ bool get_reference() { return reference_; }
- void set_reference(bool reference) {
- reference_ = reference;
- }
+ void set_reference(bool reference) { reference_ = reference; }
- private:
+private:
t_type* type_;
std::string name_;
int32_t key_;
diff --git a/compiler/cpp/src/parse/t_function.h b/compiler/cpp/src/parse/t_function.h
index ae8c2f6..96886f3 100644
--- a/compiler/cpp/src/parse/t_function.h
+++ b/compiler/cpp/src/parse/t_function.h
@@ -32,17 +32,11 @@
*
*/
class t_function : public t_doc {
- public:
- t_function(t_type* returntype,
- std::string name,
- t_struct* arglist,
- bool oneway=false) :
- returntype_(returntype),
- name_(name),
- arglist_(arglist),
- oneway_(oneway) {
+public:
+ t_function(t_type* returntype, std::string name, t_struct* arglist, bool oneway = false)
+ : returntype_(returntype), name_(name), arglist_(arglist), oneway_(oneway) {
xceptions_ = new t_struct(NULL);
- if (oneway_ && (! returntype_->is_void())) {
+ if (oneway_ && (!returntype_->is_void())) {
pwarning(1, "Oneway methods should return void.\n");
}
}
@@ -51,46 +45,35 @@
std::string name,
t_struct* arglist,
t_struct* xceptions,
- bool oneway=false) :
- returntype_(returntype),
- name_(name),
- arglist_(arglist),
- xceptions_(xceptions),
- oneway_(oneway)
- {
+ bool oneway = false)
+ : returntype_(returntype),
+ name_(name),
+ arglist_(arglist),
+ xceptions_(xceptions),
+ oneway_(oneway) {
if (oneway_ && !xceptions_->get_members().empty()) {
throw std::string("Oneway methods can't throw exceptions.");
}
- if (oneway_ && (! returntype_->is_void())) {
+ if (oneway_ && (!returntype_->is_void())) {
pwarning(1, "Oneway methods should return void.\n");
}
}
~t_function() {}
- t_type* get_returntype() const {
- return returntype_;
- }
+ t_type* get_returntype() const { return returntype_; }
- const std::string& get_name() const {
- return name_;
- }
+ const std::string& get_name() const { return name_; }
- t_struct* get_arglist() const {
- return arglist_;
- }
+ t_struct* get_arglist() const { return arglist_; }
- t_struct* get_xceptions() const {
- return xceptions_;
- }
+ t_struct* get_xceptions() const { return xceptions_; }
- bool is_oneway() const {
- return oneway_;
- }
+ bool is_oneway() const { return oneway_; }
std::map<std::string, std::string> annotations_;
- private:
+private:
t_type* returntype_;
std::string name_;
t_struct* arglist_;
diff --git a/compiler/cpp/src/parse/t_list.h b/compiler/cpp/src/parse/t_list.h
index 21a9625..e121d1d 100644
--- a/compiler/cpp/src/parse/t_list.h
+++ b/compiler/cpp/src/parse/t_list.h
@@ -27,17 +27,12 @@
*
*/
class t_list : public t_container {
- public:
- t_list(t_type* elem_type) :
- elem_type_(elem_type) {}
+public:
+ t_list(t_type* elem_type) : elem_type_(elem_type) {}
- t_type* get_elem_type() const {
- return elem_type_;
- }
+ t_type* get_elem_type() const { return elem_type_; }
- bool is_list() const {
- return true;
- }
+ bool is_list() const { return true; }
virtual std::string get_fingerprint_material() const {
return "list<" + elem_type_->get_fingerprint_material() + ">";
@@ -48,9 +43,8 @@
elem_type_->generate_fingerprint();
}
- private:
+private:
t_type* elem_type_;
};
#endif
-
diff --git a/compiler/cpp/src/parse/t_map.h b/compiler/cpp/src/parse/t_map.h
index c4e358f..4795147 100644
--- a/compiler/cpp/src/parse/t_map.h
+++ b/compiler/cpp/src/parse/t_map.h
@@ -28,26 +28,18 @@
*
*/
class t_map : public t_container {
- public:
- t_map(t_type* key_type, t_type* val_type) :
- key_type_(key_type),
- val_type_(val_type) {}
+public:
+ t_map(t_type* key_type, t_type* val_type) : key_type_(key_type), val_type_(val_type) {}
- t_type* get_key_type() const {
- return key_type_;
- }
+ t_type* get_key_type() const { return key_type_; }
- t_type* get_val_type() const {
- return val_type_;
- }
+ t_type* get_val_type() const { return val_type_; }
- bool is_map() const {
- return true;
- }
+ bool is_map() const { return true; }
virtual std::string get_fingerprint_material() const {
- return "map<" + key_type_->get_fingerprint_material() +
- "," + val_type_->get_fingerprint_material() + ">";
+ return "map<" + key_type_->get_fingerprint_material() + ","
+ + val_type_->get_fingerprint_material() + ">";
}
virtual void generate_fingerprint() {
@@ -56,7 +48,7 @@
val_type_->generate_fingerprint();
}
- private:
+private:
t_type* key_type_;
t_type* val_type_;
};
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index d18cc5d..51157aa 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -56,30 +56,22 @@
*
*/
class t_program : public t_doc {
- public:
- t_program(std::string path, std::string name) :
- path_(path),
- name_(name),
- out_path_("./"),
- out_path_is_absolute_(false) {
+public:
+ t_program(std::string path, std::string name)
+ : path_(path), name_(name), out_path_("./"), out_path_is_absolute_(false) {
scope_ = new t_scope();
}
- t_program(std::string path) :
- path_(path),
- out_path_("./"),
- out_path_is_absolute_(false) {
+ t_program(std::string path) : path_(path), out_path_("./"), out_path_is_absolute_(false) {
name_ = program_name(path);
scope_ = new t_scope();
}
- ~t_program()
- {
- if(scope_)
- {
- delete scope_;
- scope_ = NULL;
- }
+ ~t_program() {
+ if (scope_) {
+ delete scope_;
+ scope_ = NULL;
+ }
}
// Path accessor
@@ -101,23 +93,27 @@
const std::string& get_include_prefix() const { return include_prefix_; }
// Accessors for program elements
- const std::vector<t_typedef*>& get_typedefs() const { return typedefs_; }
- const std::vector<t_enum*>& get_enums() const { return enums_; }
- const std::vector<t_const*>& get_consts() const { return consts_; }
- const std::vector<t_struct*>& get_structs() const { return structs_; }
- const std::vector<t_struct*>& get_xceptions() const { return xceptions_; }
- const std::vector<t_struct*>& get_objects() const { return objects_; }
- const std::vector<t_service*>& get_services() const { return services_; }
+ const std::vector<t_typedef*>& get_typedefs() const { return typedefs_; }
+ const std::vector<t_enum*>& get_enums() const { return enums_; }
+ const std::vector<t_const*>& get_consts() const { return consts_; }
+ const std::vector<t_struct*>& get_structs() const { return structs_; }
+ const std::vector<t_struct*>& get_xceptions() const { return xceptions_; }
+ const std::vector<t_struct*>& get_objects() const { return objects_; }
+ const std::vector<t_service*>& get_services() const { return services_; }
// Program elements
- void add_typedef (t_typedef* td) { typedefs_.push_back(td); }
- void add_enum (t_enum* te) { enums_.push_back(te); }
- void add_const (t_const* tc) { consts_.push_back(tc); }
- void add_struct (t_struct* ts) { objects_.push_back(ts);
- structs_.push_back(ts); }
- void add_xception (t_struct* tx) { objects_.push_back(tx);
- xceptions_.push_back(tx); }
- void add_service (t_service* ts) { services_.push_back(ts); }
+ void add_typedef(t_typedef* td) { typedefs_.push_back(td); }
+ void add_enum(t_enum* te) { enums_.push_back(te); }
+ void add_const(t_const* tc) { consts_.push_back(tc); }
+ void add_struct(t_struct* ts) {
+ objects_.push_back(ts);
+ structs_.push_back(ts);
+ }
+ void add_xception(t_struct* tx) {
+ objects_.push_back(tx);
+ xceptions_.push_back(tx);
+ }
+ void add_service(t_service* ts) { services_.push_back(ts); }
// Programs to include
const std::vector<t_program*>& get_includes() const { return includes_; }
@@ -138,10 +134,9 @@
* @param t the type to test for collisions
* @return true if a certain collision was found, otherwise false
*/
- bool is_unique_typename(t_type * t) {
+ bool is_unique_typename(t_type* t) {
int occurances = program_typename_count(this, t);
- for (std::vector<t_program*>::iterator it = includes_.begin();
- it != includes_.end(); ++it) {
+ for (std::vector<t_program*>::iterator it = includes_.begin(); it != includes_.end(); ++it) {
occurances += program_typename_count(*it, t);
}
return 0 == occurances;
@@ -153,7 +148,7 @@
* @param t the type to test for collisions
* @return the number of certain typename collisions
*/
- int program_typename_count(t_program * prog, t_type * t) {
+ int program_typename_count(t_program* prog, t_type* t) {
int occurances = 0;
occurances += collection_typename_count(prog, prog->typedefs_, t);
occurances += collection_typename_count(prog, prog->enums_, t);
@@ -170,7 +165,7 @@
* @return the number of certain typename collisions
*/
template <class T>
- int collection_typename_count(t_program * prog, T type_collection, t_type * t) {
+ int collection_typename_count(t_program* prog, T type_collection, t_type* t) {
int occurances = 0;
for (typename T::iterator it = type_collection.begin(); it != type_collection.end(); ++it)
if (t != *it && 0 == t->get_name().compare((*it)->get_name()) && is_common_namespace(prog, t))
@@ -190,54 +185,67 @@
* @param t the type containing the typename match
* @return true if a collision within namespaces is found, otherwise false
*/
- bool is_common_namespace(t_program * prog, t_type * t) {
- //Case 1: Typenames are in the same program [collision]
+ bool is_common_namespace(t_program* prog, t_type* t) {
+ // Case 1: Typenames are in the same program [collision]
if (prog == t->get_program()) {
- pwarning(1, "Duplicate typename %s found in %s",
- t->get_name().c_str(), t->get_program()->get_name().c_str());
+ pwarning(1,
+ "Duplicate typename %s found in %s",
+ t->get_name().c_str(),
+ t->get_program()->get_name().c_str());
return true;
}
- //Case 2: Both programs have identical namespace scope/name declarations [collision]
+ // Case 2: Both programs have identical namespace scope/name declarations [collision]
bool match = true;
for (std::map<std::string, std::string>::iterator it = prog->namespaces_.begin();
- it != prog->namespaces_.end(); ++it) {
+ it != prog->namespaces_.end();
+ ++it) {
if (0 == it->second.compare(t->get_program()->get_namespace(it->first))) {
- pwarning(1, "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
+ pwarning(1,
+ "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
t->get_name().c_str(),
- t->get_program()->get_name().c_str(), it->first.c_str(), it->second.c_str(),
- prog->get_name().c_str(), it->first.c_str(), it->second.c_str());
+ t->get_program()->get_name().c_str(),
+ it->first.c_str(),
+ it->second.c_str(),
+ prog->get_name().c_str(),
+ it->first.c_str(),
+ it->second.c_str());
} else {
match = false;
}
}
for (std::map<std::string, std::string>::iterator it = t->get_program()->namespaces_.begin();
- it != t->get_program()->namespaces_.end(); ++it) {
+ it != t->get_program()->namespaces_.end();
+ ++it) {
if (0 == it->second.compare(prog->get_namespace(it->first))) {
- pwarning(1, "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
+ pwarning(1,
+ "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
t->get_name().c_str(),
- t->get_program()->get_name().c_str(), it->first.c_str(), it->second.c_str(),
- prog->get_name().c_str(), it->first.c_str(), it->second.c_str());
+ t->get_program()->get_name().c_str(),
+ it->first.c_str(),
+ it->second.c_str(),
+ prog->get_name().c_str(),
+ it->first.c_str(),
+ it->second.c_str());
} else {
match = false;
}
}
if (0 == prog->namespaces_.size() && 0 == t->get_program()->namespaces_.size()) {
- pwarning(1, "Duplicate typename %s found in %s and %s",
- t->get_name().c_str(), t->get_program()->get_name().c_str(), prog->get_name().c_str());
+ pwarning(1,
+ "Duplicate typename %s found in %s and %s",
+ t->get_name().c_str(),
+ t->get_program()->get_name().c_str(),
+ prog->get_name().c_str());
}
return match;
}
// Scoping and namespacing
- void set_namespace(std::string name) {
- namespace_ = name;
- }
+ void set_namespace(std::string name) { namespace_ = name; }
// Scope accessor
- t_scope* scope() const {
- return scope_;
- }
+ t_scope* scope() const { return scope_; }
// Includes
@@ -256,9 +264,7 @@
includes_.push_back(program);
}
- std::vector<t_program*>& get_includes() {
- return includes_;
- }
+ std::vector<t_program*>& get_includes() { return includes_; }
void set_include_prefix(std::string include_prefix) {
include_prefix_ = include_prefix;
@@ -277,7 +283,7 @@
std::string base_language = language.substr(0, sub_index);
std::string sub_namespace;
- if(base_language == "smalltalk") {
+ if (base_language == "smalltalk") {
pwarning(1, "Namespace 'smalltalk' is deprecated. Use 'st' instead");
base_language = "st";
}
@@ -285,16 +291,17 @@
t_generator_registry::gen_map_t my_copy = t_generator_registry::get_generator_map();
t_generator_registry::gen_map_t::iterator it;
- it=my_copy.find(base_language);
+ it = my_copy.find(base_language);
if (it == my_copy.end()) {
std::string warning = "No generator named '" + base_language + "' could be found!";
pwarning(1, warning.c_str());
} else {
if (sub_index != std::string::npos) {
- std::string sub_namespace = language.substr(sub_index+1);
- if ( ! it->second->is_valid_namespace(sub_namespace)) {
- std::string warning = base_language + " generator does not accept '" + sub_namespace + "' as sub-namespace!";
+ std::string sub_namespace = language.substr(sub_index + 1);
+ if (!it->second->is_valid_namespace(sub_namespace)) {
+ std::string warning = base_language + " generator does not accept '" + sub_namespace
+ + "' as sub-namespace!";
pwarning(1, warning.c_str());
}
}
@@ -306,8 +313,8 @@
std::string get_namespace(std::string language) const {
std::map<std::string, std::string>::const_iterator iter;
- if ((iter = namespaces_.find(language)) != namespaces_.end() ||
- (iter = namespaces_.find("*" )) != namespaces_.end()) {
+ if ((iter = namespaces_.find(language)) != namespaces_.end()
+ || (iter = namespaces_.find("*")) != namespaces_.end()) {
return iter->second;
}
return std::string();
@@ -315,24 +322,15 @@
// Language specific namespace / packaging
- void add_cpp_include(std::string path) {
- cpp_includes_.push_back(path);
- }
+ void add_cpp_include(std::string path) { cpp_includes_.push_back(path); }
- const std::vector<std::string>& get_cpp_includes() {
- return cpp_includes_;
- }
+ const std::vector<std::string>& get_cpp_includes() { return cpp_includes_; }
- void add_c_include(std::string path) {
- c_includes_.push_back(path);
- }
+ void add_c_include(std::string path) { c_includes_.push_back(path); }
- const std::vector<std::string>& get_c_includes() {
- return c_includes_;
- }
+ const std::vector<std::string>& get_c_includes() { return c_includes_; }
- private:
-
+private:
// File path
std::string path_;
@@ -359,11 +357,11 @@
// Components to generate code for
std::vector<t_typedef*> typedefs_;
- std::vector<t_enum*> enums_;
- std::vector<t_const*> consts_;
- std::vector<t_struct*> objects_;
- std::vector<t_struct*> structs_;
- std::vector<t_struct*> xceptions_;
+ std::vector<t_enum*> enums_;
+ std::vector<t_const*> consts_;
+ std::vector<t_struct*> objects_;
+ std::vector<t_struct*> structs_;
+ std::vector<t_struct*> xceptions_;
std::vector<t_service*> services_;
// Dynamic namespaces
@@ -374,7 +372,6 @@
// C extra includes
std::vector<std::string> c_includes_;
-
};
#endif
diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h
index e73c0f3..c108fdd 100644
--- a/compiler/cpp/src/parse/t_scope.h
+++ b/compiler/cpp/src/parse/t_scope.h
@@ -40,24 +40,16 @@
*
*/
class t_scope {
- public:
+public:
t_scope() {}
- void add_type(std::string name, t_type* type) {
- types_[name] = type;
- }
+ void add_type(std::string name, t_type* type) { types_[name] = type; }
- t_type* get_type(std::string name) {
- return types_[name];
- }
+ t_type* get_type(std::string name) { return types_[name]; }
- void add_service(std::string name, t_service* service) {
- services_[name] = service;
- }
+ void add_service(std::string name, t_service* service) { services_[name] = service; }
- t_service* get_service(std::string name) {
- return services_[name];
- }
+ t_service* get_service(std::string name) { return services_[name]; }
void add_constant(std::string name, t_const* constant) {
if (constants_.find(name) != constants_.end()) {
@@ -67,16 +59,12 @@
}
}
- t_const* get_constant(std::string name) {
- return constants_[name];
- }
+ t_const* get_constant(std::string name) { return constants_[name]; }
void print() {
std::map<std::string, t_type*>::iterator iter;
for (iter = types_.begin(); iter != types_.end(); ++iter) {
- printf("%s => %s\n",
- iter->first.c_str(),
- iter->second->get_name().c_str());
+ printf("%s => %s\n", iter->first.c_str(), iter->second->get_name().c_str());
}
}
@@ -101,7 +89,8 @@
for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
t_field* field = tstruct->get_field_by_name(v_iter->first->get_string());
if (field == NULL) {
- throw "No field named \"" + v_iter->first->get_string() + "\" was found in struct of type \"" + tstruct->get_name() + "\"";
+ throw "No field named \"" + v_iter->first->get_string()
+ + "\" was found in struct of type \"" + tstruct->get_name() + "\"";
}
resolve_const_value(v_iter->second, field->get_type());
}
@@ -119,21 +108,21 @@
if (const_type->is_base_type()) {
switch (((t_base_type*)const_type)->get_base()) {
- case t_base_type::TYPE_I16:
- case t_base_type::TYPE_I32:
- case t_base_type::TYPE_I64:
- case t_base_type::TYPE_BOOL:
- case t_base_type::TYPE_BYTE:
- const_val->set_integer(constant->get_value()->get_integer());
- break;
- case t_base_type::TYPE_STRING:
- const_val->set_string(constant->get_value()->get_string());
- break;
- case t_base_type::TYPE_DOUBLE:
- const_val->set_double(constant->get_value()->get_double());
- break;
- case t_base_type::TYPE_VOID:
- throw "Constants cannot be of type VOID";
+ case t_base_type::TYPE_I16:
+ case t_base_type::TYPE_I32:
+ case t_base_type::TYPE_I64:
+ case t_base_type::TYPE_BOOL:
+ case t_base_type::TYPE_BYTE:
+ const_val->set_integer(constant->get_value()->get_integer());
+ break;
+ case t_base_type::TYPE_STRING:
+ const_val->set_string(constant->get_value()->get_string());
+ break;
+ case t_base_type::TYPE_DOUBLE:
+ const_val->set_double(constant->get_value()->get_double());
+ break;
+ case t_base_type::TYPE_VOID:
+ throw "Constants cannot be of type VOID";
}
} else if (const_type->is_map()) {
const std::map<t_const_value*, t_const_value*>& map = constant->get_value()->get_map();
@@ -161,15 +150,15 @@
if (enum_value == NULL) {
std::ostringstream valstm;
valstm << const_val->get_integer();
- throw "Couldn't find a named value in enum " + tenum->get_name() + " for value " + valstm.str();
+ throw "Couldn't find a named value in enum " + tenum->get_name() + " for value "
+ + valstm.str();
}
const_val->set_identifier(tenum->get_name() + "." + enum_value->get_name());
const_val->set_enum(tenum);
}
}
- private:
-
+private:
// Map of names to types
std::map<std::string, t_type*> types_;
@@ -178,7 +167,6 @@
// Map of names to services
std::map<std::string, t_service*> services_;
-
};
#endif
diff --git a/compiler/cpp/src/parse/t_service.h b/compiler/cpp/src/parse/t_service.h
index 31e6924..091403d 100644
--- a/compiler/cpp/src/parse/t_service.h
+++ b/compiler/cpp/src/parse/t_service.h
@@ -30,18 +30,12 @@
*
*/
class t_service : public t_type {
- public:
- t_service(t_program* program) :
- t_type(program),
- extends_(NULL) {}
+public:
+ t_service(t_program* program) : t_type(program), extends_(NULL) {}
- bool is_service() const {
- return true;
- }
+ bool is_service() const { return true; }
- void set_extends(t_service* extends) {
- extends_ = extends;
- }
+ void set_extends(t_service* extends) { extends_ = extends; }
void add_function(t_function* func) {
std::vector<t_function*>::const_iterator iter;
@@ -53,20 +47,16 @@
functions_.push_back(func);
}
- const std::vector<t_function*>& get_functions() const {
- return functions_;
- }
+ const std::vector<t_function*>& get_functions() const { return functions_; }
- t_service* get_extends() {
- return extends_;
- }
+ t_service* get_extends() { return extends_; }
virtual std::string get_fingerprint_material() const {
// Services should never be used in fingerprints.
throw "BUG: Can't get fingerprint material for service.";
}
- private:
+private:
std::vector<t_function*> functions_;
t_service* extends_;
};
diff --git a/compiler/cpp/src/parse/t_set.h b/compiler/cpp/src/parse/t_set.h
index d198357..ccfc701 100644
--- a/compiler/cpp/src/parse/t_set.h
+++ b/compiler/cpp/src/parse/t_set.h
@@ -27,17 +27,12 @@
*
*/
class t_set : public t_container {
- public:
- t_set(t_type* elem_type) :
- elem_type_(elem_type) {}
+public:
+ t_set(t_type* elem_type) : elem_type_(elem_type) {}
- t_type* get_elem_type() const {
- return elem_type_;
- }
+ t_type* get_elem_type() const { return elem_type_; }
- bool is_set() const {
- return true;
- }
+ bool is_set() const { return true; }
virtual std::string get_fingerprint_material() const {
return "set<" + elem_type_->get_fingerprint_material() + ">";
@@ -48,7 +43,7 @@
elem_type_->generate_fingerprint();
}
- private:
+private:
t_type* elem_type_;
};
diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h
index 8dd4c73..2282676 100644
--- a/compiler/cpp/src/parse/t_struct.h
+++ b/compiler/cpp/src/parse/t_struct.h
@@ -37,58 +37,59 @@
*
*/
class t_struct : public t_type {
- public:
+public:
typedef std::vector<t_field*> members_type;
- t_struct(t_program* program) :
- t_type(program),
- is_xception_(false),
- is_union_(false),
- members_validated(false),
- members_with_value(0),
- xsd_all_(false) {}
+ t_struct(t_program* program)
+ : t_type(program),
+ is_xception_(false),
+ is_union_(false),
+ members_validated(false),
+ members_with_value(0),
+ xsd_all_(false) {}
- t_struct(t_program* program, const std::string& name) :
- t_type(program, name),
- is_xception_(false),
- is_union_(false),
- members_validated(false),
- members_with_value(0),
- xsd_all_(false) {}
+ t_struct(t_program* program, const std::string& name)
+ : t_type(program, name),
+ is_xception_(false),
+ is_union_(false),
+ members_validated(false),
+ members_with_value(0),
+ xsd_all_(false) {}
void set_name(const std::string& name) {
name_ = name;
validate_union_members();
}
- void set_xception(bool is_xception) {
- is_xception_ = is_xception;
- }
+ void set_xception(bool is_xception) { is_xception_ = is_xception; }
- void validate_union_member( t_field * field) {
- if( is_union_ && (! name_.empty())) {
+ void validate_union_member(t_field* field) {
+ if (is_union_ && (!name_.empty())) {
// unions can't have required fields
- if( field->get_req() == t_field::T_REQUIRED) {
- pwarning( 1, "Required field %s of union %s set to optional.\n", field->get_name().c_str(), name_.c_str());
- field->set_req( t_field::T_OPTIONAL);
+ if (field->get_req() == t_field::T_REQUIRED) {
+ pwarning(1,
+ "Required field %s of union %s set to optional.\n",
+ field->get_name().c_str(),
+ name_.c_str());
+ field->set_req(t_field::T_OPTIONAL);
}
// unions may have up to one member defaulted, but not more
- if( field->get_value() != NULL) {
- if( 1 < ++members_with_value) {
- throw "Error: Field "+field->get_name()+" provides another default value for union "+name_;
+ if (field->get_value() != NULL) {
+ if (1 < ++members_with_value) {
+ throw "Error: Field " + field->get_name() + " provides another default value for union "
+ + name_;
}
}
}
-
}
void validate_union_members() {
- if( is_union_ && (! name_.empty()) && (!members_validated)) {
+ if (is_union_ && (!name_.empty()) && (!members_validated)) {
members_type::const_iterator m_iter;
for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
- validate_union_member( *m_iter);
+ validate_union_member(*m_iter);
}
members_validated = true;
}
@@ -99,19 +100,16 @@
validate_union_members();
}
- void set_xsd_all(bool xsd_all) {
- xsd_all_ = xsd_all;
- }
+ void set_xsd_all(bool xsd_all) { xsd_all_ = xsd_all; }
- bool get_xsd_all() const {
- return xsd_all_;
- }
+ bool get_xsd_all() const { return xsd_all_; }
bool append(t_field* elem) {
typedef members_type::iterator iter_type;
- std::pair<iter_type, iter_type> bounds = std::equal_range(
- members_in_id_order_.begin(), members_in_id_order_.end(), elem, t_field::key_compare()
- );
+ std::pair<iter_type, iter_type> bounds = std::equal_range(members_in_id_order_.begin(),
+ members_in_id_order_.end(),
+ elem,
+ t_field::key_compare());
if (bounds.first != bounds.second) {
return false;
}
@@ -121,29 +119,19 @@
}
members_.push_back(elem);
members_in_id_order_.insert(bounds.second, elem);
- validate_union_member( elem);
+ validate_union_member(elem);
return true;
}
- const members_type& get_members() {
- return members_;
- }
+ const members_type& get_members() { return members_; }
- const members_type& get_sorted_members() {
- return members_in_id_order_;
- }
+ const members_type& get_sorted_members() { return members_in_id_order_; }
- bool is_struct() const {
- return !is_xception_;
- }
+ bool is_struct() const { return !is_xception_; }
- bool is_xception() const {
- return is_xception_;
- }
+ bool is_xception() const { return is_xception_; }
- bool is_union() const {
- return is_union_;
- }
+ bool is_union() const { return is_union_; }
virtual std::string get_fingerprint_material() const {
std::string rv = "{";
@@ -154,9 +142,9 @@
rv += (*m_iter)->get_fingerprint_material();
rv += ";";
- if( do_reserve) {
+ if (do_reserve) {
estimation = members_in_id_order_.size() * rv.size() + 16;
- rv.reserve( estimation);
+ rv.reserve(estimation);
do_reserve = false;
}
}
@@ -182,14 +170,13 @@
return NULL;
}
- private:
-
+private:
members_type members_;
members_type members_in_id_order_;
bool is_xception_;
bool is_union_;
bool members_validated;
- int members_with_value;
+ int members_with_value;
bool xsd_all_;
};
diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h
index b85f2da..20409f3 100644
--- a/compiler/cpp/src/parse/t_type.h
+++ b/compiler/cpp/src/parse/t_type.h
@@ -37,38 +37,30 @@
*
*/
class t_type : public t_doc {
- public:
+public:
virtual ~t_type() {}
- virtual void set_name(const std::string& name) {
- name_ = name;
- }
+ virtual void set_name(const std::string& name) { name_ = name; }
- virtual const std::string& get_name() const {
- return name_;
- }
+ virtual const std::string& get_name() const { return name_; }
- virtual bool is_void() const { return false; }
+ virtual bool is_void() const { return false; }
virtual bool is_base_type() const { return false; }
- virtual bool is_string() const { return false; }
- virtual bool is_bool() const { return false; }
- virtual bool is_typedef() const { return false; }
- virtual bool is_enum() const { return false; }
- virtual bool is_struct() const { return false; }
- virtual bool is_xception() const { return false; }
+ virtual bool is_string() const { return false; }
+ virtual bool is_bool() const { return false; }
+ virtual bool is_typedef() const { return false; }
+ virtual bool is_enum() const { return false; }
+ virtual bool is_struct() const { return false; }
+ virtual bool is_xception() const { return false; }
virtual bool is_container() const { return false; }
- virtual bool is_list() const { return false; }
- virtual bool is_set() const { return false; }
- virtual bool is_map() const { return false; }
- virtual bool is_service() const { return false; }
+ virtual bool is_list() const { return false; }
+ virtual bool is_set() const { return false; }
+ virtual bool is_map() const { return false; }
+ virtual bool is_service() const { return false; }
- t_program* get_program() {
- return program_;
- }
+ t_program* get_program() { return program_; }
- const t_program* get_program() const {
- return program_;
- }
+ const t_program* get_program() const { return program_; }
t_type* get_true_type();
@@ -95,8 +87,9 @@
return false;
}
- const uint8_t* get_binary_fingerprint() {
- if(! has_fingerprint()) // lazy fingerprint generation, right now only used with the c++ generator
+ const uint8_t* get_binary_fingerprint() {
+ if (!has_fingerprint()) // lazy fingerprint generation, right now only used with the c++
+ // generator
generate_fingerprint();
return fingerprint_;
}
@@ -128,30 +121,16 @@
std::map<std::string, std::string> annotations_;
- protected:
- t_type() :
- program_(NULL)
- {
+protected:
+ t_type() : program_(NULL) { memset(fingerprint_, 0, sizeof(fingerprint_)); }
+
+ t_type(t_program* program) : program_(program) { memset(fingerprint_, 0, sizeof(fingerprint_)); }
+
+ t_type(t_program* program, std::string name) : program_(program), name_(name) {
memset(fingerprint_, 0, sizeof(fingerprint_));
}
- t_type(t_program* program) :
- program_(program)
- {
- memset(fingerprint_, 0, sizeof(fingerprint_));
- }
-
- t_type(t_program* program, std::string name) :
- program_(program),
- name_(name)
- {
- memset(fingerprint_, 0, sizeof(fingerprint_));
- }
-
- t_type(std::string name) :
- program_(NULL),
- name_(name)
- {
+ t_type(std::string name) : program_(NULL), name_(name) {
memset(fingerprint_, 0, sizeof(fingerprint_));
}
@@ -161,7 +140,6 @@
uint8_t fingerprint_[fingerprint_len];
};
-
/**
* Placeholder struct for returning the key and value of an annotation
* during parsing.
diff --git a/compiler/cpp/src/parse/t_typedef.h b/compiler/cpp/src/parse/t_typedef.h
index 57d8df5..1051909 100644
--- a/compiler/cpp/src/parse/t_typedef.h
+++ b/compiler/cpp/src/parse/t_typedef.h
@@ -31,41 +31,31 @@
*
*/
class t_typedef : public t_type {
- public:
- t_typedef(t_program* program, t_type* type, const std::string& symbolic) :
- t_type(program, symbolic),
- type_(type),
- symbolic_(symbolic),
- forward_(false),
- seen_(false) {}
+public:
+ t_typedef(t_program* program, t_type* type, const std::string& symbolic)
+ : t_type(program, symbolic), type_(type), symbolic_(symbolic), forward_(false), seen_(false) {}
/**
* This constructor is used to refer to a type that is lazily
* resolved at a later time, like for forward declarations or
* recursive types.
*/
- t_typedef(t_program* program, const std::string& symbolic, bool forward) :
- t_type(program, symbolic),
- type_(NULL),
- symbolic_(symbolic),
- forward_(forward),
- seen_(false) {}
+ t_typedef(t_program* program, const std::string& symbolic, bool forward)
+ : t_type(program, symbolic),
+ type_(NULL),
+ symbolic_(symbolic),
+ forward_(forward),
+ seen_(false) {}
~t_typedef() {}
t_type* get_type() const;
- const std::string& get_symbolic() const {
- return symbolic_;
- }
+ const std::string& get_symbolic() const { return symbolic_; }
- bool is_forward_typedef() const {
- return forward_;
- }
+ bool is_forward_typedef() const { return forward_; }
- bool is_typedef() const {
- return true;
- }
+ bool is_typedef() const { return true; }
virtual std::string get_fingerprint_material() const {
if (!seen_) {
@@ -84,7 +74,7 @@
}
}
- private:
+private:
t_type* type_;
std::string symbolic_;
bool forward_;