THRIFT-1180. as3: AS3 compiler generates uncompilable code for binary types.
authorBryan Duxbury <bryanduxbury@apache.org>
Thu, 9 Jun 2011 00:40:47 +0000 (00:40 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Thu, 9 Jun 2011 00:40:47 +0000 (00:40 +0000)
Switch to ByteArray.

Patch: Ethan Urie

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1133617 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_as3_generator.cc

index e8d99ff..422af07 100644 (file)
@@ -260,6 +260,7 @@ string t_as3_generator::as3_type_imports() {
   return
     string() +
     "import org.apache.thrift.Set;\n" +
+    "import flash.utils.ByteArray;\n" +
     "import flash.utils.Dictionary;\n\n";
 }
 
@@ -864,7 +865,7 @@ void t_as3_generator::generate_as3_struct_reader(ofstream& out,
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
         out <<
-          indent() << "if (!__isset." << (*f_iter)->get_name() << ") {" << endl <<
+          indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl <<
           indent() << "  throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl <<
           indent() << "}" << endl;
       }
@@ -2423,7 +2424,7 @@ string t_as3_generator::type_name(t_type* ttype, bool in_container, bool in_init
 }
 
 /**
- * Returns the C++ type that corresponds to the thrift type.
+ * Returns the AS3 type that corresponds to the thrift type.
  *
  * @param tbase The base type
  * @param container Is it going in a As3 container?
@@ -2438,7 +2439,7 @@ string t_as3_generator::base_type_name(t_base_type* type,
     return "void";
   case t_base_type::TYPE_STRING:
     if (type->is_binary()) {
-      return "byte[]";
+      return "ByteArray";
     } else {
       return "String";
     }