Thrift-1432: Javascript struct constants declared in the same file as their struct definition will cause an error
Client: js
Patch: Mike Riley
Flips print out of constants and structs within the generator to allow for use of constants within the structs.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1204495 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_generator.cc b/compiler/cpp/src/generate/t_generator.cc
index c91929c..67a3e78 100644
--- a/compiler/cpp/src/generate/t_generator.cc
+++ b/compiler/cpp/src/generate/t_generator.cc
@@ -45,10 +45,6 @@
generate_typedef(*td_iter);
}
- // Generate constants
- vector<t_const*> consts = program_->get_consts();
- generate_consts(consts);
-
// Generate structs, exceptions, and unions in declared order
vector<t_struct*> objects = program_->get_objects();
vector<t_struct*>::iterator o_iter;
@@ -60,6 +56,10 @@
}
}
+ // Generate constants
+ vector<t_const*> consts = program_->get_consts();
+ generate_consts(consts);
+
// Generate services
vector<t_service*> services = program_->get_services();
vector<t_service*>::iterator sv_iter;