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 2011/06/09 20:55:12 UTC
svn commit: r1134039 -
/thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc
Author: jfarrell
Date: Thu Jun 9 18:55:12 2011
New Revision: 1134039
URL: http://svn.apache.org/viewvc?rev=1134039&view=rev
Log:
Thrift-1181: AS3 compiler generates incorrect code for setting default values in constructor
Client: as3
Patch: Ethan Urie
Fix generated statements syntax to remove :type of the variable.
Modified:
thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc
Modified: thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc?rev=1134039&r1=1134038&r2=1134039&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc Thu Jun 9 18:55:12 2011
@@ -468,9 +468,17 @@ void t_as3_generator::print_const_value(
}
if (type->is_base_type()) {
string v2 = render_const_value(out, name, type, value);
- out << name << ":" << type_name(type) << " = " << v2 << ";" << endl << endl;
+ out << name;
+ if (!defval) {
+ out << ":" << type_name(type);
+ }
+ out << " = " << v2 << ";" << endl << endl;
} else if (type->is_enum()) {
- out << name << ":" << type_name(type) << " = " << value->get_integer() << ";" << endl << endl;
+ out << name;
+ if(!defval) {
+ out << ":" << type_name(type);
+ }
+ out << " = " << value->get_integer() << ";" << endl << endl;
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -505,7 +513,11 @@ void t_as3_generator::print_const_value(
}
out << endl;
} else if (type->is_map()) {
- out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name;
+ if(!defval){
+ out << ":" << type_name(type);
+ }
+ out << " = new " << type_name(type, false, true) << "();" << endl;
if (!in_static) {
indent(out) << "{" << endl;
indent_up();
@@ -529,7 +541,11 @@ void t_as3_generator::print_const_value(
}
out << endl;
} else if (type->is_list() || type->is_set()) {
- out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name;
+ if(!defval) {
+ out << ":" << type_name(type);
+ }
+ out << " = new " << type_name(type, false, true) << "();" << endl;
if (!in_static) {
indent(out) << "{" << endl;
indent_up();