You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2009/02/01 17:56:29 UTC
svn commit: r739788 - in /incubator/thrift/trunk/compiler/cpp/src:
generate/t_cpp_generator.cc generate/t_csharp_generator.cc
generate/t_java_generator.cc thriftl.ll
Author: bryanduxbury
Date: Sun Feb 1 16:56:29 2009
New Revision: 739788
URL: http://svn.apache.org/viewvc?rev=739788&view=rev
Log:
THRIFT-178. java, csharp, cpp: Final Keyword
The lexer has been changed to make "final" a non-reserved word, and the java, csharp, and cpp compilers now look for the final annotation and amend their class declarations appropriately.
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
incubator/thrift/trunk/compiler/cpp/src/generate/t_csharp_generator.cc
incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
incubator/thrift/trunk/compiler/cpp/src/thriftl.ll
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc?rev=739788&r1=739787&r2=739788&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc Sun Feb 1 16:56:29 2009
@@ -680,9 +680,11 @@
scope_down(out);
}
- out <<
- endl <<
- indent() << "virtual ~" << tstruct->get_name() << "() throw() {}" << endl << endl;
+ if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
+ out <<
+ endl <<
+ indent() << "virtual ~" << tstruct->get_name() << "() throw() {}" << endl << endl;
+ }
// Pointer to this structure's reflection local typespec.
if (gen_dense_) {
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_csharp_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_csharp_generator.cc?rev=739788&r1=739787&r2=739788&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_csharp_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_csharp_generator.cc Sun Feb 1 16:56:29 2009
@@ -393,7 +393,9 @@
out << endl;
indent(out) << "[Serializable]" << endl;
- indent(out) << "public class " << tstruct->get_name() << " : ";
+ bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
+
+ indent(out) << "public " << (is_final ? "sealed " : "") << "class " << tstruct->get_name() << " : ";
if (is_exception) {
out << "Exception, ";
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc?rev=739788&r1=739787&r2=739788&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc Sun Feb 1 16:56:29 2009
@@ -596,8 +596,11 @@
bool is_result) {
generate_java_doc(out, tstruct);
+ bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
+
indent(out) <<
- "public " << (in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
+ "public " << (is_final ? "final " : "") <<
+ (in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
if (is_exception) {
out << "extends Exception ";
Modified: incubator/thrift/trunk/compiler/cpp/src/thriftl.ll
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/thriftl.ll?rev=739788&r1=739787&r2=739788&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/thriftl.ll (original)
+++ incubator/thrift/trunk/compiler/cpp/src/thriftl.ll Sun Feb 1 16:56:29 2009
@@ -141,7 +141,6 @@
"except" { thrift_reserved_keyword(yytext); }
"exec" { thrift_reserved_keyword(yytext); }
"false" { thrift_reserved_keyword(yytext); }
-"final" { thrift_reserved_keyword(yytext); }
"finally" { thrift_reserved_keyword(yytext); }
"float" { thrift_reserved_keyword(yytext); }
"for" { thrift_reserved_keyword(yytext); }