From: David Reiss Date: Mon, 17 Sep 2007 21:16:32 +0000 (+0000) Subject: Thrift: Fix fingerprinting bug. X-Git-Tag: 0.2.0~1204 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=f84b360d5c593653a3f038d526797805861b8ace;p=common%2Fthrift.git Thrift: Fix fingerprinting bug. Summary: Fingerprints were'nt being initialized properly because I forgot to move the initialization from t_struct to t_type. Fixed that. Also, typedefs weren't generating fingerprints for their true types. Reviewed By: mcslee Test Plan: This didn't work before with -cpp -dense. Now it does. typedef list ilist struct foo { 1: ilist l } Revert Plan: ok git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665268 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h index 05cd216c..39da110d 100644 --- a/compiler/cpp/src/parse/t_struct.h +++ b/compiler/cpp/src/parse/t_struct.h @@ -9,7 +9,6 @@ #include #include -#include #include "t_type.h" #include "t_field.h" @@ -28,18 +27,12 @@ class t_struct : public t_type { t_struct(t_program* program) : t_type(program), is_xception_(false), - xsd_all_(false) - { - memset(fingerprint_, 0, sizeof(fingerprint_)); - } + xsd_all_(false) {} t_struct(t_program* program, const std::string& name) : t_type(program, name), is_xception_(false), - xsd_all_(false) - { - memset(fingerprint_, 0, sizeof(fingerprint_)); - } + xsd_all_(false) {} void set_name(const std::string& name) { name_ = name; diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h index 61975d5f..3144356a 100644 --- a/compiler/cpp/src/parse/t_type.h +++ b/compiler/cpp/src/parse/t_type.h @@ -8,6 +8,7 @@ #define T_TYPE_H #include +#include #include "t_doc.h" // What's worse? This, or making a src/parse/non_inlined.cc? @@ -114,17 +115,28 @@ class t_type : public t_doc { protected: - t_type() {} + t_type() { + memset(fingerprint_, 0, sizeof(fingerprint_)); + } t_type(t_program* program) : - program_(program) {} + program_(program) + { + memset(fingerprint_, 0, sizeof(fingerprint_)); + } t_type(t_program* program, std::string name) : program_(program), - name_(name) {} + name_(name) + { + memset(fingerprint_, 0, sizeof(fingerprint_)); + } t_type(std::string name) : - name_(name) {} + name_(name) + { + memset(fingerprint_, 0, sizeof(fingerprint_)); + } t_program* program_; std::string name_; diff --git a/compiler/cpp/src/parse/t_typedef.h b/compiler/cpp/src/parse/t_typedef.h index 341a6ff6..f2c97139 100644 --- a/compiler/cpp/src/parse/t_typedef.h +++ b/compiler/cpp/src/parse/t_typedef.h @@ -43,6 +43,13 @@ class t_typedef : public t_type { return type_->get_fingerprint_material(); } + virtual void generate_fingerprint() { + t_type::generate_fingerprint(); + if (!type_->has_fingerprint()) { + type_->generate_fingerprint(); + } + } + private: t_type* type_; std::string symbolic_;