Thrift now works in PHP, hot stuff

Summary: End to end communication working in Thrift with PHP

Problem: It's a bit slower than pillar still. Need to find out why.

Reviewed By: aditya

Test Plan: Unit tests are in the test directory. Get lucas on the PHP case...




git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664720 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/src/main.cc b/compiler/src/main.cc
index 7f87368..8783309 100644
--- a/compiler/src/main.cc
+++ b/compiler/src/main.cc
@@ -20,6 +20,7 @@
 #include "parse/t_program.h"
 #include "generate/t_cpp_generator.h"
 #include "generate/t_java_generator.h"
+#include "generate/t_php_generator.h"
 
 using namespace std;
 
@@ -96,7 +97,7 @@
   fprintf(stderr, "Options:\n");
   fprintf(stderr, "  -cpp    Generate C++ output files\n");
   fprintf(stderr, "  -java   Generate Java output files\n");
-  //fprintf(stderr, "  -php    Generate PHP output files\n");
+  fprintf(stderr, "  -php    Generate PHP output files\n");
   //fprintf(stderr, "  -python Generate Python output files\n");
   fprintf(stderr, "  -d      Print parse debugging to standard output\n");
   exit(1);
@@ -109,6 +110,7 @@
   int i;
   bool gen_cpp = false;
   bool gen_java = false;
+  bool gen_php = false;
 
   // Setup time string
   time_t now = time(NULL);
@@ -126,13 +128,15 @@
       gen_cpp = true;
     } else if (strcmp(argv[i], "-java") == 0) {
       gen_java = true;
+    } else if (strcmp(argv[i], "-php") == 0) {
+      gen_php = true;
     } else {
       fprintf(stderr, "!!! Unrecognized option: %s\n", argv[i]);
       usage();
     }
   }
   
-  if (!gen_cpp && !gen_java) {
+  if (!gen_cpp && !gen_java && !gen_php) {
     fprintf(stderr, "!!! No output language(s) specified\n\n");
     usage();
   }
@@ -176,6 +180,11 @@
       delete java;
     }
 
+    if (gen_php) {
+      t_php_generator* php = new t_php_generator();
+      php->generate_program(g_program);
+      delete php;
+    }
   } catch (string s) {
     printf("Error: %s\n", s.c_str());
   } catch (const char* exc) {