You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2012/12/18 22:35:33 UTC
git commit: THRIFT-1788 C#: Constants static constructor does not
compile Patch: Carl Yeksigian
Updated Branches:
refs/heads/master ad8154a7a -> 5bcf32bfa
THRIFT-1788 C#: Constants static constructor does not compile
Patch: Carl Yeksigian
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/5bcf32bf
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/5bcf32bf
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/5bcf32bf
Branch: refs/heads/master
Commit: 5bcf32bfa8ea52b0783a52e773b6e2546bb9f406
Parents: ad8154a
Author: Jens Geyer <je...@apache.org>
Authored: Tue Dec 18 22:35:04 2012 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Dec 18 22:35:04 2012 +0100
----------------------------------------------------------------------
compiler/cpp/src/generate/t_csharp_generator.cc | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/5bcf32bf/compiler/cpp/src/generate/t_csharp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 943445a..31e4d0b 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -286,7 +286,7 @@ void t_csharp_generator::generate_consts(std::vector<t_const*> consts) {
vector<t_const*>::iterator c_iter;
bool need_static_constructor = false;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
- generate_csharp_doc(f_consts, (*c_iter));
+ generate_csharp_doc(f_consts, (*c_iter));
if (print_const_value(f_consts, (*c_iter)->get_name(), (*c_iter)->get_type(), (*c_iter)->get_value(), false)) {
need_static_constructor = true;
}
@@ -309,17 +309,18 @@ void t_csharp_generator::print_const_def_value(std::ofstream& out, string name,
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_field* field = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
- field_type = (*f_iter)->get_type();
+ field = (*f_iter);
}
}
- if (field_type == NULL) {
+ if (field == NULL) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
+ t_type* field_type = field->get_type();
string val = render_const_value(out, name, field_type, v_iter->second);
- indent(out) << name << "." << v_iter->first->get_string() << " = " << val << ";" << endl;
+ indent(out) << name << "." << prop_name(field) << " = " << val << ";" << endl;
}
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
@@ -367,6 +368,10 @@ void t_csharp_generator::print_const_constructor(std::ofstream& out, std::vector
bool t_csharp_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval, bool needtype) {
indent(out);
bool need_static_construction = !in_static;
+ while (type->is_typedef()) {
+ type = ((t_typedef*)type)->get_type();
+ }
+
if (!defval || needtype) {
out <<
(in_static ? "" : "public static ") <<