From: David Reiss Date: Tue, 5 Oct 2010 16:39:27 +0000 (+0000) Subject: compiler: Move t_type::generate_fingerprint to a .cc file X-Git-Tag: 0.6.0~144 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=9e7ba8cbacd5d09eb2af4c76eb82f7df5e0b8739;p=common%2Fthrift.git compiler: Move t_type::generate_fingerprint to a .cc file Forcing all of the functions under src/parse to be defined in header files is silly and sometimes painful. Createa a "parse.cc" file for functions that don't belong in header files. To start, move generate_fingerprint there, because it requires including md5.h. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1004702 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am index 24687dc4..6902ba47 100644 --- a/compiler/cpp/Makefile.am +++ b/compiler/cpp/Makefile.am @@ -56,6 +56,7 @@ thrift_SOURCES = src/thrifty.yy \ src/parse/t_scope.h \ src/parse/t_const.h \ src/parse/t_const_value.h \ + src/parse/parse.cc \ src/generate/t_generator.h \ src/generate/t_oop_generator.h diff --git a/compiler/cpp/src/parse/parse.cc b/compiler/cpp/src/parse/parse.cc new file mode 100644 index 00000000..2570c37b --- /dev/null +++ b/compiler/cpp/src/parse/parse.cc @@ -0,0 +1,11 @@ +#include "t_type.h" + +#include "md5.h" + +void t_type::generate_fingerprint() { + std::string material = get_fingerprint_material(); + md5_state_t ctx; + md5_init(&ctx); + md5_append(&ctx, (md5_byte_t*)(material.data()), (int)material.size()); + md5_finish(&ctx, (md5_byte_t*)fingerprint_); +} diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h index 4ce2eda1..0941a264 100644 --- a/compiler/cpp/src/parse/t_type.h +++ b/compiler/cpp/src/parse/t_type.h @@ -26,9 +26,6 @@ #include #include "t_doc.h" -// What's worse? This, or making a src/parse/non_inlined.cc? -#include "md5.h" - class t_program; /** @@ -82,13 +79,7 @@ class t_type : public t_doc { static const int fingerprint_len = 16; // Call this before trying get_*_fingerprint(). - virtual void generate_fingerprint() { - std::string material = get_fingerprint_material(); - md5_state_t ctx; - md5_init(&ctx); - md5_append(&ctx, (md5_byte_t*)(material.data()), (int)material.size()); - md5_finish(&ctx, (md5_byte_t*)fingerprint_); - } + virtual void generate_fingerprint(); bool has_fingerprint() const { for (int i = 0; i < fingerprint_len; i++) {