summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorjfarrell <jfarrell@apache.org>2014-03-11 21:56:15 -0400
committerjfarrell <jfarrell@apache.org>2014-03-11 21:56:15 -0400
commitd272f21ccab97fa870b7b844b77dd95a75356c3c (patch)
treebcae5807c9580f8eff94c7715b627d962bd0fc22 /compiler
parente3ab0bf507d1f3b6e898df702869331ee8ac8e12 (diff)
downloadthrift-d272f21ccab97fa870b7b844b77dd95a75356c3c.tar.gz
THRIFT-2389: namespaces handled wrongly in acrionscript 3.0 implementation
Client: as3 Patch: dima levchenko Updates compiler to work with AS3.0 namespacing
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cpp/src/generate/t_as3_generator.cc43
1 files changed, 33 insertions, 10 deletions
diff --git a/compiler/cpp/src/generate/t_as3_generator.cc b/compiler/cpp/src/generate/t_as3_generator.cc
index 5abeba4f8..c67384589 100644
--- a/compiler/cpp/src/generate/t_as3_generator.cc
+++ b/compiler/cpp/src/generate/t_as3_generator.cc
@@ -255,7 +255,7 @@ string t_as3_generator::as3_package() {
if (!package_name_.empty()) {
return string("package ") + package_name_ + " ";
}
- return "";
+ return "package ";
}
/**
@@ -1442,7 +1442,17 @@ void t_as3_generator::generate_service(t_service* tservice) {
f_service_ << endl <<
as3_type_imports() <<
as3_thrift_imports() <<
- as3_thrift_gen_imports(tservice) << endl;
+ as3_thrift_gen_imports(tservice);
+
+ if(tservice->get_extends() != NULL) {
+ t_type* parent = tservice->get_extends();
+ string parent_namespace = parent->get_program()->get_namespace("as3");
+ if(!parent_namespace.empty() && parent_namespace != package_name_) {
+ f_service_ << "import " << type_name(parent) << ";" << endl;
+ }
+ }
+
+ f_service_ << endl;
generate_service_interface(tservice);
@@ -1461,15 +1471,28 @@ void t_as3_generator::generate_service(t_service* tservice) {
f_service_ << endl <<
as3_type_imports() <<
as3_thrift_imports() <<
- as3_thrift_gen_imports(tservice) << endl;
-
+ as3_thrift_gen_imports(tservice);
+
+
+ if(tservice->get_extends() != NULL) {
+ t_type* parent = tservice->get_extends();
+ string parent_namespace = parent->get_program()->get_namespace("as3");
+ if(!parent_namespace.empty() && parent_namespace != package_name_) {
+ f_service_ << "import " << type_name(parent) << "Impl;" << endl;
+ }
+ }
+
+ f_service_ << endl;
+
generate_service_client(tservice);
scope_down(f_service_);
f_service_ << as3_type_imports();
f_service_ << as3_thrift_imports();
f_service_ << as3_thrift_gen_imports(tservice);
- f_service_ << "import " << package_name_ << ".*;" << endl;
+ if(!package_name_.empty()) {
+ f_service_ << "import " << package_name_ << ".*;" << endl;
+ }
generate_service_helpers(tservice);
@@ -1495,7 +1518,9 @@ void t_as3_generator::generate_service(t_service* tservice) {
f_service_ << as3_type_imports();
f_service_ << as3_thrift_imports();
f_service_ << as3_thrift_gen_imports(tservice) <<endl;
- f_service_ << "import " << package_name_ << ".*;" << endl;
+ if(!package_name_.empty()) {
+ f_service_ << "import " << package_name_ << ".*;" << endl;
+ }
generate_service_helpers(tservice);
@@ -1509,11 +1534,9 @@ void t_as3_generator::generate_service(t_service* tservice) {
* @param tservice The service to generate a header definition for
*/
void t_as3_generator::generate_service_interface(t_service* tservice) {
- string extends = "";
string extends_iface = "";
if (tservice->get_extends() != NULL) {
- extends = type_name(tservice->get_extends());
- extends_iface = " extends " + extends;
+ extends_iface = " extends " + tservice->get_extends()->get_name();
}
generate_as3_doc(f_service_, tservice);
@@ -1567,7 +1590,7 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
if (tservice->get_extends() != NULL) {
- extends = type_name(tservice->get_extends());
+ extends = tservice->get_extends()->get_name();
extends_client = " extends " + extends + "Impl";
}