Thrift XSD generator populates PHP globals with type names for typedeffed stuffs

Reviewed By: dave


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664933 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_xsd_generator.cc b/compiler/cpp/src/generate/t_xsd_generator.cc
index 5d4cfa2..b711440 100644
--- a/compiler/cpp/src/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/generate/t_xsd_generator.cc
@@ -7,9 +7,19 @@
 void t_xsd_generator::init_generator() {
   // Make output directory
   mkdir(T_XSD_DIR, S_IREAD | S_IWRITE | S_IEXEC);
+
+  // Make output file
+  string f_php_name = string(T_XSD_DIR)+"/"+program_->get_name()+"_xsd.php";
+  f_php_.open(f_php_name.c_str());
+
+  f_php_ <<
+    "<?php" << endl;
+
 }
 
 void t_xsd_generator::close_generator() {
+  f_php_ << "?>" << endl;
+  f_php_.close();
 }
 
 void t_xsd_generator::generate_typedef(t_typedef* ttypedef) {
@@ -78,6 +88,7 @@
       } else {
         subname = type_name(subtype);
       }
+      f_php_ << "$GLOBALS['" << program_->get_name() << "_xsd_elt_" << name << "'] = '" << subname << "';" << endl;
       generate_element(out, subname, subtype);
       indent_down();
       indent(out) << "</xsd:sequence>" << endl;
diff --git a/compiler/cpp/src/generate/t_xsd_generator.h b/compiler/cpp/src/generate/t_xsd_generator.h
index 35bcf93..0f6a41b 100644
--- a/compiler/cpp/src/generate/t_xsd_generator.h
+++ b/compiler/cpp/src/generate/t_xsd_generator.h
@@ -54,9 +54,10 @@
   std::string base_type_name(t_base_type::t_base tbase);
 
   /**
-   * Output xsd file
+   * Output xsd/php file
    */
   std::ofstream f_xsd_;
+  std::ofstream f_php_;
 
   /**
    * Output string stream