You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2013/02/17 20:46:27 UTC

git commit: THRIFT-1856: different comments generated Patch: Jake Farrell

Updated Branches:
  refs/heads/master 3a67c2f83 -> 1af57289f


THRIFT-1856: different comments generated
Patch: Jake Farrell

Fix different comments being generated on OSX vs Linux/Windows


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/1af57289
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/1af57289
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/1af57289

Branch: refs/heads/master
Commit: 1af57289f299f9f03c9ed0e5826f8e464171bbf9
Parents: 3a67c2f
Author: Jake Farrell <jf...@apache.org>
Authored: Sun Feb 17 14:44:46 2013 -0500
Committer: Jake Farrell <jf...@apache.org>
Committed: Sun Feb 17 14:44:46 2013 -0500

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_java_generator.cc |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/1af57289/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 2f31a37..78b4c9c 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -261,7 +261,7 @@ public:
   std::string java_type_imports();
   std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false);
   std::string base_type_name(t_base_type* tbase, bool in_container=false);
-  std::string declare_field(t_field* tfield, bool init=false);
+  std::string declare_field(t_field* tfield, bool init=false, bool comment=false);
   std::string function_signature(t_function* tfunction, std::string prefix="");
   std::string function_signature_async(t_function* tfunction, bool use_base_method = false, std::string prefix="");
   std::string argument_list(t_struct* tstruct, bool include_types = true);
@@ -1292,7 +1292,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
       generate_java_doc(out, *m_iter);
       indent(out) << "public ";
     }
-    out << declare_field(*m_iter, false) << endl;
+    out << declare_field(*m_iter, false, true) << endl;
   }
 
   out << endl;
@@ -3300,7 +3300,7 @@ string t_java_generator::base_type_name(t_base_type* type,
  * @param tfield The field
  * @param init Whether to initialize the field
  */
-string t_java_generator::declare_field(t_field* tfield, bool init) {
+string t_java_generator::declare_field(t_field* tfield, bool init, bool comment) {
   // TODO(mcslee): do we ever need to initialize the field?
   string result = type_name(tfield->get_type()) + " " + tfield->get_name();
   if (init) {
@@ -3337,11 +3337,13 @@ string t_java_generator::declare_field(t_field* tfield, bool init) {
       result += " = new " + type_name(ttype, false, true) + "()";;
     }
   }
-  result += "; // ";
-  if (tfield->get_req() == t_field::T_OPTIONAL) {
-    result += "optional";
-  } else {
-    result += "required";
+  if (comment) {
+    result += "; // ";
+    if (tfield->get_req() == t_field::T_OPTIONAL) {
+      result += "optional";
+    } else {
+      result += "required";
+    }
   }
   return result;
 }