THRIFT-5229 remove AS3 support
Client: AS3
Patch: Jens Geyer
This closes #2329
diff --git a/.gitignore b/.gitignore
index d11897e..2a4307a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,8 +105,6 @@
/contrib/fb303/py/fb303/ttypes.py
/depcomp
/install-sh
-/lib/as3/.gradle/
-/lib/as3/build/
/lib/cl/backport-update.zip
/lib/cl/lib
/lib/cl/run-tests
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ea71cc..d151fc0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,10 +98,6 @@
endif()
endif()
-if(BUILD_AS3)
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/as3)
-endif()
-
if(BUILD_C_GLIB)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
if(BUILD_TESTING)
diff --git a/LANGUAGES.md b/LANGUAGES.md
index 08c431d..4d88721 100644
--- a/LANGUAGES.md
+++ b/LANGUAGES.md
@@ -1,6 +1,8 @@
# Apache Thrift Language Support #
-Guidance For: 0.13.0 |
+Guidance For: 0.15.0 |
+[0.14.0](https://github.com/apache/thrift/blob/v0.14.0/LANGUAGES.md) |
+[0.13.0](https://github.com/apache/thrift/blob/v0.13.0/LANGUAGES.md) |
[0.12.0](https://github.com/apache/thrift/blob/v0.12.0/LANGUAGES.md) |
[0.11.0](https://github.com/apache/thrift/blob/0.11.0/LANGUAGES.md)
@@ -58,17 +60,6 @@
</thead>
<tbody>
<tr align=center>
-<td align=left><a href="https://github.com/apache/thrift/blob/master/lib/as3/README.md">ActionScript</a></td>
-<!-- Since -----------------><td>0.3.0</td>
-<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
-<!-- Language Levels -------><td colspan=2>FLEX SDK 4.6</td>
-<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
-<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
-<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
-<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
-<td align=left><a href="https://issues.apache.org/jira/issues/?jql=project%20%3D%20THRIFT%20AND%20component%20in%20(%22AS3%20-%20Compiler%22%2C%20%22AS3%20-%20Library%22)%20and%20status%20not%20in%20(fixed%2C%20resolved%2C%20closed)">ActionScript</a></td>
-</tr>
-<tr align=center>
<td align=left><a href="https://github.com/apache/thrift/blob/master/lib/c_glib/README.md">C (glib)</a></td>
<!-- Since -----------------><td>0.6.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 0675f0e..34604d0 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -72,7 +72,6 @@
endmacro()
# The following compiler can be enabled or disabled
-THRIFT_ADD_COMPILER(as3 "Enable compiler for ActionScript 3" ON)
THRIFT_ADD_COMPILER(c_glib "Enable compiler for C with Glib" ON)
THRIFT_ADD_COMPILER(cl "Enable compiler for Common LISP" ON)
THRIFT_ADD_COMPILER(cpp "Enable compiler for C++" ON)
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index 05c9121..2b83d94 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -69,8 +69,7 @@
src/thrift/platform.h
# Specific client generator source
-thrift_SOURCES += src/thrift/generate/t_as3_generator.cc \
- src/thrift/generate/t_c_glib_generator.cc \
+thrift_SOURCES += src/thrift/generate/t_c_glib_generator.cc \
src/thrift/generate/t_cl_generator.cc \
src/thrift/generate/t_cpp_generator.cc \
src/thrift/generate/t_d_generator.cc \
diff --git a/compiler/cpp/compiler.vcxproj b/compiler/cpp/compiler.vcxproj
index dc9793f..31bc595 100644
--- a/compiler/cpp/compiler.vcxproj
+++ b/compiler/cpp/compiler.vcxproj
@@ -53,7 +53,6 @@
<ItemGroup>
<ClCompile Include="src\thrift\audit\t_audit.cpp" />
<ClCompile Include="src\thrift\common.cc" />
- <ClCompile Include="src\thrift\generate\t_as3_generator.cc" />
<ClCompile Include="src\thrift\generate\t_c_glib_generator.cc" />
<ClCompile Include="src\thrift\generate\t_cl_generator.cc" />
<ClCompile Include="src\thrift\generate\t_cpp_generator.cc" />
diff --git a/compiler/cpp/compiler.vcxproj.filters b/compiler/cpp/compiler.vcxproj.filters
index 360c446..b5fdce7 100644
--- a/compiler/cpp/compiler.vcxproj.filters
+++ b/compiler/cpp/compiler.vcxproj.filters
@@ -92,9 +92,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\audit\t_audit.cpp"/>
- <ClCompile Include="src\generate\t_as3_generator.cc">
- <Filter>generate</Filter>
- </ClCompile>
<ClCompile Include="src\generate\t_cocoa_generator.cc">
<Filter>generate</Filter>
</ClCompile>
diff --git a/compiler/cpp/src/thrift/generate/t_as3_generator.cc b/compiler/cpp/src/thrift/generate/t_as3_generator.cc
deleted file mode 100644
index fa2967b..0000000
--- a/compiler/cpp/src/thrift/generate/t_as3_generator.cc
+++ /dev/null
@@ -1,2592 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <sstream>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <vector>
-#include <cctype>
-
-#include <sys/stat.h>
-#include <stdexcept>
-
-#include "thrift/platform.h"
-#include "thrift/generate/t_oop_generator.h"
-
-using std::map;
-using std::ostream;
-using std::ostringstream;
-using std::string;
-using std::stringstream;
-using std::vector;
-
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
-/**
- * AS3 code generator.
- *
- */
-class t_as3_generator : public t_oop_generator {
-public:
- t_as3_generator(t_program* program,
- const std::map<std::string, std::string>& parsed_options,
- const std::string& option_string)
- : t_oop_generator(program) {
- (void)option_string;
- std::map<std::string, std::string>::const_iterator iter;
-
- bindable_ = false;
- for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
- if( iter->first.compare("bindable") == 0) {
- bindable_ = true;
- } else {
- throw "unknown option as3:" + iter->first;
- }
- }
-
- out_dir_base_ = "gen-as3";
- }
-
- /**
- * Init and close methods
- */
-
- void init_generator() override;
- void close_generator() override;
-
- void generate_consts(std::vector<t_const*> consts) override;
-
- /**
- * Program-level generation functions
- */
-
- void generate_typedef(t_typedef* ttypedef) override;
- void generate_enum(t_enum* tenum) override;
- void generate_struct(t_struct* tstruct) override;
- void generate_xception(t_struct* txception) override;
- void generate_service(t_service* tservice) override;
-
- void print_const_value(std::ostream& out,
- std::string name,
- t_type* type,
- t_const_value* value,
- bool in_static,
- bool defval = false);
- std::string render_const_value(ostream& out,
- std::string name,
- t_type* type,
- t_const_value* value);
-
- /**
- * Service-level generation functions
- */
-
- void generate_as3_struct(t_struct* tstruct, bool is_exception);
-
- void generate_as3_struct_definition(std::ostream& out,
- t_struct* tstruct,
- bool is_xception = false,
- bool in_class = false,
- bool is_result = false);
- // removed -- equality,compare_to
- void generate_as3_struct_reader(std::ostream& out, t_struct* tstruct);
- void generate_as3_validator(std::ostream& out, t_struct* tstruct);
- void generate_as3_struct_result_writer(std::ostream& out, t_struct* tstruct);
- void generate_as3_struct_writer(std::ostream& out, t_struct* tstruct);
- void generate_as3_struct_tostring(std::ostream& out, t_struct* tstruct, bool bindable);
- void generate_as3_meta_data_map(std::ostream& out, t_struct* tstruct);
- void generate_field_value_meta_data(std::ostream& out, t_type* type);
- std::string get_as3_type_string(t_type* type);
- void generate_reflection_setters(std::ostringstream& out,
- t_type* type,
- std::string field_name,
- std::string cap_name);
- void generate_reflection_getters(std::ostringstream& out,
- t_type* type,
- std::string field_name,
- std::string cap_name);
- void generate_generic_field_getters_setters(std::ostream& out, t_struct* tstruct);
- void generate_generic_isset_method(std::ostream& out, t_struct* tstruct);
- void generate_as3_bean_boilerplate(std::ostream& out, t_struct* tstruct, bool bindable);
-
- void generate_function_helpers(t_function* tfunction);
- std::string get_cap_name(std::string name);
- std::string generate_isset_check(t_field* field);
- std::string generate_isset_check(std::string field);
- void generate_isset_set(ostream& out, t_field* field);
- // removed std::string isset_field_id(t_field* field);
-
- void generate_service_interface(t_service* tservice);
- void generate_service_helpers(t_service* tservice);
- void generate_service_client(t_service* tservice);
- void generate_service_server(t_service* tservice);
- void generate_process_function(t_service* tservice, t_function* tfunction);
-
- /**
- * Serialization constructs
- */
-
- void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
-
- void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
-
- void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
-
- void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
-
- void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
-
- void generate_deserialize_list_element(std::ostream& out,
- t_list* tlist,
- std::string prefix = "");
-
- void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
-
- void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
-
- void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
-
- void generate_serialize_map_element(std::ostream& out,
- t_map* tmap,
- std::string iter,
- std::string map);
-
- void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
-
- void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
-
- void generate_as3_doc(std::ostream& out, t_doc* tdoc);
-
- void generate_as3_doc(std::ostream& out, t_function* tdoc);
-
- /**
- * Helper rendering functions
- */
-
- std::string as3_package();
- std::string as3_type_imports();
- std::string as3_thrift_imports();
- std::string as3_thrift_gen_imports(t_struct* tstruct, string& imports);
- std::string as3_thrift_gen_imports(t_service* tservice);
- std::string type_name(t_type* ttype, bool in_container = false, bool in_init = false);
- std::string base_type_name(t_base_type* tbase, bool in_container = false);
- std::string declare_field(t_field* tfield, bool init = false);
- std::string function_signature(t_function* tfunction, std::string prefix = "");
- std::string argument_list(t_struct* tstruct);
- std::string type_to_enum(t_type* ttype);
- std::string get_enum_class_name(t_type* type) override;
-
- bool type_can_be_null(t_type* ttype) {
- ttype = get_true_type(ttype);
-
- return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
- || ttype->is_string();
- }
-
- std::string constant_name(std::string name);
-
-private:
- /**
- * File streams
- */
-
- std::string package_name_;
- ofstream_with_content_based_conditional_update f_service_;
- std::string package_dir_;
-
- bool bindable_;
-};
-
-/**
- * Prepares for file generation by opening up the necessary file output
- * streams.
- *
- * @param tprogram The program to generate
- */
-void t_as3_generator::init_generator() {
- // Make output directory
- MKDIR(get_out_dir().c_str());
- package_name_ = program_->get_namespace("as3");
-
- string dir = package_name_;
- string subdir = get_out_dir();
- string::size_type loc;
- while ((loc = dir.find(".")) != string::npos) {
- subdir = subdir + "/" + dir.substr(0, loc);
- MKDIR(subdir.c_str());
- dir = dir.substr(loc + 1);
- }
- if (dir.size() > 0) {
- subdir = subdir + "/" + dir;
- MKDIR(subdir.c_str());
- }
-
- package_dir_ = subdir;
-}
-
-/**
- * Packages the generated file
- *
- * @return String of the package, i.e. "package org.apache.thriftdemo;"
- */
-string t_as3_generator::as3_package() {
- if (!package_name_.empty()) {
- return string("package ") + package_name_ + " ";
- }
- return "package ";
-}
-
-/**
- * Prints standard as3 imports
- *
- * @return List of imports for As3 types that are used in here
- */
-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";
-}
-
-/**
- * Prints standard as3 imports
- *
- * @return List of imports necessary for thrift
- */
-string t_as3_generator::as3_thrift_imports() {
- return string() + "import org.apache.thrift.*;\n" + "import org.apache.thrift.meta_data.*;\n"
- + "import org.apache.thrift.protocol.*;\n\n";
-}
-
-/**
- * Prints imports needed for a given type
- *
- * @return List of imports necessary for a given t_struct
- */
-string t_as3_generator::as3_thrift_gen_imports(t_struct* tstruct, string& imports) {
-
- const vector<t_field*>& members = tstruct->get_members();
- vector<t_field*>::const_iterator m_iter;
-
- // For each type check if it is from a differnet namespace
- for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- t_program* program = (*m_iter)->get_type()->get_program();
- if (program != nullptr && program != program_) {
- string package = program->get_namespace("as3");
- if (!package.empty()) {
- if (imports.find(package + "." + (*m_iter)->get_type()->get_name()) == string::npos) {
- imports.append("import " + package + "." + (*m_iter)->get_type()->get_name() + ";\n");
- }
- }
- }
- }
- return imports;
-}
-
-/**
- * Prints imports needed for a given type
- *
- * @return List of imports necessary for a given t_service
- */
-string t_as3_generator::as3_thrift_gen_imports(t_service* tservice) {
- string imports;
- const vector<t_function*>& functions = tservice->get_functions();
- vector<t_function*>::const_iterator f_iter;
-
- // For each type check if it is from a differnet namespace
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- t_program* program = (*f_iter)->get_returntype()->get_program();
- if (program != nullptr && program != program_) {
- string package = program->get_namespace("as3");
- if (!package.empty()) {
- if (imports.find(package + "." + (*f_iter)->get_returntype()->get_name()) == string::npos) {
- imports.append("import " + package + "." + (*f_iter)->get_returntype()->get_name()
- + ";\n");
- }
- }
- }
-
- as3_thrift_gen_imports((*f_iter)->get_arglist(), imports);
- as3_thrift_gen_imports((*f_iter)->get_xceptions(), imports);
- }
-
- return imports;
-}
-
-/**
- * Nothing in As3
- */
-void t_as3_generator::close_generator() {
-}
-
-/**
- * Generates a typedef. This is not done in As3, since it does
- * not support arbitrary name replacements, and it'd be a wacky waste
- * of overhead to make wrapper classes.
- *
- * @param ttypedef The type definition
- */
-void t_as3_generator::generate_typedef(t_typedef* ttypedef) {
- (void)ttypedef;
-}
-
-/**
- * Enums are a class with a set of static constants.
- *
- * @param tenum The enumeration
- */
-void t_as3_generator::generate_enum(t_enum* tenum) {
- // Make output file
- string f_enum_name = package_dir_ + "/" + (tenum->get_name()) + ".as";
- ofstream_with_content_based_conditional_update f_enum;
- f_enum.open(f_enum_name);
-
- // Comment and package it
- f_enum << autogen_comment() << as3_package() << endl;
-
- scope_up(f_enum);
- // Add as3 imports
- f_enum << string() + "import org.apache.thrift.Set;" << endl << "import flash.utils.Dictionary;"
- << endl;
-
- indent(f_enum) << "public class " << tenum->get_name() << " ";
- scope_up(f_enum);
-
- vector<t_enum_value*> constants = tenum->get_constants();
- vector<t_enum_value*>::iterator c_iter;
- for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
- int value = (*c_iter)->get_value();
- indent(f_enum) << "public static const " << (*c_iter)->get_name() << ":int = " << value << ";"
- << endl;
- }
-
- // Create a static Set with all valid values for this enum
- f_enum << endl;
-
- indent(f_enum) << "public static const VALID_VALUES:Set = new Set(";
- indent_up();
- bool firstValue = true;
- for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
- // populate set
- f_enum << (firstValue ? "" : ", ") << (*c_iter)->get_name();
- firstValue = false;
- }
- indent_down();
- f_enum << ");" << endl;
-
- indent(f_enum) << "public static const VALUES_TO_NAMES:Dictionary = new Dictionary();" << endl;
-
- scope_up(f_enum);
- for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
- indent(f_enum) << "VALUES_TO_NAMES[" << (*c_iter)->get_name() << "] = \""
- << (*c_iter)->get_name() << "\";" << endl;
- }
- f_enum << endl;
-
- scope_down(f_enum);
-
- scope_down(f_enum); // end class
-
- scope_down(f_enum); // end package
-
- f_enum.close();
-}
-
-/**
- * Generates a class that holds all the constants.
- */
-void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
- if (consts.empty()) {
- return;
- }
-
- string f_consts_name = package_dir_ + "/" + program_name_ + "Constants.as";
- ofstream_with_content_based_conditional_update f_consts;
- f_consts.open(f_consts_name);
-
- // Print header
- f_consts << autogen_comment() << as3_package();
-
- scope_up(f_consts);
- f_consts << endl;
-
- f_consts << as3_type_imports();
-
- indent(f_consts) << "public class " << program_name_ << "Constants {" << endl << endl;
- indent_up();
- vector<t_const*>::iterator c_iter;
- for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
- print_const_value(f_consts,
- (*c_iter)->get_name(),
- (*c_iter)->get_type(),
- (*c_iter)->get_value(),
- false);
- }
- indent_down();
- indent(f_consts) << "}" << endl;
- scope_down(f_consts);
- f_consts.close();
-}
-
-void t_as3_generator::print_const_value(std::ostream& out,
- string name,
- t_type* type,
- t_const_value* value,
- bool in_static,
- bool defval) {
- type = get_true_type(type);
-
- indent(out);
- if (!defval) {
- out << (in_static ? "var " : "public static const ");
- }
- if (type->is_base_type()) {
- string v2 = render_const_value(out, name, type, value);
- out << name;
- if (!defval) {
- out << ":" << type_name(type);
- }
- out << " = " << v2 << ";" << endl << endl;
- } else if (type->is_enum()) {
- out << name;
- if (!defval) {
- out << ":" << type_name(type);
- }
- out << " = " << value->get_integer() << ";" << endl << endl;
- } else if (type->is_struct() || type->is_xception()) {
- const vector<t_field*>& fields = ((t_struct*)type)->get_members();
- vector<t_field*>::const_iterator f_iter;
- const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
- map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
- out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();"
- << endl;
- if (!in_static) {
- indent(out) << "{" << endl;
- indent_up();
- indent(out) << "new function():void {" << endl;
- indent_up();
- }
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = nullptr;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if ((*f_iter)->get_name() == v_iter->first->get_string()) {
- field_type = (*f_iter)->get_type();
- }
- }
- if (field_type == nullptr) {
- throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
- }
- string val = render_const_value(out, name, field_type, v_iter->second);
- indent(out) << name << ".";
- out << v_iter->first->get_string() << " = " << val << ";" << endl;
- }
- if (!in_static) {
- indent_down();
- indent(out) << "}();" << endl;
- indent_down();
- indent(out) << "}" << endl;
- }
- out << endl;
- } else if (type->is_map()) {
- out << name;
- if (!defval) {
- out << ":" << type_name(type);
- }
- out << " = new " << type_name(type, false, true) << "();" << endl;
- if (!in_static) {
- indent(out) << "{" << endl;
- indent_up();
- indent(out) << "new function():void {" << endl;
- indent_up();
- }
- t_type* ktype = ((t_map*)type)->get_key_type();
- t_type* vtype = ((t_map*)type)->get_val_type();
- const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
- map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- string key = render_const_value(out, name, ktype, v_iter->first);
- string val = render_const_value(out, name, vtype, v_iter->second);
- indent(out) << name << "[" << key << "] = " << val << ";" << endl;
- }
- if (!in_static) {
- indent_down();
- indent(out) << "}();" << endl;
- indent_down();
- indent(out) << "}" << endl;
- }
- out << endl;
- } else if (type->is_list() || type->is_set()) {
- out << name;
- if (!defval) {
- out << ":" << type_name(type);
- }
- out << " = new " << type_name(type, false, true) << "();" << endl;
- if (!in_static) {
- indent(out) << "{" << endl;
- indent_up();
- indent(out) << "new function():void {" << endl;
- indent_up();
- }
- t_type* etype;
- if (type->is_list()) {
- etype = ((t_list*)type)->get_elem_type();
- } else {
- etype = ((t_set*)type)->get_elem_type();
- }
- const vector<t_const_value*>& val = value->get_list();
- vector<t_const_value*>::const_iterator v_iter;
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- string val = render_const_value(out, name, etype, *v_iter);
- indent(out) << name << "." << (type->is_list() ? "push" : "add") << "(" << val << ");"
- << endl;
- }
- if (!in_static) {
- indent_down();
- indent(out) << "}();" << endl;
- indent_down();
- indent(out) << "}" << endl;
- }
- out << endl;
- } else {
- throw "compiler error: no const of type " + type->get_name();
- }
-}
-
-string t_as3_generator::render_const_value(ostream& out,
- string name,
- t_type* type,
- t_const_value* value) {
- (void)name;
- type = get_true_type(type);
- std::ostringstream render;
-
- if (type->is_base_type()) {
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
- switch (tbase) {
- case t_base_type::TYPE_STRING:
- render << '"' << get_escaped_string(value) << '"';
- break;
- case t_base_type::TYPE_BOOL:
- render << ((value->get_integer() > 0) ? "true" : "false");
- break;
- case t_base_type::TYPE_I8:
- render << "(byte)" << value->get_integer();
- break;
- case t_base_type::TYPE_I16:
- render << "(short)" << value->get_integer();
- break;
- case t_base_type::TYPE_I32:
- render << value->get_integer();
- break;
- case t_base_type::TYPE_I64:
- render << value->get_integer() << "L";
- break;
- case t_base_type::TYPE_DOUBLE:
- if (value->get_type() == t_const_value::CV_INTEGER) {
- render << "(double)" << value->get_integer();
- } else {
- render << value->get_double();
- }
- break;
- default:
- throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
- }
- } else if (type->is_enum()) {
- render << value->get_integer();
- } else {
- string t = tmp("tmp");
- print_const_value(out, t, type, value, true);
- render << t;
- }
-
- return render.str();
-}
-
-/**
- * Generates a struct definition for a thrift data type. This is a class
- * with data members, read(), write(), and an inner Isset class.
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_struct(t_struct* tstruct) {
- generate_as3_struct(tstruct, false);
-}
-
-/**
- * Exceptions are structs, but they inherit from Exception
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_xception(t_struct* txception) {
- generate_as3_struct(txception, true);
-}
-
-/**
- * As3 struct definition.
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_struct(t_struct* tstruct, bool is_exception) {
- // Make output file
- string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".as";
- ofstream_with_content_based_conditional_update f_struct;
- f_struct.open(f_struct_name.c_str());
-
- f_struct << autogen_comment() << as3_package();
-
- scope_up(f_struct);
- f_struct << endl;
-
- string imports;
-
- f_struct << as3_type_imports() << as3_thrift_imports() << as3_thrift_gen_imports(tstruct, imports)
- << endl;
-
- if (bindable_ && !is_exception) {
- f_struct << "import flash.events.Event;" << endl << "import flash.events.EventDispatcher;"
- << endl << "import mx.events.PropertyChangeEvent;" << endl;
- }
-
- generate_as3_struct_definition(f_struct, tstruct, is_exception);
-
- scope_down(f_struct); // end of package
- f_struct.close();
-}
-
-/**
- * As3 struct definition. This has various parameters, as it could be
- * generated standalone or inside another class as a helper. If it
- * is a helper than it is a static class.
- *
- * @param tstruct The struct definition
- * @param is_exception Is this an exception?
- * @param in_class If inside a class, needs to be static class
- * @param is_result If this is a result it needs a different writer
- */
-void t_as3_generator::generate_as3_struct_definition(ostream& out,
- t_struct* tstruct,
- bool is_exception,
- bool in_class,
- bool is_result) {
- generate_as3_doc(out, tstruct);
-
- bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
- bool bindable = !is_exception && !in_class && bindable_;
-
- indent(out) << (in_class ? "" : "public ") << (is_final ? "final " : "") << "class "
- << tstruct->get_name() << " ";
-
- if (is_exception) {
- out << "extends Error ";
- } else if (bindable) {
- out << "extends EventDispatcher ";
- }
- out << "implements TBase ";
-
- scope_up(out);
-
- indent(out) << "private static const STRUCT_DESC:TStruct = new TStruct(\"" << tstruct->get_name()
- << "\");" << endl;
-
- // Members are public for -as3, private for -as3bean
- const vector<t_field*>& members = tstruct->get_members();
- vector<t_field*>::const_iterator m_iter;
-
- for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- indent(out) << "private static const " << constant_name((*m_iter)->get_name())
- << "_FIELD_DESC:TField = new TField(\"" << (*m_iter)->get_name() << "\", "
- << type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << ");"
- << endl;
- }
-
- out << endl;
-
- for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- generate_as3_doc(out, *m_iter);
- indent(out) << "private var _" << (*m_iter)->get_name() + ":" + type_name((*m_iter)->get_type())
- << ";" << endl;
-
- indent(out) << "public static const " << upcase_string((*m_iter)->get_name())
- << ":int = " << (*m_iter)->get_key() << ";" << endl;
- }
-
- out << endl;
-
- // Inner Isset class
- if (members.size() > 0) {
- for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- if (!type_can_be_null((*m_iter)->get_type())) {
- indent(out) << "private var __isset_" << (*m_iter)->get_name() << ":Boolean = false;"
- << endl;
- }
- }
- }
-
- out << endl;
-
- generate_as3_meta_data_map(out, tstruct);
-
- // Static initializer to populate global class to struct metadata map
- indent(out) << "{" << endl;
- indent_up();
- indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);"
- << endl;
- indent_down();
- indent(out) << "}" << endl << endl;
-
- // Default constructor
- indent(out) << "public function " << tstruct->get_name() << "() {" << endl;
- indent_up();
- for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- if ((*m_iter)->get_value() != nullptr) {
- indent(out) << "this._" << (*m_iter)->get_name() << " = "
- << (*m_iter)->get_value()->get_integer() << ";" << endl;
- }
- }
- indent_down();
- indent(out) << "}" << endl << endl;
-
- generate_as3_bean_boilerplate(out, tstruct, bindable);
- generate_generic_field_getters_setters(out, tstruct);
- generate_generic_isset_method(out, tstruct);
-
- generate_as3_struct_reader(out, tstruct);
- if (is_result) {
- generate_as3_struct_result_writer(out, tstruct);
- } else {
- generate_as3_struct_writer(out, tstruct);
- }
- generate_as3_struct_tostring(out, tstruct, bindable);
- generate_as3_validator(out, tstruct);
- scope_down(out);
- out << endl;
-}
-
-/**
- * Generates a function to read all the fields of the struct.
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_struct_reader(ostream& out, t_struct* tstruct) {
- out << indent() << "public function read(iprot:TProtocol):void {" << endl;
- indent_up();
-
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
-
- // Declare stack tmp variables and read struct header
- out << indent() << "var field:TField;" << endl << indent() << "iprot.readStructBegin();" << endl;
-
- // Loop over reading in fields
- indent(out) << "while (true)" << endl;
- scope_up(out);
-
- // Read beginning field marker
- indent(out) << "field = iprot.readFieldBegin();" << endl;
-
- // Check for field STOP marker and break
- indent(out) << "if (field.type == TType.STOP) { " << endl;
- indent_up();
- indent(out) << "break;" << endl;
- indent_down();
- indent(out) << "}" << endl;
-
- // Switch statement on the field we are reading
- indent(out) << "switch (field.id)" << endl;
-
- scope_up(out);
-
- // Generate deserialization code for known cases
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << upcase_string((*f_iter)->get_name()) << ":" << endl;
- indent_up();
- indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
- indent_up();
-
- generate_deserialize_field(out, *f_iter, "this.");
- generate_isset_set(out, *f_iter);
- indent_down();
- out << indent() << "} else { " << endl << indent() << " TProtocolUtil.skip(iprot, field.type);"
- << endl << indent() << "}" << endl << indent() << "break;" << endl;
- indent_down();
- }
-
- // In the default case we skip the field
- out << indent() << "default:" << endl << indent() << " TProtocolUtil.skip(iprot, field.type);"
- << endl << indent() << " break;" << endl;
-
- scope_down(out);
-
- // Read field end marker
- indent(out) << "iprot.readFieldEnd();" << endl;
-
- scope_down(out);
-
- out << indent() << "iprot.readStructEnd();" << endl << endl;
-
- // in non-beans style, check for required fields of primitive type
- // (which can be checked here but not in the general validate method)
- out << endl << indent() << "// check for required fields of primitive type, which can't be "
- "checked in the validate method" << endl;
- 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()
- << " throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '"
- << (*f_iter)->get_name()
- << "' was not found in serialized data! Struct: \" + toString());" << endl << indent()
- << "}" << endl;
- }
- }
-
- // performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl;
-
- indent_down();
- out << indent() << "}" << endl << endl;
-}
-
-// generates as3 method to perform various checks
-// (e.g. check that all required fields are set)
-void t_as3_generator::generate_as3_validator(ostream& out, t_struct* tstruct) {
- indent(out) << "public function validate():void {" << endl;
- indent_up();
-
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
-
- out << indent() << "// check for required fields" << endl;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- if (type_can_be_null((*f_iter)->get_type())) {
- indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
- indent(out) << " throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '"
- << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());"
- << endl;
- indent(out) << "}" << endl;
- } else {
- indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name()
- << "' because it's a primitive and you chose the non-beans generator." << endl;
- }
- }
- }
-
- // check that fields of type enum have valid values
- out << indent() << "// check that fields of type enum have valid values" << endl;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- t_field* field = (*f_iter);
- t_type* type = field->get_type();
- // if field is an enum, check that its value is valid
- if (type->is_enum()) {
- indent(out) << "if (" << generate_isset_check(field) << " && !" << get_enum_class_name(type)
- << ".VALID_VALUES.contains(" << field->get_name() << ")){" << endl;
- indent_up();
- indent(out) << "throw new TProtocolError(TProtocolError.UNKNOWN, \"The field '"
- << field->get_name() << "' has been assigned the invalid value \" + "
- << field->get_name() << ");" << endl;
- indent_down();
- indent(out) << "}" << endl;
- }
- }
-
- indent_down();
- indent(out) << "}" << endl << endl;
-}
-
-/**
- * Generates a function to write all the fields of the struct
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_struct_writer(ostream& out, t_struct* tstruct) {
- out << indent() << "public function write(oprot:TProtocol):void {" << endl;
- indent_up();
-
- string name = tstruct->get_name();
- const vector<t_field*>& fields = tstruct->get_sorted_members();
- vector<t_field*>::const_iterator f_iter;
-
- // performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl << endl;
-
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
-
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
- if (could_be_unset) {
- indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
- indent_up();
- }
- bool null_allowed = type_can_be_null((*f_iter)->get_type());
- if (null_allowed) {
- out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
- indent_up();
- }
-
- indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
-
- // Write field contents
- generate_serialize_field(out, *f_iter, "this.");
-
- // Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
-
- if (null_allowed) {
- indent_down();
- indent(out) << "}" << endl;
- }
- if (could_be_unset) {
- indent_down();
- indent(out) << "}" << endl;
- }
- }
- // Write the struct map
- out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
- << endl;
-
- indent_down();
- out << indent() << "}" << endl << endl;
-}
-
-/**
- * Generates a function to write all the fields of the struct,
- * which is a function result. These fields are only written
- * if they are set in the Isset array, and only one of them
- * can be set at a time.
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_struct_result_writer(ostream& out, t_struct* tstruct) {
- out << indent() << "public function write(oprot:TProtocol):void {" << endl;
- indent_up();
-
- string name = tstruct->get_name();
- const vector<t_field*>& fields = tstruct->get_sorted_members();
- vector<t_field*>::const_iterator f_iter;
-
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
-
- bool first = true;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if (first) {
- first = false;
- out << endl << indent() << "if ";
- } else {
- out << " else if ";
- }
-
- out << "(this." << generate_isset_check(*f_iter) << ") {" << endl;
-
- indent_up();
-
- indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
-
- // Write field contents
- generate_serialize_field(out, *f_iter, "this.");
-
- // Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
-
- indent_down();
- indent(out) << "}";
- }
- // Write the struct map
- out << endl << indent() << "oprot.writeFieldStop();" << endl << indent()
- << "oprot.writeStructEnd();" << endl;
-
- indent_down();
- out << indent() << "}" << endl << endl;
-}
-
-void t_as3_generator::generate_reflection_getters(ostringstream& out,
- t_type* type,
- string field_name,
- string cap_name) {
- (void)type;
- (void)cap_name;
- indent(out) << "case " << upcase_string(field_name) << ":" << endl;
- indent_up();
- indent(out) << "return this." << field_name << ";" << endl;
- indent_down();
-}
-
-void t_as3_generator::generate_reflection_setters(ostringstream& out,
- t_type* type,
- string field_name,
- string cap_name) {
- (void)type;
- (void)cap_name;
- indent(out) << "case " << upcase_string(field_name) << ":" << endl;
- indent_up();
- indent(out) << "if (value == null) {" << endl;
- indent(out) << " unset" << get_cap_name(field_name) << "();" << endl;
- indent(out) << "} else {" << endl;
- indent(out) << " this." << field_name << " = value;" << endl;
- indent(out) << "}" << endl;
- indent(out) << "break;" << endl << endl;
-
- indent_down();
-}
-
-void t_as3_generator::generate_generic_field_getters_setters(std::ostream& out,
- t_struct* tstruct) {
-
- std::ostringstream getter_stream;
- std::ostringstream setter_stream;
-
- // build up the bodies of both the getter and setter at once
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- t_field* field = *f_iter;
- t_type* type = get_true_type(field->get_type());
- std::string field_name = field->get_name();
- std::string cap_name = get_cap_name(field_name);
-
- indent_up();
- generate_reflection_setters(setter_stream, type, field_name, cap_name);
- generate_reflection_getters(getter_stream, type, field_name, cap_name);
- indent_down();
- }
-
- // create the setter
- indent(out) << "public function setFieldValue(fieldID:int, value:*):void {" << endl;
- indent_up();
-
- indent(out) << "switch (fieldID) {" << endl;
-
- out << setter_stream.str();
-
- indent(out) << "default:" << endl;
- indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
-
- indent(out) << "}" << endl;
-
- indent_down();
- indent(out) << "}" << endl << endl;
-
- // create the getter
- indent(out) << "public function getFieldValue(fieldID:int):* {" << endl;
- indent_up();
-
- indent(out) << "switch (fieldID) {" << endl;
-
- out << getter_stream.str();
-
- indent(out) << "default:" << endl;
- indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
-
- indent(out) << "}" << endl;
-
- indent_down();
-
- indent(out) << "}" << endl << endl;
-}
-
-// Creates a generic isSet method that takes the field number as argument
-void t_as3_generator::generate_generic_isset_method(std::ostream& out, t_struct* tstruct) {
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
-
- // create the isSet method
- indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a "
- "value) and false otherwise" << endl;
- indent(out) << "public function isSet(fieldID:int):Boolean {" << endl;
- indent_up();
- indent(out) << "switch (fieldID) {" << endl;
-
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- t_field* field = *f_iter;
- indent(out) << "case " << upcase_string(field->get_name()) << ":" << endl;
- indent_up();
- indent(out) << "return " << generate_isset_check(field) << ";" << endl;
- indent_down();
- }
-
- indent(out) << "default:" << endl;
- indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
-
- indent(out) << "}" << endl;
-
- indent_down();
- indent(out) << "}" << endl << endl;
-}
-
-/**
- * Generates a set of As3 Bean boilerplate functions (setters, getters, etc.)
- * for the given struct.
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_bean_boilerplate(ostream& out,
- t_struct* tstruct,
- bool bindable) {
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- t_field* field = *f_iter;
- t_type* type = get_true_type(field->get_type());
- std::string field_name = field->get_name();
- std::string cap_name = get_cap_name(field_name);
-
- // Simple getter
- generate_as3_doc(out, field);
- indent(out) << "public function get " << field_name << "():" << type_name(type) << " {" << endl;
- indent_up();
- indent(out) << "return this._" << field_name << ";" << endl;
- indent_down();
- indent(out) << "}" << endl << endl;
-
- // Simple setter
- generate_as3_doc(out, field);
- std::string propName = tmp("thriftPropertyChange");
- if (bindable) {
- indent(out) << "[Bindable(event=\"" << propName << "\")]" << endl;
- }
- indent(out) << "public function set " << field_name << "(" << field_name << ":"
- << type_name(type) << "):void {" << endl;
- indent_up();
- indent(out) << "this._" << field_name << " = " << field_name << ";" << endl;
- generate_isset_set(out, field);
-
- if (bindable) {
- // We have to use a custom event rather than the default, because if you use the default,
- // the setter only gets called if the value has changed - this means calling
- // foo.setIntValue(0)
- // will not cause foo.isIntValueSet() to return true since the value of foo._intValue wasn't
- // changed
- // so the setter was never called.
- indent(out) << "dispatchEvent(new Event(\"" << propName << "\"));" << endl;
-
- // However, if you just use a custom event, then collections won't be able to detect when
- // elements
- // in the collections have changed since they listed for PropertyChangeEvents. So, we
- // dispatch both.
- indent(out) << "dispatchEvent(new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE));"
- << endl;
- }
- indent_down();
- indent(out) << "}" << endl << endl;
-
- // Unsetter
- indent(out) << "public function unset" << cap_name << "():void {" << endl;
- indent_up();
- if (type_can_be_null(type)) {
- indent(out) << "this." << field_name << " = null;" << endl;
- } else {
- indent(out) << "this.__isset_" << field_name << " = false;" << endl;
- }
- indent_down();
- indent(out) << "}" << endl << endl;
-
- // isSet method
- indent(out) << "// Returns true if field " << field_name
- << " is set (has been assigned a value) and false otherwise" << endl;
- indent(out) << "public function is" << get_cap_name("set") << cap_name << "():Boolean {"
- << endl;
- indent_up();
- if (type_can_be_null(type)) {
- indent(out) << "return this." << field_name << " != null;" << endl;
- } else {
- indent(out) << "return this.__isset_" << field_name << ";" << endl;
- }
- indent_down();
- indent(out) << "}" << endl << endl;
- }
-}
-
-/**
- * Generates a toString() method for the given struct
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_struct_tostring(ostream& out,
- t_struct* tstruct,
- bool bindable) {
- // If it's bindable, it extends EventDispatcher so toString is an override.
- out << indent() << "public " << (bindable ? "override " : "") << "function toString():String {"
- << endl;
- indent_up();
-
- out << indent() << "var ret:String = new String(\"" << tstruct->get_name() << "(\");" << endl;
- out << indent() << "var first:Boolean = true;" << endl << endl;
-
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
- bool first = true;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
- if (could_be_unset) {
- indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
- indent_up();
- }
-
- t_field* field = (*f_iter);
-
- if (!first) {
- indent(out) << "if (!first) ret += \", \";" << endl;
- }
- indent(out) << "ret += \"" << (*f_iter)->get_name() << ":\";" << endl;
- bool can_be_null = type_can_be_null(field->get_type());
- if (can_be_null) {
- indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << endl;
- indent(out) << " ret += \"null\";" << endl;
- indent(out) << "} else {" << endl;
- indent_up();
- }
-
- if (field->get_type()->is_binary()) {
- indent(out) << " ret += \"BINARY\";" << endl;
- } else if (field->get_type()->is_enum()) {
- indent(out) << "var " << field->get_name()
- << "_name:String = " << get_enum_class_name(field->get_type())
- << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << endl;
- indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
- indent(out) << " ret += " << field->get_name() << "_name;" << endl;
- indent(out) << " ret += \" (\";" << endl;
- indent(out) << "}" << endl;
- indent(out) << "ret += this." << field->get_name() << ";" << endl;
- indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
- indent(out) << " ret += \")\";" << endl;
- indent(out) << "}" << endl;
- } else {
- indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << endl;
- }
-
- if (can_be_null) {
- indent_down();
- indent(out) << "}" << endl;
- }
- indent(out) << "first = false;" << endl;
-
- if (could_be_unset) {
- indent_down();
- indent(out) << "}" << endl;
- }
- first = false;
- }
- out << indent() << "ret += \")\";" << endl << indent() << "return ret;" << endl;
-
- indent_down();
- indent(out) << "}" << endl << endl;
-}
-
-/**
- * Generates a static map with meta data to store information such as fieldID to
- * fieldName mapping
- *
- * @param tstruct The struct definition
- */
-void t_as3_generator::generate_as3_meta_data_map(ostream& out, t_struct* tstruct) {
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
-
- // Static Map with fieldID -> FieldMetaData mappings
- indent(out) << "public static const metaDataMap:Dictionary = new Dictionary();" << endl;
-
- if (fields.size() > 0) {
- // Populate map
- scope_up(out);
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- t_field* field = *f_iter;
- std::string field_name = field->get_name();
- indent(out) << "metaDataMap[" << upcase_string(field_name) << "] = new FieldMetaData(\""
- << field_name << "\", ";
-
- // Set field requirement type (required, optional, etc.)
- if (field->get_req() == t_field::T_REQUIRED) {
- out << "TFieldRequirementType.REQUIRED, ";
- } else if (field->get_req() == t_field::T_OPTIONAL) {
- out << "TFieldRequirementType.OPTIONAL, ";
- } else {
- out << "TFieldRequirementType.DEFAULT, ";
- }
-
- // Create value meta data
- generate_field_value_meta_data(out, field->get_type());
- out << ");" << endl;
- }
- scope_down(out);
- }
-}
-
-/**
- * Returns a string with the as3 representation of the given thrift type
- * (e.g. for the type struct it returns "TType.STRUCT")
- */
-std::string t_as3_generator::get_as3_type_string(t_type* type) {
- if (type->is_list()) {
- return "TType.LIST";
- } else if (type->is_map()) {
- return "TType.MAP";
- } else if (type->is_set()) {
- return "TType.SET";
- } else if (type->is_struct() || type->is_xception()) {
- return "TType.STRUCT";
- } else if (type->is_enum()) {
- return "TType.I32";
- } else if (type->is_typedef()) {
- return get_as3_type_string(((t_typedef*)type)->get_type());
- } else if (type->is_base_type()) {
- switch (((t_base_type*)type)->get_base()) {
- case t_base_type::TYPE_VOID:
- return "TType.VOID";
- break;
- case t_base_type::TYPE_STRING:
- return "TType.STRING";
- break;
- case t_base_type::TYPE_BOOL:
- return "TType.BOOL";
- break;
- case t_base_type::TYPE_I8:
- return "TType.BYTE";
- break;
- case t_base_type::TYPE_I16:
- return "TType.I16";
- break;
- case t_base_type::TYPE_I32:
- return "TType.I32";
- break;
- case t_base_type::TYPE_I64:
- return "TType.I64";
- break;
- case t_base_type::TYPE_DOUBLE:
- return "TType.DOUBLE";
- break;
- default:
- throw std::runtime_error("Unknown thrift type \"" + type->get_name()
- + "\" passed to t_as3_generator::get_as3_type_string!");
- break; // This should never happen!
- }
- } else {
- throw std::runtime_error(
- "Unknown thrift type \"" + type->get_name()
- + "\" passed to t_as3_generator::get_as3_type_string!"); // This should never happen!
- }
-}
-
-void t_as3_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
- out << endl;
- indent_up();
- indent_up();
- if (type->is_struct() || type->is_xception()) {
- indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type);
- } else if (type->is_container()) {
- if (type->is_list()) {
- indent(out) << "new ListMetaData(TType.LIST, ";
- t_type* elem_type = ((t_list*)type)->get_elem_type();
- generate_field_value_meta_data(out, elem_type);
- } else if (type->is_set()) {
- indent(out) << "new SetMetaData(TType.SET, ";
- t_type* elem_type = ((t_list*)type)->get_elem_type();
- generate_field_value_meta_data(out, elem_type);
- } else { // map
- indent(out) << "new MapMetaData(TType.MAP, ";
- t_type* key_type = ((t_map*)type)->get_key_type();
- t_type* val_type = ((t_map*)type)->get_val_type();
- generate_field_value_meta_data(out, key_type);
- out << ", ";
- generate_field_value_meta_data(out, val_type);
- }
- } else {
- indent(out) << "new FieldValueMetaData(" << get_as3_type_string(type);
- }
- out << ")";
- indent_down();
- indent_down();
-}
-
-/**
- * Generates a thrift service. In C++, this comprises an entirely separate
- * header and source file. The header file defines the methods and includes
- * the data types defined in the main header file, and the implementation
- * file contains implementations of the basic printer and default interfaces.
- *
- * @param tservice The service definition
- */
-void t_as3_generator::generate_service(t_service* tservice) {
- // Make interface file
- string f_service_name = package_dir_ + "/" + service_name_ + ".as";
- f_service_.open(f_service_name.c_str());
-
- f_service_ << autogen_comment() << as3_package();
-
- scope_up(f_service_);
-
- f_service_ << endl << as3_type_imports() << as3_thrift_imports()
- << as3_thrift_gen_imports(tservice);
-
- if (tservice->get_extends() != nullptr) {
- 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);
-
- scope_down(f_service_);
- f_service_.close();
-
- // Now make the implementation/client file
- f_service_name = package_dir_ + "/" + service_name_ + "Impl.as";
- f_service_.open(f_service_name.c_str());
-
- f_service_ << autogen_comment() << as3_package();
-
- scope_up(f_service_);
-
- f_service_ << endl << as3_type_imports() << as3_thrift_imports()
- << as3_thrift_gen_imports(tservice);
-
- if (tservice->get_extends() != nullptr) {
- 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);
- if (!package_name_.empty()) {
- f_service_ << "import " << package_name_ << ".*;" << endl;
- }
-
- generate_service_helpers(tservice);
-
- f_service_.close();
-
- // Now make the processor/server file
- f_service_name = package_dir_ + "/" + service_name_ + "Processor.as";
- f_service_.open(f_service_name.c_str());
-
- f_service_ << autogen_comment() << as3_package();
-
- scope_up(f_service_);
-
- f_service_ << endl << as3_type_imports() << as3_thrift_imports()
- << as3_thrift_gen_imports(tservice) << endl;
-
- generate_service_server(tservice);
- scope_down(f_service_);
-
- f_service_ << as3_type_imports();
- f_service_ << as3_thrift_imports();
- f_service_ << as3_thrift_gen_imports(tservice) << endl;
- if (!package_name_.empty()) {
- f_service_ << "import " << package_name_ << ".*;" << endl;
- }
-
- generate_service_helpers(tservice);
-
- f_service_.close();
-}
-
-/**
- * Generates a service interface definition.
- *
- * @param tservice The service to generate a header definition for
- */
-void t_as3_generator::generate_service_interface(t_service* tservice) {
- string extends_iface = "";
- if (tservice->get_extends() != nullptr) {
- extends_iface = " extends " + tservice->get_extends()->get_name();
- }
-
- generate_as3_doc(f_service_, tservice);
- f_service_ << indent() << "public interface " << service_name_ << extends_iface << " {" << endl
- << endl;
- indent_up();
- vector<t_function*> functions = tservice->get_functions();
- vector<t_function*>::iterator f_iter;
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- generate_as3_doc(f_service_, *f_iter);
- if (!(*f_iter)->is_oneway()) {
- if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "//function onError(Error):void;" << endl;
- indent(f_service_) << "//function onSuccess():void;" << endl;
- } else {
- indent(f_service_) << "//function onError(Error):void;" << endl;
- indent(f_service_) << "//function onSuccess(" << type_name((*f_iter)->get_returntype())
- << "):void;" << endl;
- }
- }
- indent(f_service_) << function_signature(*f_iter) << ";" << endl << endl;
- }
- indent_down();
- f_service_ << indent() << "}" << endl << endl;
-}
-
-/**
- * Generates structs for all the service args and return types
- *
- * @param tservice The service
- */
-void t_as3_generator::generate_service_helpers(t_service* tservice) {
- vector<t_function*> functions = tservice->get_functions();
- vector<t_function*>::iterator f_iter;
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- t_struct* ts = (*f_iter)->get_arglist();
- generate_as3_struct_definition(f_service_, ts, false, true);
- generate_function_helpers(*f_iter);
- }
-}
-
-/**
- * Generates a service client definition.
- *
- * @param tservice The service to generate a server for.
- */
-void t_as3_generator::generate_service_client(t_service* tservice) {
- string extends = "";
- string extends_client = "";
- if (tservice->get_extends() != nullptr) {
- extends = tservice->get_extends()->get_name();
- extends_client = " extends " + extends + "Impl";
- }
-
- indent(f_service_) << "public class " << service_name_ << "Impl" << extends_client
- << " implements " << service_name_ << " {" << endl;
- indent_up();
-
- indent(f_service_) << "public function " << service_name_ << "Impl"
- << "(iprot:TProtocol, oprot:TProtocol=null)" << endl;
- scope_up(f_service_);
- if (extends.empty()) {
- f_service_ << indent() << "iprot_ = iprot;" << endl;
- f_service_ << indent() << "if (oprot == null) {" << endl;
- indent_up();
- f_service_ << indent() << "oprot_ = iprot;" << endl;
- indent_down();
- f_service_ << indent() << "} else {" << endl;
- indent_up();
- f_service_ << indent() << "oprot_ = oprot;" << endl;
- indent_down();
- f_service_ << indent() << "}";
- } else {
- f_service_ << indent() << "super(iprot, oprot);" << endl;
- }
- scope_down(f_service_);
- f_service_ << endl;
-
- if (extends.empty()) {
- f_service_ << indent() << "protected var iprot_:TProtocol;" << endl << indent()
- << "protected var oprot_:TProtocol;" << endl << endl << indent()
- << "protected var seqid_:int;" << endl << endl;
-
- indent(f_service_) << "public function getInputProtocol():TProtocol" << endl;
- scope_up(f_service_);
- indent(f_service_) << "return this.iprot_;" << endl;
- scope_down(f_service_);
- f_service_ << endl;
-
- indent(f_service_) << "public function getOutputProtocol():TProtocol" << endl;
- scope_up(f_service_);
- indent(f_service_) << "return this.oprot_;" << endl;
- scope_down(f_service_);
- f_service_ << endl;
- }
-
- // Generate client method implementations
- vector<t_function*> functions = tservice->get_functions();
- vector<t_function*>::const_iterator f_iter;
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- string funname = (*f_iter)->get_name();
-
- // Open function
- if (!(*f_iter)->is_oneway()) {
- if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "//function onError(Error):void;" << endl;
- indent(f_service_) << "//function onSuccess():void;" << endl;
- } else {
- indent(f_service_) << "//function onError(Error):void;" << endl;
- indent(f_service_) << "//function onSuccess(" << type_name((*f_iter)->get_returntype())
- << "):void;" << endl;
- }
- }
- indent(f_service_) << "public " << function_signature(*f_iter) << endl;
- scope_up(f_service_);
-
- // Get the struct of function call params
- t_struct* arg_struct = (*f_iter)->get_arglist();
-
- string argsname = (*f_iter)->get_name() + "_args";
- vector<t_field*>::const_iterator fld_iter;
- const vector<t_field*>& fields = arg_struct->get_members();
-
- // Serialize the request
- f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", "
- << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
- << ", seqid_));" << endl << indent() << "var args:" << argsname << " = new "
- << argsname << "();" << endl;
-
- for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
- f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = "
- << (*fld_iter)->get_name() << ";" << endl;
- }
-
- f_service_ << indent() << "args.write(oprot_);" << endl << indent()
- << "oprot_.writeMessageEnd();" << endl;
-
- if ((*f_iter)->is_oneway()) {
- f_service_ << indent() << "oprot_.getTransport().flush();" << endl;
- } else {
- f_service_ << indent() << "oprot_.getTransport().flush(function(error:Error):void {" << endl;
- indent_up();
- f_service_ << indent() << "try {" << endl;
- indent_up();
- string resultname = (*f_iter)->get_name() + "_result";
- f_service_ << indent() << "if (error != null) {" << endl << indent()
- << " if (onError != null) onError(error);" << endl << indent() << " return;"
- << endl << indent() << "}" << endl << indent()
- << "var msg:TMessage = iprot_.readMessageBegin();" << endl << indent()
- << "if (msg.type == TMessageType.EXCEPTION) {" << endl << indent()
- << " var x:TApplicationError = TApplicationError.read(iprot_);" << endl
- << indent() << " iprot_.readMessageEnd();" << endl << indent()
- << " if (onError != null) onError(x);" << endl << indent() << " return;" << endl
- << indent() << "}" << endl << indent() << "var result :" << resultname << " = new "
- << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl
- << indent() << "iprot_.readMessageEnd();" << endl;
-
- // Careful, only return _result if not a void function
- if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl
- << indent() << " if (onSuccess != null) onSuccess(result.success);" << endl
- << indent() << " return;" << endl << indent() << "}" << endl;
- }
-
- t_struct* xs = (*f_iter)->get_xceptions();
- const std::vector<t_field*>& xceptions = xs->get_members();
- vector<t_field*>::const_iterator x_iter;
- for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl
- << indent() << " if (onError != null) onError(result." << (*x_iter)->get_name()
- << ");" << endl << indent() << " return;" << endl << indent() << "}" << endl;
- }
-
- // If you get here it's an exception, unless a void function
- if ((*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if (onSuccess != null) onSuccess();" << endl << indent()
- << "return;" << endl;
- } else {
-
- f_service_ << indent() << "if (onError != null) onError(new "
- "TApplicationError(TApplicationError.MISSING_RESULT, \""
- << (*f_iter)->get_name() << " failed: unknown result\"));" << endl;
- }
- indent_down();
- f_service_ << indent() << "} catch (e:TError) {" << endl << indent()
- << " if (onError != null) onError(e);" << endl << indent() << "}" << endl;
-
- indent_down();
- indent(f_service_) << "});" << endl;
- }
- // Close function
- scope_down(f_service_);
- f_service_ << endl;
- }
-
- indent_down();
- indent(f_service_) << "}" << endl;
-}
-
-/**
- * Generates a service server definition.
- *
- * @param tservice The service to generate a server for.
- */
-void t_as3_generator::generate_service_server(t_service* tservice) {
- // Generate the dispatch methods
- vector<t_function*> functions = tservice->get_functions();
- vector<t_function*>::iterator f_iter;
-
- // Extends stuff
- string extends = "";
- string extends_processor = "";
- if (tservice->get_extends() != nullptr) {
- extends = type_name(tservice->get_extends());
- extends_processor = " extends " + extends + "Processor";
- }
-
- // Generate the header portion
- indent(f_service_) << "public class " << service_name_ << "Processor" << extends_processor
- << " implements TProcessor {" << endl;
- indent_up();
-
- indent(f_service_) << "public function " << service_name_ << "Processor(iface:" << service_name_
- << ")" << endl;
- scope_up(f_service_);
- if (!extends.empty()) {
- f_service_ << indent() << "super(iface);" << endl;
- }
- f_service_ << indent() << "iface_ = iface;" << endl;
-
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_service_ << indent() << "PROCESS_MAP[\"" << (*f_iter)->get_name()
- << "\"] = " << (*f_iter)->get_name() << "();" << endl;
- }
-
- scope_down(f_service_);
- f_service_ << endl;
-
- f_service_ << indent() << "private var iface_:" << service_name_ << ";" << endl;
-
- if (extends.empty()) {
- f_service_ << indent() << "protected const PROCESS_MAP:Dictionary = new Dictionary();" << endl;
- }
-
- f_service_ << endl;
-
- // Generate the server implementation
- string override = "";
- if (tservice->get_extends() != nullptr) {
- override = "override ";
- }
- indent(f_service_) << override
- << "public function process(iprot:TProtocol, oprot:TProtocol):Boolean" << endl;
- scope_up(f_service_);
-
- f_service_ << indent() << "var msg:TMessage = iprot.readMessageBegin();" << endl;
-
- // TODO(mcslee): validate message, was the seqid etc. legit?
- // AS- If all method is oneway:
- // do you have an oprot?
- // do you you need nullcheck?
- f_service_
- << indent() << "var fn:Function = PROCESS_MAP[msg.name];" << endl << indent()
- << "if (fn == null) {" << endl << indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);"
- << endl << indent() << " iprot.readMessageEnd();" << endl << indent()
- << " var x:TApplicationError = new TApplicationError(TApplicationError.UNKNOWN_METHOD, "
- "\"Invalid method name: '\"+msg.name+\"'\");" << endl << indent()
- << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));"
- << endl << indent() << " x.write(oprot);" << endl << indent() << " oprot.writeMessageEnd();"
- << endl << indent() << " oprot.getTransport().flush();" << endl << indent()
- << " return true;" << endl << indent() << "}" << endl << indent()
- << "fn.call(this,msg.seqid, iprot, oprot);" << endl;
-
- f_service_ << indent() << "return true;" << endl;
-
- scope_down(f_service_);
- f_service_ << endl;
-
- // Generate the process subfunctions
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- generate_process_function(tservice, *f_iter);
- }
-
- indent_down();
- indent(f_service_) << "}" << endl << endl;
-}
-
-/**
- * Generates a struct and helpers for a function.
- *
- * @param tfunction The function
- */
-void t_as3_generator::generate_function_helpers(t_function* tfunction) {
- if (tfunction->is_oneway()) {
- return;
- }
-
- t_struct result(program_, tfunction->get_name() + "_result");
- t_field success(tfunction->get_returntype(), "success", 0);
- if (!tfunction->get_returntype()->is_void()) {
- result.append(&success);
- }
-
- t_struct* xs = tfunction->get_xceptions();
- const vector<t_field*>& fields = xs->get_members();
- vector<t_field*>::const_iterator f_iter;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- result.append(*f_iter);
- }
-
- generate_as3_struct_definition(f_service_, &result, false, true, true);
-}
-
-/**
- * Generates a process function definition.
- *
- * @param tfunction The function to write a dispatcher for
- */
-void t_as3_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
- (void)tservice;
- // Open class
- indent(f_service_) << "private function " << tfunction->get_name() << "():Function {" << endl;
- indent_up();
-
- // Open function
- indent(f_service_) << "return function(seqid:int, iprot:TProtocol, oprot:TProtocol):void" << endl;
- scope_up(f_service_);
-
- string argsname = tfunction->get_name() + "_args";
- string resultname = tfunction->get_name() + "_result";
-
- f_service_ << indent() << "var args:" << argsname << " = new " << argsname << "();" << endl
- << indent() << "args.read(iprot);" << endl << indent() << "iprot.readMessageEnd();"
- << endl;
-
- t_struct* xs = tfunction->get_xceptions();
- const std::vector<t_field*>& xceptions = xs->get_members();
- vector<t_field*>::const_iterator x_iter;
-
- // Declare result for non oneway function
- if (!tfunction->is_oneway()) {
- f_service_ << indent() << "var result:" << resultname << " = new " << resultname << "();"
- << endl;
- }
-
- // Try block for a function with exceptions
- if (xceptions.size() > 0) {
- f_service_ << indent() << "try {" << endl;
- indent_up();
- }
-
- // Generate the function call
- t_struct* arg_struct = tfunction->get_arglist();
- const std::vector<t_field*>& fields = arg_struct->get_members();
- vector<t_field*>::const_iterator f_iter;
-
- f_service_ << indent();
- if (tfunction->is_oneway()) {
- f_service_ << "iface_." << tfunction->get_name() << "(";
- bool first = true;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if (first) {
- first = false;
- } else {
- f_service_ << ", ";
- }
- f_service_ << "args." << (*f_iter)->get_name();
- }
- f_service_ << ");" << endl;
- } else {
- f_service_ << "// sorry this operation is not supported yet" << endl;
- f_service_ << indent() << "throw new Error(\"This is not yet supported\");" << endl;
- }
-
- // Set isset on success field
- if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()
- && !type_can_be_null(tfunction->get_returntype())) {
- f_service_ << indent() << "result.set" << get_cap_name("success") << get_cap_name("isSet")
- << "(true);" << endl;
- }
-
- if (!tfunction->is_oneway() && xceptions.size() > 0) {
- indent_down();
- f_service_ << indent() << "}";
- for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- f_service_ << " catch (" << (*x_iter)->get_name() << ":"
- << type_name((*x_iter)->get_type(), false, false) << ") {" << endl;
- if (!tfunction->is_oneway()) {
- indent_up();
- f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
- << (*x_iter)->get_name() << ";" << endl;
- indent_down();
- f_service_ << indent() << "}";
- } else {
- f_service_ << "}";
- }
- }
- f_service_ << " catch (th:Error) {" << endl;
- indent_up();
- f_service_ << indent() << "trace(\"Internal error processing " << tfunction->get_name()
- << "\", th);" << endl << indent()
- << "var x:TApplicationError = new "
- "TApplicationError(TApplicationError.INTERNAL_ERROR, \"Internal error processing "
- << tfunction->get_name() << "\");" << endl << indent()
- << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.EXCEPTION, seqid));" << endl << indent() << "x.write(oprot);"
- << endl << indent() << "oprot.writeMessageEnd();" << endl << indent()
- << "oprot.getTransport().flush();" << endl << indent() << "return;" << endl;
- indent_down();
- f_service_ << indent() << "}" << endl;
- }
-
- // Shortcut out here for oneway functions
- if (tfunction->is_oneway()) {
- f_service_ << indent() << "return;" << endl;
- scope_down(f_service_);
-
- // Close class
- indent_down();
- f_service_ << indent() << "}" << endl << endl;
- return;
- }
-
- f_service_ << indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);"
- << endl << indent() << "oprot.writeMessageEnd();" << endl << indent()
- << "oprot.getTransport().flush();" << endl;
-
- // Close function
- scope_down(f_service_);
- f_service_ << endl;
-
- // Close class
- indent_down();
- f_service_ << indent() << "}" << endl << endl;
-}
-
-/**
- * Deserializes a field of any type.
- *
- * @param tfield The field
- * @param prefix The variable name or container for this field
- */
-void t_as3_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
- t_type* type = get_true_type(tfield->get_type());
-
- if (type->is_void()) {
- throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
- }
-
- string name = prefix + tfield->get_name();
-
- if (type->is_struct() || type->is_xception()) {
- generate_deserialize_struct(out, (t_struct*)type, name);
- } else if (type->is_container()) {
- generate_deserialize_container(out, type, name);
- } else if (type->is_base_type() || type->is_enum()) {
-
- indent(out) << name << " = iprot.";
-
- if (type->is_base_type()) {
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
- switch (tbase) {
- case t_base_type::TYPE_VOID:
- throw "compiler error: cannot serialize void field in a struct: " + name;
- break;
- case t_base_type::TYPE_STRING:
- if (type->is_binary()) {
- out << "readBinary();";
- } else {
- out << "readString();";
- }
- break;
- case t_base_type::TYPE_BOOL:
- out << "readBool();";
- break;
- case t_base_type::TYPE_I8:
- out << "readByte();";
- break;
- case t_base_type::TYPE_I16:
- out << "readI16();";
- break;
- case t_base_type::TYPE_I32:
- out << "readI32();";
- break;
- case t_base_type::TYPE_I64:
- out << "readI64();";
- break;
- case t_base_type::TYPE_DOUBLE:
- out << "readDouble();";
- break;
- default:
- throw "compiler error: no As3 name for base type " + t_base_type::t_base_name(tbase);
- }
- } else if (type->is_enum()) {
- out << "readI32();";
- }
- out << endl;
- } else {
- printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
- tfield->get_name().c_str(),
- type_name(type).c_str());
- }
-}
-
-/**
- * Generates an unserializer for a struct, invokes read()
- */
-void t_as3_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
- out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl << indent()
- << prefix << ".read(iprot);" << endl;
-}
-
-/**
- * Deserializes a container by reading its size and then iterating
- */
-void t_as3_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
- scope_up(out);
-
- string obj;
-
- if (ttype->is_map()) {
- obj = tmp("_map");
- } else if (ttype->is_set()) {
- obj = tmp("_set");
- } else if (ttype->is_list()) {
- obj = tmp("_list");
- }
-
- // Declare variables, read header
- if (ttype->is_map()) {
- indent(out) << "var " << obj << ":TMap = iprot.readMapBegin();" << endl;
- } else if (ttype->is_set()) {
- indent(out) << "var " << obj << ":TSet = iprot.readSetBegin();" << endl;
- } else if (ttype->is_list()) {
- indent(out) << "var " << obj << ":TList = iprot.readListBegin();" << endl;
- }
-
- indent(out) << prefix << " = new " << type_name(ttype, false, true)
- // size the collection correctly
- << "("
- << ");" << endl;
-
- // For loop iterates over elements
- string i = tmp("_i");
- indent(out) << "for (var " << i << ":int = 0; " << i << " < " << obj << ".size"
- << "; "
- << "++" << i << ")" << endl;
-
- scope_up(out);
-
- if (ttype->is_map()) {
- generate_deserialize_map_element(out, (t_map*)ttype, prefix);
- } else if (ttype->is_set()) {
- generate_deserialize_set_element(out, (t_set*)ttype, prefix);
- } else if (ttype->is_list()) {
- generate_deserialize_list_element(out, (t_list*)ttype, prefix);
- }
-
- scope_down(out);
-
- // Read container end
- if (ttype->is_map()) {
- indent(out) << "iprot.readMapEnd();" << endl;
- } else if (ttype->is_set()) {
- indent(out) << "iprot.readSetEnd();" << endl;
- } else if (ttype->is_list()) {
- indent(out) << "iprot.readListEnd();" << endl;
- }
-
- scope_down(out);
-}
-
-/**
- * Generates code to deserialize a map
- */
-void t_as3_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) {
- string key = tmp("_key");
- string val = tmp("_val");
- t_field fkey(tmap->get_key_type(), key);
- t_field fval(tmap->get_val_type(), val);
-
- indent(out) << declare_field(&fkey) << endl;
- indent(out) << declare_field(&fval) << endl;
-
- generate_deserialize_field(out, &fkey);
- generate_deserialize_field(out, &fval);
-
- indent(out) << prefix << "[" << key << "] = " << val << ";" << endl;
-}
-
-/**
- * Deserializes a set element
- */
-void t_as3_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
- string elem = tmp("_elem");
- t_field felem(tset->get_elem_type(), elem);
-
- indent(out) << declare_field(&felem) << endl;
-
- generate_deserialize_field(out, &felem);
-
- indent(out) << prefix << ".add(" << elem << ");" << endl;
-}
-
-/**
- * Deserializes a list element
- */
-void t_as3_generator::generate_deserialize_list_element(ostream& out,
- t_list* tlist,
- string prefix) {
- string elem = tmp("_elem");
- t_field felem(tlist->get_elem_type(), elem);
-
- indent(out) << declare_field(&felem) << endl;
-
- generate_deserialize_field(out, &felem);
-
- indent(out) << prefix << ".push(" << elem << ");" << endl;
-}
-
-/**
- * Serializes a field of any type.
- *
- * @param tfield The field to serialize
- * @param prefix Name to prepend to field name
- */
-void t_as3_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
- t_type* type = get_true_type(tfield->get_type());
-
- // Do nothing for void types
- if (type->is_void()) {
- throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
- }
-
- if (type->is_struct() || type->is_xception()) {
- generate_serialize_struct(out, (t_struct*)type, prefix + tfield->get_name());
- } else if (type->is_container()) {
- generate_serialize_container(out, type, prefix + tfield->get_name());
- } else if (type->is_base_type() || type->is_enum()) {
-
- string name = prefix + tfield->get_name();
- indent(out) << "oprot.";
-
- if (type->is_base_type()) {
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
- switch (tbase) {
- case t_base_type::TYPE_VOID:
- throw "compiler error: cannot serialize void field in a struct: " + name;
- break;
- case t_base_type::TYPE_STRING:
- if (type->is_binary()) {
- out << "writeBinary(" << name << ");";
- } else {
- out << "writeString(" << name << ");";
- }
- break;
- case t_base_type::TYPE_BOOL:
- out << "writeBool(" << name << ");";
- break;
- case t_base_type::TYPE_I8:
- out << "writeByte(" << name << ");";
- break;
- case t_base_type::TYPE_I16:
- out << "writeI16(" << name << ");";
- break;
- case t_base_type::TYPE_I32:
- out << "writeI32(" << name << ");";
- break;
- case t_base_type::TYPE_I64:
- out << "writeI64(" << name << ");";
- break;
- case t_base_type::TYPE_DOUBLE:
- out << "writeDouble(" << name << ");";
- break;
- default:
- throw "compiler error: no As3 name for base type " + t_base_type::t_base_name(tbase);
- }
- } else if (type->is_enum()) {
- out << "writeI32(" << name << ");";
- }
- out << endl;
- } else {
- printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
- prefix.c_str(),
- tfield->get_name().c_str(),
- type_name(type).c_str());
- }
-}
-
-/**
- * Serializes all the members of a struct.
- *
- * @param tstruct The struct to serialize
- * @param prefix String prefix to attach to all fields
- */
-void t_as3_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
- (void)tstruct;
- out << indent() << prefix << ".write(oprot);" << endl;
-}
-
-/**
- * Serializes a container by writing its size then the elements.
- *
- * @param ttype The type of container
- * @param prefix String prefix for fields
- */
-void t_as3_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
- scope_up(out);
-
- if (ttype->is_map()) {
- string iter = tmp("_key");
- string counter = tmp("_sizeCounter");
- indent(out) << "var " << counter << ":int = 0;" << endl;
- indent(out) << "for (var " << iter << ":* in " << prefix << ") {" << endl;
- indent(out) << " " << counter << +"++;" << endl;
- indent(out) << "}" << endl;
-
- indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type())
- << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << counter << "));"
- << endl;
- } else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type())
- << ", " << prefix << ".size));" << endl;
- } else if (ttype->is_list()) {
- indent(out) << "oprot.writeListBegin(new TList("
- << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".length));"
- << endl;
- }
-
- string iter = tmp("elem");
- if (ttype->is_map()) {
- indent(out) << "for (var " << iter << ":* in " << prefix << ")";
- } else if (ttype->is_set()) {
- indent(out) << "for each (var " << iter << ":* in " << prefix << ".toArray())";
- } else if (ttype->is_list()) {
- indent(out) << "for each (var " << iter << ":* in " << prefix << ")";
- }
-
- scope_up(out);
-
- if (ttype->is_map()) {
- generate_serialize_map_element(out, (t_map*)ttype, iter, prefix);
- } else if (ttype->is_set()) {
- generate_serialize_set_element(out, (t_set*)ttype, iter);
- } else if (ttype->is_list()) {
- generate_serialize_list_element(out, (t_list*)ttype, iter);
- }
-
- scope_down(out);
-
- if (ttype->is_map()) {
- indent(out) << "oprot.writeMapEnd();" << endl;
- } else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetEnd();" << endl;
- } else if (ttype->is_list()) {
- indent(out) << "oprot.writeListEnd();" << endl;
- }
-
- scope_down(out);
-}
-
-/**
- * Serializes the members of a map.
- */
-void t_as3_generator::generate_serialize_map_element(ostream& out,
- t_map* tmap,
- string iter,
- string map) {
- t_field kfield(tmap->get_key_type(), iter);
- generate_serialize_field(out, &kfield, "");
- t_field vfield(tmap->get_val_type(), map + "[" + iter + "]");
- generate_serialize_field(out, &vfield, "");
-}
-
-/**
- * Serializes the members of a set.
- */
-void t_as3_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
- t_field efield(tset->get_elem_type(), iter);
- generate_serialize_field(out, &efield, "");
-}
-
-/**
- * Serializes the members of a list.
- */
-void t_as3_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
- t_field efield(tlist->get_elem_type(), iter);
- generate_serialize_field(out, &efield, "");
-}
-
-/**
- * Returns a As3 type name
- *
- * @param ttype The type
- * @param container Is the type going inside a container?
- * @return As3 type name, i.e. HashMap<Key,Value>
- */
-string t_as3_generator::type_name(t_type* ttype, bool in_container, bool in_init) {
- (void)in_init;
- // In As3 typedefs are just resolved to their real type
- ttype = get_true_type(ttype);
- string prefix;
-
- if (ttype->is_base_type()) {
- return base_type_name((t_base_type*)ttype, in_container);
- } else if (ttype->is_enum()) {
- return "int";
- } else if (ttype->is_map()) {
- return "Dictionary";
- } else if (ttype->is_set()) {
- return "Set";
- } else if (ttype->is_list()) {
- return "Array";
- }
-
- // Check for namespacing
- t_program* program = ttype->get_program();
- if (program != nullptr && program != program_) {
- string package = program->get_namespace("as3");
- if (!package.empty()) {
- return package + "." + ttype->get_name();
- }
- }
-
- return ttype->get_name();
-}
-
-/**
- * Returns the AS3 type that corresponds to the thrift type.
- *
- * @param tbase The base type
- * @param container Is it going in a As3 container?
- */
-string t_as3_generator::base_type_name(t_base_type* type, bool in_container) {
- (void)in_container;
- t_base_type::t_base tbase = type->get_base();
-
- switch (tbase) {
- case t_base_type::TYPE_VOID:
- return "void";
- case t_base_type::TYPE_STRING:
- if (type->is_binary()) {
- return "ByteArray";
- } else {
- return "String";
- }
- case t_base_type::TYPE_BOOL:
- return "Boolean";
- case t_base_type::TYPE_I8:
- case t_base_type::TYPE_I16:
- case t_base_type::TYPE_I32:
- return "int";
- case t_base_type::TYPE_I64:
- throw "i64 is not yet supported in as3";
- case t_base_type::TYPE_DOUBLE:
- return "Number";
- default:
- throw "compiler error: no As3 name for base type " + t_base_type::t_base_name(tbase);
- }
-}
-
-/**
- * Declares a field, which may include initialization as necessary.
- *
- * @param ttype The type
- */
-string t_as3_generator::declare_field(t_field* tfield, bool init) {
- // TODO(mcslee): do we ever need to initialize the field?
- string result = "var " + tfield->get_name() + ":" + type_name(tfield->get_type());
- if (init) {
- t_type* ttype = get_true_type(tfield->get_type());
- if (ttype->is_base_type() && tfield->get_value() != nullptr) {
- std::ofstream dummy;
- result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
- } else if (ttype->is_base_type()) {
- t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
- switch (tbase) {
- case t_base_type::TYPE_VOID:
- throw "NO T_VOID CONSTRUCT";
- case t_base_type::TYPE_STRING:
- result += " = null";
- break;
- case t_base_type::TYPE_BOOL:
- result += " = false";
- break;
- case t_base_type::TYPE_I8:
- case t_base_type::TYPE_I16:
- case t_base_type::TYPE_I32:
- case t_base_type::TYPE_I64:
- result += " = 0";
- break;
- case t_base_type::TYPE_DOUBLE:
- result += " = (double)0";
- break;
- }
-
- } else if (ttype->is_enum()) {
- result += " = 0";
- } else if (ttype->is_container()) {
- result += " = new " + type_name(ttype, false, true) + "()";
- } else {
- result += " = new " + type_name(ttype, false, true) + "()";
- ;
- }
- }
- return result + ";";
-}
-
-/**
- * Renders a function signature of the form 'type name(args)'
- *
- * @param tfunction Function definition
- * @return String of rendered function definition
- */
-string t_as3_generator::function_signature(t_function* tfunction, string prefix) {
- std::string arguments = argument_list(tfunction->get_arglist());
- if (!tfunction->is_oneway()) {
- if (arguments != "") {
- arguments += ", ";
- }
- arguments += "onError:Function, onSuccess:Function";
- }
-
- std::string result = "function " + prefix + tfunction->get_name() + "(" + arguments + "):void";
- return result;
-}
-
-/**
- * Renders a comma separated field list, with type names
- */
-string t_as3_generator::argument_list(t_struct* tstruct) {
- string result = "";
-
- const vector<t_field*>& fields = tstruct->get_members();
- vector<t_field*>::const_iterator f_iter;
- bool first = true;
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if (first) {
- first = false;
- } else {
- result += ", ";
- }
- result += (*f_iter)->get_name() + ":" + type_name((*f_iter)->get_type());
- }
- return result;
-}
-
-/**
- * Converts the parse type to a C++ enum string for the given type.
- */
-string t_as3_generator::type_to_enum(t_type* type) {
- type = get_true_type(type);
-
- if (type->is_base_type()) {
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
- switch (tbase) {
- case t_base_type::TYPE_VOID:
- throw "NO T_VOID CONSTRUCT";
- case t_base_type::TYPE_STRING:
- return "TType.STRING";
- case t_base_type::TYPE_BOOL:
- return "TType.BOOL";
- case t_base_type::TYPE_I8:
- return "TType.BYTE";
- case t_base_type::TYPE_I16:
- return "TType.I16";
- case t_base_type::TYPE_I32:
- return "TType.I32";
- case t_base_type::TYPE_I64:
- return "TType.I64";
- case t_base_type::TYPE_DOUBLE:
- return "TType.DOUBLE";
- }
- } else if (type->is_enum()) {
- return "TType.I32";
- } else if (type->is_struct() || type->is_xception()) {
- return "TType.STRUCT";
- } else if (type->is_map()) {
- return "TType.MAP";
- } else if (type->is_set()) {
- return "TType.SET";
- } else if (type->is_list()) {
- return "TType.LIST";
- }
-
- throw "INVALID TYPE IN type_to_enum: " + type->get_name();
-}
-
-/**
- * Applies the correct style to a string based on the value of nocamel_style_
- */
-std::string t_as3_generator::get_cap_name(std::string name) {
- name[0] = toupper(name[0]);
- return name;
-}
-
-string t_as3_generator::constant_name(string name) {
- string constant_name;
-
- bool is_first = true;
- bool was_previous_char_upper = false;
- for (char character : name) {
- bool is_upper = isupper(character);
-
- if (is_upper && !is_first && !was_previous_char_upper) {
- constant_name += '_';
- }
- constant_name += toupper(character);
-
- is_first = false;
- was_previous_char_upper = is_upper;
- }
-
- return constant_name;
-}
-
-/**
- * Emits a As3Doc comment if the provided object has a doc in Thrift
- */
-void t_as3_generator::generate_as3_doc(ostream& out, t_doc* tdoc) {
- if (tdoc->has_doc()) {
- generate_docstring_comment(out, "/**\n", " * ", tdoc->get_doc(), " */\n");
- }
-}
-
-/**
- * Emits a As3Doc comment if the provided function object has a doc in Thrift
- */
-void t_as3_generator::generate_as3_doc(ostream& out, t_function* tfunction) {
- if (tfunction->has_doc()) {
- stringstream ss;
- ss << tfunction->get_doc();
- const vector<t_field*>& fields = tfunction->get_arglist()->get_members();
- vector<t_field*>::const_iterator p_iter;
- for (p_iter = fields.begin(); p_iter != fields.end(); ++p_iter) {
- t_field* p = *p_iter;
- ss << "\n@param " << p->get_name();
- if (p->has_doc()) {
- ss << " " << p->get_doc();
- }
- }
- generate_docstring_comment(out, "/**\n", " * ", ss.str(), " */\n");
- }
-}
-
-std::string t_as3_generator::generate_isset_check(t_field* field) {
- return generate_isset_check(field->get_name());
-}
-
-std::string t_as3_generator::generate_isset_check(std::string field_name) {
- return "is" + get_cap_name("set") + get_cap_name(field_name) + "()";
-}
-
-void t_as3_generator::generate_isset_set(ostream& out, t_field* field) {
- if (!type_can_be_null(field->get_type())) {
- indent(out) << "this.__isset_" << field->get_name() << " = true;" << endl;
- }
-}
-
-std::string t_as3_generator::get_enum_class_name(t_type* type) {
- string package = "";
- t_program* program = type->get_program();
- if (program != nullptr && program != program_) {
- package = program->get_namespace("as3") + ".";
- }
- return package + type->get_name();
-}
-
-THRIFT_REGISTER_GENERATOR(
- as3,
- "AS3",
- " bindable: Add [bindable] metadata to all the struct classes.\n")
diff --git a/compiler/cpp/src/thrift/generate/t_generator.cc b/compiler/cpp/src/thrift/generate/t_generator.cc
index d87af89..1c540d4 100644
--- a/compiler/cpp/src/thrift/generate/t_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_generator.cc
@@ -237,9 +237,6 @@
if ((language == "csharp") || (language == "netcore")) {
failure("The '%s' target is no longer available. Use 'netstd' instead.", language.c_str());
}
- else if (language == "as3") {
- pwarning(1, "The '%s' target is deprecated and will be removed in future Thrift versions.", language.c_str());
- }
else if (language == "hs") {
pwarning(1, "The '%s' target is deprecated and will be removed in future Thrift versions.", language.c_str());
}
diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
index 7f1bb6f..725a534 100644
--- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
@@ -2975,7 +2975,7 @@
THRIFT_REGISTER_GENERATOR(
haxe,
"Haxe",
- " callbacks Use onError()/onSuccess() callbacks for service methods (like AS3)\n"
+ " callbacks Use onError()/onSuccess() callbacks for service methods\n"
" rtti Enable @:rtti for generated classes and interfaces\n"
" buildmacro=my.macros.Class.method(args)\n"
" Add @:build macro calls to generated classes and interfaces\n")
diff --git a/compiler/cpp/tests/CMakeLists.txt b/compiler/cpp/tests/CMakeLists.txt
index 924e167..57b4c09 100644
--- a/compiler/cpp/tests/CMakeLists.txt
+++ b/compiler/cpp/tests/CMakeLists.txt
@@ -97,7 +97,6 @@
endmacro()
# The following compiler with unit tests can be enabled or disabled
-THRIFT_ADD_COMPILER(as3 "Enable compiler for ActionScript 3" OFF)
THRIFT_ADD_COMPILER(c_glib "Enable compiler for C with Glib" OFF)
THRIFT_ADD_COMPILER(cl "Enable compiler for Common LISP" OFF)
THRIFT_ADD_COMPILER(cpp "Enable compiler for C++" OFF)
diff --git a/configure.ac b/configure.ac
index 608c4aa..a70a812 100755
--- a/configure.ac
+++ b/configure.ac
@@ -116,7 +116,6 @@
have_libs=yes
if test "$enable_libs" = "no"; then
have_libs="no"
- with_as3="no"
with_cpp="no"
with_c_glib="no"
with_cl="no"
@@ -141,18 +140,6 @@
with_swift="no"
fi
-AX_THRIFT_LIB(as3, [as3], yes)
-have_as3=no
-if test "$with_as3" = "yes"; then
- if test "${FLEX_HOME+set}" = set; then
- AC_PATH_PROGS([FLEX_COMPC], [compc], "fail", [$PATH$PATH_SEPARATOR$FLEX_HOME/bin])
- if test "$FLEX_COMPC" != "fail"; then
- have_as3="yes"
- fi
- fi
-fi
-AM_CONDITIONAL(WITH_AS3, [test "$have_as3" = "yes"])
-
AX_THRIFT_LIB(cpp, [C++], yes)
have_cpp=no
if test "$with_cpp" = "yes"; then
@@ -776,7 +763,6 @@
compiler/cpp/src/Makefile
compiler/cpp/test/Makefile
lib/Makefile
- lib/as3/Makefile
lib/cl/Makefile
lib/cpp/Makefile
lib/cpp/test/Makefile
@@ -857,8 +843,6 @@
tutorial/rs/Makefile
])
-if test "$have_as3" = "yes" ; then MAYBE_AS3="as3" ; else MAYBE_AS3="" ; fi
-AC_SUBST([MAYBE_AS3])
if test "$have_cpp" = "yes" ; then MAYBE_CPP="cpp" ; else MAYBE_CPP="" ; fi
AC_SUBST([MAYBE_CPP])
if test "$have_c_glib" = "yes" ; then MAYBE_C_GLIB="c_glib" ; else MAYBE_C_GLIB="" ; fi
@@ -906,7 +890,6 @@
echo
echo "$PACKAGE $VERSION"
echo
-echo "Building ActionScript3 Library : $have_as3"
echo "Building C (GLib) Library .... : $have_c_glib"
echo "Building C++ Library ......... : $have_cpp"
echo "Building Common Lisp Library.. : $have_cl"
@@ -928,12 +911,6 @@
echo "Building Rust Library ........ : $have_rs"
echo "Building Swift Library ....... : $have_swift"
-if test "$have_as3" = "yes" ; then
- echo
- echo "ActionScript Library:"
- echo " FLEX_HOME ................. : $FLEX_HOME"
- echo " Using compc version ....... : $($FLEX_COMPC --version)"
-fi
if test "$have_c_glib" = "yes" ; then
echo
echo "C (glib):"
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5d16256..3213aff 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -20,10 +20,6 @@
SUBDIRS = json xml
PRECROSS_TARGET =
-if WITH_AS3
-SUBDIRS += as3
-endif
-
if WITH_CPP
SUBDIRS += cpp
endif
@@ -106,7 +102,6 @@
# All of the libs that don't use Automake need to go in here
# so they will end up in our release tarballs.
EXTRA_DIST = \
- as3 \
d \
dart \
delphi \
diff --git a/lib/as3/CMakeLists.txt b/lib/as3/CMakeLists.txt
deleted file mode 100644
index 999905d..0000000
--- a/lib/as3/CMakeLists.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-if (IS_ABSOLUTE "${LIB_INSTALL_DIR}")
- set(AS3_INSTALL_DIR "${LIB_INSTALL_DIR}/as3")
-else ()
- set(AS3_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/as3")
-endif ()
-
-set(PRELEASE "true")
-if (CMAKE_BUILD_TYPE MATCHES DEBUG)
- set(PRELEASE "false")
-endif ()
-
-add_custom_target(ThriftAs3 ALL
- COMMENT "Building as3 library using Gradle Wrapper"
- COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} compileFlex
- --console=plain --no-daemon
- -Prelease=${PRELEASE}
- "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
-
-# Enable publishing from CMake if the publishing information is provided
-if (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
- add_custom_target(MavenPublishAs3
- COMMENT "Publishing as3 library to Apache Maven staging"
- COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean publishMavenPublicationToMavenRepository
- --console=plain --no-daemon
- -Prelease=${PRELEASE}
- -Psign=${PRELEASE}
- "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
-endif ()
-
-# Hook the CMake install process to the results from make ALL.
-# This works best when 'make all && sudo make install/fast' is used.
-# Using slash to end the source location to avoid copying the directory path.
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/libs/
- DESTINATION ${AS3_INSTALL_DIR}
- FILES_MATCHING PATTERN "libthrift-as3.swc")
-
-if (BUILD_TESTING)
- add_test(NAME As3Test
- COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test
- --console=plain --no-daemon
- -Prelease=${PRELEASE}
- "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
- "-Pthrift.compiler=${THRIFT_COMPILER}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-endif ()
diff --git a/lib/as3/Makefile.am b/lib/as3/Makefile.am
deleted file mode 100644
index 0b3c3be..0000000
--- a/lib/as3/Makefile.am
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-all-local:
- ./gradlew $(GRADLE_OPTS) compile \
- -Prelease=true \
- --console=plain
-
-install-exec-hook:
- ./gradlew $(GRADLE_OPTS) publishToMavenLocal \
- -Prelease=true \
- --console=plain
-
-clean-local:
- ./gradlew $(GRADLE_OPTS) clean \
- -Prelease=true \
- --console=plain
- $(RM) -r .gradle
-
-check-local: $(THRIFT)
- ./gradlew $(GRADLE_OPTS) test \
- -Prelease=true \
- --console=plain
-
-maven-publish:
- ./gradlew $(GRADLE_OPTS) publishMavenPublicationToMavenRepository \
- -Prelease=true \
- -Psign=true \
- --console=plain
-
-dist-hook:
- $(RM) -r $(distdir)/.gradle/
-
-EXTRA_DIST = \
- CMakeLists.txt \
- README.md \
- build.gradle \
- coding_standards.md \
- gradle \
- gradle.properties \
- gradlew \
- gradlew.bat \
- settings.gradle \
- src
diff --git a/lib/as3/README.md b/lib/as3/README.md
deleted file mode 100644
index c14f8c7..0000000
--- a/lib/as3/README.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Apache Thrift ActionScript Library
-
-## Building
-
-We use gradle and gradlefx to build the as3 library. Unfortunately gradlefx requires
-an older version of gradle (2.5) but it still works - for now. If you use the docker
-container to do the build, the Adobe Flex SDK 4.6 is installed and the FLEX_HOME
-environment variable is configured:
-
- dev@ubuntu:~/thrift$ docker run -v $(pwd):/thrift/src:rw -it thrift/thrift-build:ubuntu-bionic /bin/bash
- root@7624b61bbf84:/thrift/src# cd lib/as3
- root@7624b61bbf84:/thrift/src/lib/as3# ./gradlew -Prelease=true compileFlex
-
- ...
-
- :compileFlex UP-TO-DATE
-
- BUILD SUCCESSFUL
-
- Total time: 10.784 secs
-
- root@7624b61bbf84:/thrift/src/lib/as3# ls -ls build/
- total 4
- 4 -rw-r--r-- 1 root root 1379 Jan 22 19:23 libthrift-as3.swc
-
-## Publishing
-
-We use a similar gradle-based signing and publishing mechanism as in the java
-library. See the java library [README.md](../java/README.md) for more details.
-
-To publish into a local .m2 repository you can mount a directory into the docker container,
-for example:
-
- dev@ubuntu:~/thrift$ docker run -v~/.m2:/root/.m2 -v $(pwd):/thrift/src:rw -it thrift/thrift-build:ubuntu-bionic /bin/bash
- root@7624b61bbf84:/thrift/src/lib/as3# ./gradlew -Prelease=true publishToMavenLocal
-
-You will find your `~/.m2` directory is now populated with a release build `swc`.
diff --git a/lib/as3/build.gradle b/lib/as3/build.gradle
deleted file mode 100644
index 7853499..0000000
--- a/lib/as3/build.gradle
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- }
- dependencies {
- classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.5.0'
- }
-}
-
-plugins {
- id 'maven-publish'
- id 'signing'
-}
-
-apply plugin: 'gradlefx'
-
-description = 'Apache Thrift ActionScript Library'
-frameworkLinkage = 'none'
-group = property('thrift.groupid')
-srcDirs = ['src']
-type = 'swc'
-
-// We use the SNAPSHOT suffix for non-release versions
-if (Boolean.parseBoolean(project.release)) {
- additionalCompilerOptions = ['-compiler.debug=false', '-compiler.strict=true']
- version = property('thrift.version')
-} else {
- additionalCompilerOptions = ['-compiler.debug=true', '-compiler.strict=true']
- version = property('thrift.version') + '-SNAPSHOT'
-}
-
-defaultTasks 'compile'
-
-// Keeping the rest of the build logic in functional named scripts for clarity
-apply from: 'gradle/publishing.gradle'
-
diff --git a/lib/as3/coding_standards.md b/lib/as3/coding_standards.md
deleted file mode 100644
index fa0390b..0000000
--- a/lib/as3/coding_standards.md
+++ /dev/null
@@ -1 +0,0 @@
-Please follow [General Coding Standards](/doc/coding_standards.md)
diff --git a/lib/as3/gradle.properties b/lib/as3/gradle.properties
deleted file mode 100644
index 28f9cd5..0000000
--- a/lib/as3/gradle.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# This file is shared currently between this Gradle build and the
-# Ant builds for fd303 and JavaScript. Keep the dotted notation for
-# the properties to minimize the changes in the dependencies.
-thrift.version=0.15.0
-thrift.groupid=org.apache.thrift
-release=false
-sign=false
-
-# Local Install paths
-install.path=/usr/local/lib
-install.javadoc.path=/usr/local/lib
-
-# Test execution properties
-testPort=9090
-
-# Maven dependency download locations
-mvn.repo=https://repo1.maven.org/maven2
-apache.repo=https://repository.apache.org/content/repositories/releases
-
-# Apache Maven publish
-license=https://www.apache.org/licenses/LICENSE-2.0.txt
-maven-repository-url=https://repository.apache.org/service/local/staging/deploy/maven2
-maven-repository-id=apache.releases.https
diff --git a/lib/as3/gradle/publishing.gradle b/lib/as3/gradle/publishing.gradle
deleted file mode 100644
index 3e0ecf3..0000000
--- a/lib/as3/gradle/publishing.gradle
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// Following Gradle best practices to keep build logic organized
-
-model {
- tasks.signMavenPublication {
- dependsOn compileFlex
- }
-}
-
-publishing {
- publications {
- maven(MavenPublication) {
-
- groupId = "$group"
- artifactId = "${project.name}"
- version = "$version"
-
- def swcFile = file("$buildDir/libthrift-as3.swc")
- artifact(swcFile)
-
- pom {
- description = 'Thrift is a software framework for scalable cross-language services development.'
- packaging = 'swc'
-
- // older gradle doesn't recognize all the properties, so we inject them..
- withXml {
- asNode().with {
- appendNode('name', 'Apache Thrift')
- appendNode('url', 'http://thrift.apache.org/')
- appendNode('scm').with {
- appendNode('url', 'https://github.com/apache/thrift/')
- appendNode('connection', 'scm:git:https://github.com/apache/thrift.git')
- appendNode('developerConnection', 'scm:git:git@github.com:apache/thrift.git')
- }
- appendNode('issueManagement').with {
- appendNode('url', 'https://issues.apache.org/jira/projects/THRIFT/')
- appendNode('system', 'Jira')
- }
- appendNode('licenses').with {
- appendNode('license').with {
- appendNode('name', 'The Apache Software License, Version 2.0')
- appendNode('url', "${project.license}")
- }
- }
- appendNode('organization').with {
- appendNode('name', 'The Apache Software Foundation')
- appendNode('url', 'http://www.apache.org/')
- }
- appendNode('developers').with {
- appendNode('developer').with {
- appendNode('id', 'dev')
- appendNode('name', 'Apache Thrift Developers')
- appendNode('email', 'dev@thrift.apache.org')
- }
- }
- }
- }
- }
- }
- }
- repositories {
- maven {
- url = property('maven-repository-url')
-
- if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) {
- credentials {
- username = property('mavenUser')
- password = property('mavenPassword')
- }
- }
- }
- }
-}
-
-signing {
- required { property('sign') }
- sign publishing.publications.maven
-}
diff --git a/lib/as3/gradle/wrapper/gradle-wrapper.jar b/lib/as3/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 87b738c..0000000
--- a/lib/as3/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/lib/as3/gradle/wrapper/gradle-wrapper.properties b/lib/as3/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 5028f28..0000000
--- a/lib/as3/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/lib/as3/gradlew b/lib/as3/gradlew
deleted file mode 100755
index af6708f..0000000
--- a/lib/as3/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/lib/as3/gradlew.bat b/lib/as3/gradlew.bat
deleted file mode 100644
index 9618d8d..0000000
--- a/lib/as3/gradlew.bat
+++ /dev/null
@@ -1,100 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/lib/as3/settings.gradle b/lib/as3/settings.gradle
deleted file mode 100644
index 4932346..0000000
--- a/lib/as3/settings.gradle
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-rootProject.name = 'libthrift-as3'
diff --git a/lib/as3/src/org/apache/thrift/AbstractMethodError.as b/lib/as3/src/org/apache/thrift/AbstractMethodError.as
deleted file mode 100644
index a2082b8..0000000
--- a/lib/as3/src/org/apache/thrift/AbstractMethodError.as
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift {
-
- import flash.errors.IllegalOperationError;
-
- public class AbstractMethodError extends IllegalOperationError {
-
- public function AbstractMethodError(message:String="") {
- super("Attempt to call an abstract method");
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/Set.as b/lib/as3/src/org/apache/thrift/Set.as
deleted file mode 100644
index ae5f428..0000000
--- a/lib/as3/src/org/apache/thrift/Set.as
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift {
- import flash.utils.Dictionary;
-
-
- public class Set {
-
- private var _elements:Dictionary = new Dictionary();
- private var _size:int = 0;
-
- public function Set(... values) {
- for each (var value:* in values) {
- add(value);
- }
- }
-
- public function add(o:*):Boolean {
- var alreadyPresent:Boolean = _elements.hasOwnProperty(o);
- if (! alreadyPresent) {
- _size++;
- _elements[o] = true;
- }
-
- return ! alreadyPresent;
- }
-
- public function clear():void {
- for (var value:* in _elements) {
- remove(value);
- }
- }
-
- public function contains(o:Object):Boolean {
- return _elements.hasOwnProperty(o);
- }
-
- public function isEmpty():Boolean {
- return _size == 0;
- }
-
- public function remove(o:*):Boolean {
- if (contains(o)) {
- delete _elements[o];
- _size--;
- return true;
- }
- else {
- return false;
- }
- }
-
- public function toArray():Array {
- var ret:Array = new Array();
- for (var key:* in _elements) {
- ret.push(key);
- }
- return ret;
- }
-
- public function get size():int {
- return _size;
- }
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/TApplicationError.as b/lib/as3/src/org/apache/thrift/TApplicationError.as
deleted file mode 100644
index 3448fce..0000000
--- a/lib/as3/src/org/apache/thrift/TApplicationError.as
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift {
-
- import org.apache.thrift.protocol.TField;
- import org.apache.thrift.protocol.TProtocol;
- import org.apache.thrift.protocol.TProtocolUtil;
- import org.apache.thrift.protocol.TStruct;
- import org.apache.thrift.protocol.TType;
-
- /**
- * Application level exception
- */
- public class TApplicationError extends TError {
-
- private static const TAPPLICATION_EXCEPTION_STRUCT:TStruct = new TStruct("TApplicationException");
- private static const MESSAGE_FIELD:TField = new TField("message", TType.STRING, 1);
- private static const TYPE_FIELD:TField = new TField("type", TType.I32, 2);
-
- public static const UNKNOWN:int = 0;
- public static const UNKNOWN_METHOD:int = 1;
- public static const INVALID_MESSAGE_TYPE:int = 2;
- public static const WRONG_METHOD_NAME:int = 3;
- public static const BAD_SEQUENCE_ID:int = 4;
- public static const MISSING_RESULT:int = 5;
- public static const INTERNAL_ERROR:int = 6;
- public static const PROTOCOL_ERROR:int = 7;
- public static const INVALID_TRANSFORM:int = 8;
- public static const INVALID_PROTOCOL:int = 9;
- public static const UNSUPPORTED_CLIENT_TYPE:int = 10;
-
- public function TApplicationError(type:int = UNKNOWN, message:String = "") {
- super(message, type);
- }
-
- public static function read(iprot:TProtocol):TApplicationError {
- var field:TField;
- iprot.readStructBegin();
-
- var message:String = null;
- var type:int = UNKNOWN;
-
- while (true) {
- field = iprot.readFieldBegin();
- if (field.type == TType.STOP) {
- break;
- }
- switch (field.id) {
- case 1:
- if (field.type == TType.STRING) {
- message = iprot.readString();
- }
- else {
- TProtocolUtil.skip(iprot, field.type);
- }
- break;
- case 2:
- if (field.type == TType.I32) {
- type = iprot.readI32();
- }
- else {
- TProtocolUtil.skip(iprot, field.type);
- }
- break;
- default:
- TProtocolUtil.skip(iprot, field.type);
- break;
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
- return new TApplicationError(type, message);
- }
-
- public function write(oprot:TProtocol):void {
- oprot.writeStructBegin(TAPPLICATION_EXCEPTION_STRUCT);
- if (message != null) {
- oprot.writeFieldBegin(MESSAGE_FIELD);
- oprot.writeString(message);
- oprot.writeFieldEnd();
- }
- oprot.writeFieldBegin(TYPE_FIELD);
- oprot.writeI32(errorID);
- oprot.writeFieldEnd();
- oprot.writeFieldStop();
- oprot.writeStructEnd();
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/TBase.as b/lib/as3/src/org/apache/thrift/TBase.as
deleted file mode 100644
index 615db1d..0000000
--- a/lib/as3/src/org/apache/thrift/TBase.as
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift {
-
- import org.apache.thrift.protocol.TProtocol;
-
- /**
- * Generic base interface for generated Thrift objects.
- *
- */
- public interface TBase {
-
- /**
- * Reads the TObject from the given input protocol.
- *
- * @param iprot Input protocol
- */
- function read(iprot:TProtocol):void;
-
- /**
- * Writes the objects out to the protocol
- *
- * @param oprot Output protocol
- */
- function write(oprot:TProtocol):void;
-
- /**
- * Check if a field is currently set or unset.
- *
- * @param fieldId The field's id tag as found in the IDL.
- */
- function isSet(fieldId:int):Boolean;
-
- /**
- * Get a field's value by id. Primitive types will be wrapped in the
- * appropriate "boxed" types.
- *
- * @param fieldId The field's id tag as found in the IDL.
- */
- function getFieldValue(fieldId:int):*;
-
- /**
- * Set a field's value by id. Primitive types must be "boxed" in the
- * appropriate object wrapper type.
- *
- * @param fieldId The field's id tag as found in the IDL.
- */
- function setFieldValue(fieldId:int, value:*):void;
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/TError.as b/lib/as3/src/org/apache/thrift/TError.as
deleted file mode 100644
index ccc13b5..0000000
--- a/lib/as3/src/org/apache/thrift/TError.as
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift {
-
- public class TError extends Error {
-
- public function TError(message:String = "", errorCode:int = 0) {
- super(message, errorCode);
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/TFieldRequirementType.as b/lib/as3/src/org/apache/thrift/TFieldRequirementType.as
deleted file mode 100644
index 6fb4e58..0000000
--- a/lib/as3/src/org/apache/thrift/TFieldRequirementType.as
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift {
-
- /**
- * Requirement type constants.
- *
- */
- public class TFieldRequirementType {
- public static const REQUIRED:int = 1;
- public static const OPTIONAL:int = 2;
- public static const DEFAULT:int = 3;
- }
-
-}
diff --git a/lib/as3/src/org/apache/thrift/TProcessor.as b/lib/as3/src/org/apache/thrift/TProcessor.as
deleted file mode 100644
index 850acc9..0000000
--- a/lib/as3/src/org/apache/thrift/TProcessor.as
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
- package org.apache.thrift {
-
-import org.apache.thrift.protocol.TProtocol;
-
- /**
- * A processor is a generic object which operates upon an input stream and
- * writes to some output stream.
- *
- */
- public interface TProcessor {
- function process(input:TProtocol, output:TProtocol):Boolean;
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as b/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as
deleted file mode 100644
index cb18a14..0000000
--- a/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data {
-
- import flash.utils.Dictionary;
-
- /**
- * This class is used to store meta data about thrift fields. Every field in a
- * a struct should have a corresponding instance of this class describing it.
- *
- */
- public class FieldMetaData {
-
- public var fieldName:String;
- public var requirementType:int;
- public var valueMetaData:FieldValueMetaData;
-
- private static var structMap:Dictionary = new Dictionary();
-
- public function FieldMetaData(name:String, req:int, vMetaData:FieldValueMetaData) {
- this.fieldName = name;
- this.requirementType = req;
- this.valueMetaData = vMetaData;
- }
-
- public static function addStructMetaDataMap(sClass:Class, map:Dictionary):void{
- structMap[sClass] = map;
- }
-
- /**
- * Returns a map with metadata (i.e. instances of FieldMetaData) that
- * describe the fields of the given class.
- *
- * @param sClass The TBase class for which the metadata map is requested
- */
- public static function getStructMetaDataMap(sClass:Class):Dictionary {
- return structMap[sClass];
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as b/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as
deleted file mode 100644
index 07fe1be..0000000
--- a/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data {
-
- import org.apache.thrift.protocol.TType;
-
- /**
- * FieldValueMetaData and collection of subclasses to store metadata about
- * the value(s) of a field
- */
- public class FieldValueMetaData {
-
- public var type:int;
-
- public function FieldValueMetaData(type:int) {
- this.type = type;
- }
-
- public function isStruct():Boolean {
- return type == TType.STRUCT;
- }
-
- public function isContainer():Boolean {
- return type == TType.LIST || type == TType.MAP || type == TType.SET;
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as b/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as
deleted file mode 100644
index a2cc732..0000000
--- a/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data {
-
- public class ListMetaData extends FieldValueMetaData {
-
- public var elemMetaData:FieldValueMetaData;
-
- public function ListMetaData(type:int, eMetaData:FieldValueMetaData) {
- super(type);
- this.elemMetaData = eMetaData;
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as b/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as
deleted file mode 100644
index e7f1f9f..0000000
--- a/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data {
-
- public class MapMetaData extends FieldValueMetaData {
-
- public var keyMetaData:FieldValueMetaData;
- public var valueMetaData:FieldValueMetaData;
-
- public function MapMetaData(type:int, kMetaData:FieldValueMetaData, vMetaData:FieldValueMetaData) {
- super(type);
- this.keyMetaData = kMetaData;
- this.valueMetaData = vMetaData;
- }
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as b/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as
deleted file mode 100644
index 390f034..0000000
--- a/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data {
-
- public class SetMetaData extends FieldValueMetaData {
-
- public var elemMetaData:FieldValueMetaData;
-
- public function SetMetaData(type:int, eMetaData:FieldValueMetaData) {
- super(type);
- this.elemMetaData = eMetaData;
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as b/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as
deleted file mode 100644
index fc9b0be..0000000
--- a/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.meta_data {
-
- public class StructMetaData extends FieldValueMetaData {
-
- public var structClass:Class;
-
- public function StructMetaData(type:int, sClass:Class) {
- super(type);
- this.structClass = sClass;
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as b/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as
deleted file mode 100644
index b2ff9d8..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- import flash.utils.ByteArray;
-
- import org.apache.thrift.TError;
- import org.apache.thrift.transport.THttpClient;
- import org.apache.thrift.transport.TTransport;
-
- /**
- * Binary protocol implementation for thrift.
- */
- public class TBinaryProtocol implements TProtocol {
-
- private static var ANONYMOUS_STRUCT:TStruct = new TStruct();
-
- protected static const VERSION_MASK:int = int(0xffff0000);
- protected static const VERSION_1:int = int(0x80010000);
-
- protected var strictRead_:Boolean = false;
- protected var strictWrite_:Boolean = true;
-
- /**
- * Factory
- */
- /*
- public static class Factory implements TProtocolFactory {
- protected boolean strictRead_ = false;
- protected boolean strictWrite_ = true;
-
- public Factory() {
- this(false, true);
- }
-
- public Factory(boolean strictRead, boolean strictWrite) {
- strictRead_ = strictRead;
- strictWrite_ = strictWrite;
- }
-
- public TProtocol getProtocol(TTransport trans) {
- return new TBinaryProtocol(trans, strictRead_, strictWrite_);
- }
- }
- */
-
- private var trans_:TTransport;
-
- /**
- * Constructor
- */
- public function TBinaryProtocol(trans:TTransport, strictRead:Boolean=false, strictWrite:Boolean=true) {
- trans_ = trans;
- strictRead_ = strictRead;
- strictWrite_ = strictWrite;
- }
-
- public function getTransport():TTransport {
- return trans_;
- }
-
- public function writeMessageBegin(message:TMessage):void {
- if (strictWrite_) {
- var version:int = VERSION_1 | message.type;
- writeI32(version);
- writeString(message.name);
- writeI32(message.seqid);
- } else {
- writeString(message.name);
- writeByte(message.type);
- writeI32(message.seqid);
- }
- }
-
- public function writeMessageEnd():void {}
-
- public function writeStructBegin(struct:TStruct):void {}
-
- public function writeStructEnd():void {}
-
- public function writeFieldBegin(field:TField):void {
- writeByte(field.type);
- writeI16(field.id);
- }
-
- public function writeFieldEnd():void {}
-
- public function writeFieldStop():void {
- writeByte(TType.STOP);
- }
-
- public function writeMapBegin(map:TMap):void {
- writeByte(map.keyType);
- writeByte(map.valueType);
- writeI32(map.size);
- }
-
- public function writeMapEnd():void {}
-
- public function writeListBegin(list:TList):void {
- writeByte(list.elemType);
- writeI32(list.size);
- }
-
- public function writeListEnd():void {}
-
- public function writeSetBegin(set:TSet):void {
- writeByte(set.elemType);
- writeI32(set.size);
- }
-
- public function writeSetEnd():void {}
-
- public function writeBool(b:Boolean):void {
- writeByte(b ? 1 : 0);
- }
-
- private var out:ByteArray = new ByteArray();
- public function writeByte(b:int):void {
- reset(out);
- out.writeByte(b);
- trans_.write(out, 0, 1);
- }
-
- public function writeI16(i16:int):void {
- reset(out);
- out.writeShort(i16);
- trans_.write(out, 0, 2);
- }
-
- public function writeI32(i32:int):void {
- reset(out);
- out.writeInt(i32);
- trans_.write(out, 0, 4);
- }
-
- //private byte[] i64out = new byte[8];
- //public function writeI64(i64:Number):void {
- //i64out[0] = (byte)(0xff & (i64 >> 56));
- //i64out[1] = (byte)(0xff & (i64 >> 48));
- //i64out[2] = (byte)(0xff & (i64 >> 40));
- //i64out[3] = (byte)(0xff & (i64 >> 32));
- //i64out[4] = (byte)(0xff & (i64 >> 24));
- //i64out[5] = (byte)(0xff & (i64 >> 16));
- //i64out[6] = (byte)(0xff & (i64 >> 8));
- //i64out[7] = (byte)(0xff & (i64));
- //trans_.write(i64out, 0, 8);
- //}
-
- public function writeDouble(dub:Number):void {
- reset(out);
- out.writeDouble(dub);
- trans_.write(out, 0, 8);
- }
-
- private var stringOut:ByteArray = new ByteArray();
-
- public function writeString(str:String):void {
- reset(stringOut);
- stringOut.writeUTFBytes(str);
-
- writeI32(stringOut.length);
- trans_.write(stringOut, 0, stringOut.length);
- }
-
- public function writeBinary(bin:ByteArray):void {
- writeI32(bin.length);
- trans_.write(bin, 0, bin.length);
- }
-
- /**
- * Reading methods.
- */
-
- public function readMessageBegin():TMessage {
- var size:int = readI32();
- if (size < 0) {
- var version:int = size & VERSION_MASK;
- if (version != VERSION_1) {
- throw new TProtocolError(TProtocolError.BAD_VERSION, "Bad version in readMessageBegin");
- }
- return new TMessage(readString(), size & 0x000000ff, readI32());
- }
- else {
- if (strictRead_) {
- throw new TProtocolError(TProtocolError.BAD_VERSION, "Missing version in readMessageBegin, old client?");
- }
- return new TMessage(readStringBody(size), readByte(), readI32());
- }
- }
-
- public function readMessageEnd():void {}
-
- public function readStructBegin():TStruct {
- return ANONYMOUS_STRUCT;
- }
-
- public function readStructEnd():void {}
-
- public function readFieldBegin():TField {
- var type:int = readByte();
- var id:int = type == TType.STOP ? 0 : readI16();
- return new TField("", type, id);
- }
-
- public function readFieldEnd():void {}
-
- public function readMapBegin():TMap {
- return new TMap(readByte(), readByte(), readI32());
- }
-
- public function readMapEnd():void {}
-
- public function readListBegin():TList {
- return new TList(readByte(), readI32());
- }
-
- public function readListEnd():void {}
-
- public function readSetBegin():TSet {
- return new TSet(readByte(), readI32());
- }
-
- public function readSetEnd():void {}
-
- public function readBool():Boolean {
- return (readByte() == 1);
- }
-
- private var bytes:ByteArray = new ByteArray();
-
- public function readByte():int {
- readAll(1);
- return bytes.readByte();
- }
-
- public function readI16():int {
- readAll(2);
- return bytes.readShort();
- }
-
- public function readI32():int {
- readAll(4);
- return bytes.readInt();
- }
-
- //private byte[] i64rd = new byte[8];
- /*
- public function readI64() throws TException {
- readAll(i64rd, 0, 8);
- return
- ((long)(i64rd[0] & 0xff) << 56) |
- ((long)(i64rd[1] & 0xff) << 48) |
- ((long)(i64rd[2] & 0xff) << 40) |
- ((long)(i64rd[3] & 0xff) << 32) |
- ((long)(i64rd[4] & 0xff) << 24) |
- ((long)(i64rd[5] & 0xff) << 16) |
- ((long)(i64rd[6] & 0xff) << 8) |
- ((long)(i64rd[7] & 0xff));
- }
- */
-
- public function readDouble():Number {
- readAll(8);
- return bytes.readDouble();
- }
-
- public function readString():String {
- var size:int = readI32();
- readAll(size);
- return bytes.readUTFBytes(size);
- }
-
- public function readStringBody(size:int):String {
- readAll(size);
- return bytes.readUTFBytes(size);
- }
-
- public function readBinary():ByteArray {
- var size:int = readI32();
- var buf:ByteArray = new ByteArray();
- trans_.readAll(buf, 0, size);
- return buf;
- }
-
- private function readAll(len:int):void {
- reset(bytes);
-
- trans_.readAll(bytes, 0, len);
-
- bytes.position = 0;
- }
-
- private static function reset(arr:ByteArray):void {
- arr.length = 0;
- arr.position = 0;
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/protocol/TField.as b/lib/as3/src/org/apache/thrift/protocol/TField.as
deleted file mode 100644
index 1277f3a..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TField.as
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TField {
-
- public var name:String;
- public var type:int;
- public var id:int;
-
- public function TField(n:String = "", t:int = 0, i:int = 0) {
- name = n;
- type = t;
- id = i;
- }
-
- public function toString():String {
- return "<TField name:'" + name + "' type:" + type + " field-id:" + id + ">";
- }
-
- public function equals(otherField:TField):Boolean {
- return type == otherField.type && id == otherField.id;
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TList.as b/lib/as3/src/org/apache/thrift/protocol/TList.as
deleted file mode 100644
index f0bdbad..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TList.as
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TList {
-
- public var elemType:int;
- public var size:int;
-
- public function TList(t:int = 0, s:int = 0) {
- elemType = t;
- size = s;
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TMap.as b/lib/as3/src/org/apache/thrift/protocol/TMap.as
deleted file mode 100644
index 2298804..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TMap.as
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
- public class TMap {
-
- public var keyType:int;
- public var valueType:int;
- public var size:int;
-
- public function TMap(k:int = 0, v:int = 0, s:int = 0) {
- keyType = k;
- valueType = v;
- size = s;
- }
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TMessage.as b/lib/as3/src/org/apache/thrift/protocol/TMessage.as
deleted file mode 100644
index 9817235..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TMessage.as
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TMessage {
-
- public var name:String;
- public var type:int;
- public var seqid:int;
-
- public function TMessage(n:String = "", t:int = 0, s:int = 0) {
- name = n;
- type = t;
- seqid = s;
- }
-
- public function toString():String {
- return "<TMessage name:'" + name + "' type: " + type + " seqid:" + seqid + ">";
- }
-
- public function equals(other:TMessage):Boolean {
- return name == other.name && type == other.type && seqid == other.seqid;
- }
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TMessageType.as b/lib/as3/src/org/apache/thrift/protocol/TMessageType.as
deleted file mode 100644
index 56a9ba5..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TMessageType.as
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TMessageType {
- public static const CALL:int = 1;
- public static const REPLY:int = 2;
- public static const EXCEPTION:int = 3;
- public static const ONEWAY:int = 4;
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TProtocol.as b/lib/as3/src/org/apache/thrift/protocol/TProtocol.as
deleted file mode 100644
index bb9d744..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TProtocol.as
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- import org.apache.thrift.TError;
- import org.apache.thrift.transport.TTransport;
-
- import flash.utils.ByteArray;
-
- /**
- * Protocol interface definition
- */
- public interface TProtocol {
-
- function TProtocol(trans:TTransport);
-
- function getTransport():TTransport;
-
- /**
- * Writing methods.
- */
- function writeMessageBegin(message:TMessage):void;
-
- function writeMessageEnd():void;
-
- function writeStructBegin(struct:TStruct):void;
-
- function writeStructEnd():void;
-
- function writeFieldBegin(field:TField):void;
-
- function writeFieldEnd():void;
-
- function writeFieldStop():void;
-
- function writeMapBegin(map:TMap):void;
-
- function writeMapEnd():void;
-
- function writeListBegin(list:TList):void;
-
- function writeListEnd():void;
-
- function writeSetBegin(set:TSet):void;
-
- function writeSetEnd():void;
-
- function writeBool(b:Boolean):void;
-
- function writeByte(b:int):void;
-
- function writeI16(i16:int):void;
-
- function writeI32(i32:int):void;
-
- //function writeI64(i64:Number):void;
-
- function writeDouble(dub:Number):void;
-
- function writeString(str:String):void;
-
- function writeBinary(bin:ByteArray):void;
-
- /**
- * Reading methods.
- */
- function readMessageBegin():TMessage;
-
- function readMessageEnd():void;
-
- function readStructBegin():TStruct;
-
- function readStructEnd():void;
-
- function readFieldBegin():TField;
-
- function readFieldEnd():void;
-
- function readMapBegin():TMap;
-
- function readMapEnd():void;
-
- function readListBegin():TList;
-
- function readListEnd():void;
-
- function readSetBegin():TSet;
-
- function readSetEnd():void;
-
- function readBool():Boolean;
-
- function readByte():int;
-
- function readI16():int;
-
- function readI32():int;
-
- //function readI64():Number;
-
- function readDouble():Number;
-
- function readString():String;
-
- function readBinary():ByteArray;
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as b/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as
deleted file mode 100644
index 9fff730..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- import org.apache.thrift.TError;
-
- public class TProtocolError extends TError {
-
- public static const UNKNOWN:int = 0;
- public static const INVALID_DATA:int = 1;
- public static const NEGATIVE_SIZE:int = 2;
- public static const SIZE_LIMIT:int = 3;
- public static const BAD_VERSION:int = 4;
- public static const NOT_IMPLEMENTED:int = 5;
- public static const DEPTH_LIMIT:int = 6;
-
- public function TProtocolError(error:int = UNKNOWN, message:String = "") {
- super(message, error);
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as b/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as
deleted file mode 100644
index c7f5e29..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- import org.apache.thrift.transport.TTransport;
-
- public interface TProtocolFactory {
- function getProtocol(trans:TTransport):TProtocol;
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as b/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as
deleted file mode 100644
index 22877b7..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- import org.apache.thrift.TError;
-
- /**
- * Utility class with static methods for interacting with protocol data
- * streams.
- *
- */
- public class TProtocolUtil {
-
- /**
- * The maximum recursive depth the skip() function will traverse before
- * throwing a TException.
- */
- private static var maxSkipDepth:int = int.MAX_VALUE;
-
- /**
- * Specifies the maximum recursive depth that the skip function will
- * traverse before throwing a TException. This is a global setting, so
- * any call to skip in this JVM will enforce this value.
- *
- * @param depth the maximum recursive depth. A value of 2 would allow
- * the skip function to skip a structure or collection with basic children,
- * but it would not permit skipping a struct that had a field containing
- * a child struct. A value of 1 would only allow skipping of simple
- * types and empty structs/collections.
- */
- public function setMaxSkipDepth(depth:int):void {
- maxSkipDepth = depth;
- }
-
- /**
- * Skips over the next data element from the provided input TProtocol object.
- *
- * @param prot the protocol object to read from
- * @param type the next value will be intepreted as this TType value.
- */
- public static function skip(prot:TProtocol, type:int):void {
- skipMaxDepth(prot, type, maxSkipDepth);
- }
-
- /**
- * Skips over the next data element from the provided input TProtocol object.
- *
- * @param prot the protocol object to read from
- * @param type the next value will be intepreted as this TType value.
- * @param maxDepth this function will only skip complex objects to this
- * recursive depth, to prevent Java stack overflow.
- */
- public static function skipMaxDepth(prot:TProtocol, type:int, maxDepth:int):void {
- if (maxDepth <= 0) {
- throw new TError("Maximum skip depth exceeded");
- }
- switch (type) {
- case TType.BOOL: {
- prot.readBool();
- break;
- }
- case TType.BYTE: {
- prot.readByte();
- break;
- }
- case TType.I16: {
- prot.readI16();
- break;
- }
- case TType.I32: {
- prot.readI32();
- break;
- }
- /*
- case TType.I64: {
- prot.readI64();
- break;
- }
- */
- case TType.DOUBLE: {
- prot.readDouble();
- break;
- }
- case TType.STRING: {
- prot.readBinary();
- break;
- }
- case TType.STRUCT: {
- prot.readStructBegin();
- while (true) {
- var field:TField = prot.readFieldBegin();
- if (field.type == TType.STOP) {
- break;
- }
- skipMaxDepth(prot, field.type, maxDepth - 1);
- prot.readFieldEnd();
- }
- prot.readStructEnd();
- break;
- }
- case TType.MAP: {
- var map:TMap = prot.readMapBegin();
- for (var i:int = 0; i < map.size; i++) {
- skipMaxDepth(prot, map.keyType, maxDepth - 1);
- skipMaxDepth(prot, map.valueType, maxDepth - 1);
- }
- prot.readMapEnd();
- break;
- }
- case TType.SET: {
- var set:TSet = prot.readSetBegin();
- for (var j:int = 0; j < set.size; j++) {
- skipMaxDepth(prot, set.elemType, maxDepth - 1);
- }
- prot.readSetEnd();
- break;
- }
- case TType.LIST: {
- var list:TList = prot.readListBegin();
- for (var k:int = 0; k < list.size; k++) {
- skipMaxDepth(prot, list.elemType, maxDepth - 1);
- }
- prot.readListEnd();
- break;
- }
- default:
- throw new TProtocolError(TProtocolError.INVALID_DATA, "invalid data");
- }
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/protocol/TSet.as b/lib/as3/src/org/apache/thrift/protocol/TSet.as
deleted file mode 100644
index 3f0e1a6..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TSet.as
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TSet {
-
- public var elemType:int;
- public var size:int;
-
- public function TSet(t:int = 0, s:int = 0) {
- elemType = t;
- size = s;
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TStruct.as b/lib/as3/src/org/apache/thrift/protocol/TStruct.as
deleted file mode 100644
index dffad79..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TStruct.as
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TStruct {
-
- public var name:String;
-
- public function TStruct(n:String = "") {
- name = n;
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/protocol/TType.as b/lib/as3/src/org/apache/thrift/protocol/TType.as
deleted file mode 100644
index 69af208..0000000
--- a/lib/as3/src/org/apache/thrift/protocol/TType.as
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.protocol {
-
- public class TType {
-
- public static const STOP:int = 0;
- public static const VOID:int = 1;
- public static const BOOL:int = 2;
- public static const BYTE:int = 3;
- public static const DOUBLE:int = 4;
- public static const I16:int = 6;
- public static const I32:int = 8;
- public static const I64:int = 10;
- public static const STRING:int = 11;
- public static const STRUCT:int = 12;
- public static const MAP:int = 13;
- public static const SET:int = 14;
- public static const LIST:int = 15;
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as b/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as
deleted file mode 100644
index 863c59b..0000000
--- a/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.transport
-{
-
- import flash.errors.EOFError;
- import flash.events.Event;
- import flash.events.IOErrorEvent;
- import flash.events.ProgressEvent;
- import flash.events.SecurityErrorEvent;
- import flash.net.URLLoader;
- import flash.net.URLLoaderDataFormat;
- import flash.net.URLRequest;
- import flash.net.URLRequestMethod;
- import flash.utils.IDataInput;
- import flash.utils.IDataOutput;
- import flash.utils.ByteArray;
- import flash.net.Socket;
- import flash.events.EventDispatcher;
-
-
- /**
- * HTTP implementation of the TTransport interface. Used for working with a
- * Thrift web services implementation.
- * Unlike Http Client, it uses a single POST, and chunk-encoding to transfer all messages.
- */
-
- public class TFullDuplexHttpClient extends TTransport
- {
- private var socket:Socket = null;
-
- private var host:String;
-
- private var port:int;
-
- private var resource:String;
-
- private var stripped:Boolean = false;
-
- private var obuffer:ByteArray = new ByteArray();
-
- private var input:IDataInput;
-
- private var output:IDataOutput;
-
- private var bytesInChunk:int = 0;
-
- private var CRLF:ByteArray = new ByteArray();
-
- private var ioCallback:Function = null;
-
- private var eventDispatcher:EventDispatcher = new EventDispatcher();
-
- public function TFullDuplexHttpClient(host:String, port:int, resource:String):void
- {
- CRLF.writeByte(13);
- CRLF.writeByte(10);
- this.host = host;
- this.port = port;
- this.resource = resource;
- }
-
- public override function close():void
- {
- this.input = null;
- this.output = null;
- this.stripped = false;
- socket.close()
- }
-
- public override function peek():Boolean
- {
- if(socket.connected)
- {
- trace("Bytes remained:" + socket.bytesAvailable);
- return socket.bytesAvailable>0;
- }
- return false;
- }
-
- public override function read(buf:ByteArray, off:int, len:int):int
- {
- var n1:int = 0, n2:int = 0, n3:int = 0, n4:int = 0, cidx:int = 2;
- var chunkSize:ByteArray = new ByteArray();
-
- try
- {
- while (!stripped)
- {
- n1 = n2;
- n2 = n3;
- n3 = n4;
- n4 = input.readByte();
- if ((n1 == 13) && (n2 == 10) && (n3 == 13) && (n4 == 10))
- {
- stripped = true;
- }
- }
-
- // read chunk size
- if (bytesInChunk == 0)
- {
- n1 = input.readByte();
- n2 = input.readByte();
-
- chunkSize.writeByte(n1);
- chunkSize.writeByte(n2);
-
- while (!((n1 == 13) && (n2 == 10)))
- {
- n1 = n2;
- n2 = input.readByte();
- chunkSize.writeByte(n2);
- }
-
- bytesInChunk = parseInt(chunkSize.toString(), 16);
- }
-
- input.readBytes(buf, off, len);
- debugBuffer(buf);
- bytesInChunk -= len;
-
- if (bytesInChunk == 0)
- {
- // advance the : "\r\n"
- input.readUTFBytes(2);
- }
- return len;
- }
- catch (e:EOFError)
- {
- trace(e);
- throw new TTransportError(TTransportError.UNKNOWN, "No more data available.");
- }
- catch (e:Error)
- {
- trace(e);
- // WTF??
- throw new TTransportError(TTransportError.UNKNOWN, "Bad IO error:" + e);
- }
- return 0;
- }
-
- public function debugBuffer(buf:ByteArray):void
- {
- var debug:String = "BUFFER >>";
- var i:int;
- for (i = 0; i < buf.length; i++)
- {
- debug += buf[i] as int;
- debug += " ";
- }
-
- trace(debug + "<<");
- }
-
- public override function write(buf:ByteArray, off:int, len:int):void
- {
- obuffer.writeBytes(buf, off, len);
- }
-
- public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
- {
- this.eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
- }
-
- public override function open():void
- {
- this.socket = new Socket();
- this.socket.addEventListener(Event.CONNECT, socketConnected);
- this.socket.addEventListener(IOErrorEvent.IO_ERROR, socketError);
- this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, socketSecurityError);
- this.socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
- this.socket.connect(host, port);
- }
-
- public function socketConnected(event:Event):void
- {
- this.output = this.socket;
- this.input = this.socket;
- this.output.writeUTF("CONNECT " + resource + " HTTP/1.1\n" + "Host: " + host + ":" + port + "\r\n" + "User-Agent: Thrift/AS3\r\n" + "Transfer-Encoding: chunked\r\n" + "content-type: application/x-thrift\r\n" + "Accept: */*\r\n\r\n");
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public function socketError(event:IOErrorEvent):void
- {
- trace("Error Connecting:" + event);
- this.close();
- if (ioCallback == null)
- {
- return;
- }
- ioCallback(new TTransportError(TTransportError.UNKNOWN, "IOError: " + event.text));
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public function socketSecurityError(event:SecurityErrorEvent):void
- {
- trace("Security Error Connecting:" + event);
- this.close();
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public function socketDataHandler(event:ProgressEvent):void
- {
- trace("Got Data call:" +ioCallback);
- if (ioCallback != null)
- {
- ioCallback(null);
- };
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public override function flush(callback:Function = null):void
- {
- trace("set callback:" + callback);
- this.ioCallback = callback;
- this.output.writeUTF(this.obuffer.length.toString(16));
- this.output.writeBytes(CRLF);
- this.output.writeBytes(this.obuffer);
- this.output.writeBytes(CRLF);
- this.socket.flush();
- // waiting for new Flex sdk 3.5
- //this.obuffer.clear();
- this.obuffer = new ByteArray();
- }
-
- public override function isOpen():Boolean
- {
- return (this.socket == null ? false : this.socket.connected);
- }
-
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/transport/THttpClient.as b/lib/as3/src/org/apache/thrift/transport/THttpClient.as
deleted file mode 100644
index 435f911..0000000
--- a/lib/as3/src/org/apache/thrift/transport/THttpClient.as
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.transport {
-
- import flash.errors.EOFError;
- import flash.events.Event;
- import flash.events.IOErrorEvent;
- import flash.events.SecurityErrorEvent;
- import flash.net.URLLoader;
- import flash.net.URLLoaderDataFormat;
- import flash.net.URLRequest;
- import flash.net.URLRequestMethod;
- import flash.system.Capabilities;
- import flash.utils.ByteArray;
-
- /**
- * HTTP implementation of the TTransport interface. Used for working with a
- * Thrift web services implementation.
- */
- public class THttpClient extends TTransport {
-
- private var request_:URLRequest = null;
- private var requestBuffer_:ByteArray = new ByteArray();
- private var responseBuffer_:ByteArray = null;
- private var traceBuffers_:Boolean = Capabilities.isDebugger;
-
-
- public function getBuffer():ByteArray {
- return requestBuffer_;
- }
-
- public function THttpClient(request:URLRequest, traceBuffers:Boolean=true):void {
- request.contentType = "application/x-thrift";
- request_ = request;
- if(traceBuffers == false) {
- traceBuffers_ = traceBuffers;
- }
- }
-
- public override function open():void {
- }
-
- public override function close():void {
- }
-
- public override function isOpen():Boolean {
- return true;
- }
-
- public override function read(buf:ByteArray, off:int, len:int):int {
- if (responseBuffer_ == null) {
- throw new TTransportError(TTransportError.UNKNOWN, "Response buffer is empty, no request.");
- }
- try {
- responseBuffer_.readBytes(buf, off, len);
- if (traceBuffers_) {
- dumpBuffer(buf, "READ");
- }
- return len;
- }
- catch (e:EOFError) {
- if (traceBuffers_) {
- dumpBuffer(requestBuffer_, "FAILED-RESPONSE-REQUEST");
- dumpBuffer(responseBuffer_, "FAILED-RESPONSE");
- }
- throw new TTransportError(TTransportError.UNKNOWN, "No more data available.");
- }
- return 0;
- }
-
- public override function write(buf:ByteArray, off:int, len:int):void {
- requestBuffer_.writeBytes(buf, off, len);
- }
-
- public override function flush(callback:Function=null):void {
- var loader:URLLoader = new URLLoader();
- if (callback != null) {
- loader.addEventListener(Event.COMPLETE, function(event:Event):void {
- responseBuffer_ = URLLoader(event.target).data;
- if (traceBuffers_) {
- dumpBuffer(responseBuffer_, "RESPONSE_BUFFER");
- }
- callback(null);
- responseBuffer_ = null;
- });
- loader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void {
- callback(new TTransportError(TTransportError.UNKNOWN, "IOError: " + event.text));
- responseBuffer_ = null;
- });
- loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(event:SecurityErrorEvent):void {
- callback(new TTransportError(TTransportError.UNKNOWN, "SecurityError: " + event.text));
- responseBuffer_ = null;
- });
- }
- request_.method = URLRequestMethod.POST;
- loader.dataFormat = URLLoaderDataFormat.BINARY;
- requestBuffer_.position = 0;
- request_.data = requestBuffer_;
- loader.load(request_);
- }
-
- private function dumpBuffer(buf:ByteArray, prefix:String):String {
- var debugString : String = prefix + " BUFFER ";
- if (buf != null) {
- debugString += "length: " + buf.length + ", ";
- for (var i : int = 0; i < buf.length; i++) {
- debugString += "[" + buf[i].toString(16) + "]";
- }
- } else {
- debugString = "null";
- }
- trace(debugString);
- return debugString;
- }
-
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/transport/TSocket.as b/lib/as3/src/org/apache/thrift/transport/TSocket.as
deleted file mode 100644
index c60d711..0000000
--- a/lib/as3/src/org/apache/thrift/transport/TSocket.as
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.transport
-{
-
- import flash.events.EventDispatcher;
- import flash.events.Event;
- import flash.events.IOErrorEvent;
- import flash.events.ProgressEvent;
- import flash.events.SecurityErrorEvent;
- import flash.errors.EOFError;
- import flash.errors.IOError;
- import flash.net.URLLoader;
- import flash.net.URLLoaderDataFormat;
- import flash.net.URLRequest;
- import flash.net.URLRequestMethod;
- import flash.utils.IDataInput;
- import flash.utils.IDataOutput;
- import flash.utils.ByteArray;
- import flash.net.Socket;
-
-
- /**
- * Socket implementation of the TTransport interface. Used for working with a
- * Thrift Socket Server based implementations.
- */
-
- public class TSocket extends TTransport
- {
- private var socket:Socket = null;
-
- private var host:String;
-
- private var port:int;
-
- private var obuffer:ByteArray = new ByteArray();
-
- private var input:IDataInput;
-
- private var output:IDataOutput;
-
- private var ioCallback:Function = null;
-
- private var eventDispatcher:EventDispatcher = new EventDispatcher();
-
- public function TSocket(host:String, port:int):void
- {
- this.host = host;
- this.port = port;
- }
-
- public override function close():void
- {
- this.input = null;
- this.output = null;
- socket.close()
- }
-
- public override function peek():Boolean
- {
- if(socket.connected)
- {
- trace("Bytes remained:" + socket.bytesAvailable);
- return socket.bytesAvailable>0;
- }
- return false;
- }
-
- public override function read(buf:ByteArray, off:int, len:int):int
- {
- var n1:int = 0, n2:int = 0, n3:int = 0, n4:int = 0, cidx:int = 2;
- var chunkSize:ByteArray = new ByteArray();
-
- try
- {
- input.readBytes(buf, off, len);
- return len;
- }
- catch (e:EOFError)
- {
- trace(e);
- throw new TTransportError(TTransportError.END_OF_FILE, "No more data available.");
- }
- catch (e:IOError)
- {
- trace(e);
- if(isOpen())
- {
- throw new TTransportError(TTransportError.UNKNOWN, "IO error while reading: " + e);
- }
- else
- {
- throw new TTransportError(TTransportError.NOT_OPEN, "Socket seem not to be opened: " + e);
- }
- }
- catch (e:Error)
- {
- trace(e);
- throw new TTransportError(TTransportError.UNKNOWN, "Bad IO error: " + e);
- }
- return 0;
- }
-
- public override function write(buf:ByteArray, off:int, len:int):void
- {
- obuffer.writeBytes(buf, off, len);
- }
-
- public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
- {
- this.eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
- }
-
- public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
- {
- this.eventDispatcher.removeEventListener(type, listener, useCapture);
- }
-
- public override function open():void
- {
- this.socket = new Socket();
- this.socket.addEventListener(Event.CONNECT, socketConnected);
- this.socket.addEventListener(IOErrorEvent.IO_ERROR, socketError);
- this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, socketSecurityError);
- this.socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
- this.socket.connect(host, port);
- }
-
- public function socketConnected(event:Event):void
- {
- this.output = this.socket;
- this.input = this.socket;
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public function socketError(event:IOErrorEvent):void
- {
- trace("Error Connecting:" + event);
- this.close();
- if (ioCallback == null)
- {
- return;
- }
- ioCallback(new TTransportError(TTransportError.UNKNOWN, "IOError: " + event.text));
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public function socketSecurityError(event:SecurityErrorEvent):void
- {
- trace("Security Error Connecting:" + event);
- this.close();
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public function socketDataHandler(event:ProgressEvent):void
- {
- if (ioCallback != null)
- {
- ioCallback(null);
- }
- this.eventDispatcher.dispatchEvent(event);
- }
-
- public override function flush(callback:Function = null):void
- {
- this.ioCallback = callback;
- this.output.writeBytes(this.obuffer);
- this.socket.flush();
- this.obuffer.clear();
- }
-
- public override function isOpen():Boolean
- {
- return (this.socket == null ? false : this.socket.connected);
- }
- }
-}
diff --git a/lib/as3/src/org/apache/thrift/transport/TTransport.as b/lib/as3/src/org/apache/thrift/transport/TTransport.as
deleted file mode 100644
index 83160af..0000000
--- a/lib/as3/src/org/apache/thrift/transport/TTransport.as
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.transport {
-
- import flash.utils.ByteArray;
- import org.apache.thrift.AbstractMethodError;
-
- public class TTransport {
-
- /**
- * Queries whether the transport is open.
- *
- * @return True if the transport is open.
- */
- public function isOpen():Boolean {
- throw new AbstractMethodError();
- }
-
- /**
- * Is there more data to be read?
- *
- * @return True if the remote side is still alive and feeding us
- */
- public function peek():Boolean {
- return isOpen();
- }
-
- /**
- * Opens the transport for reading/writing.
- *
- * @throws TTransportException if the transport could not be opened
- */
- public function open():void {
- throw new AbstractMethodError();
- }
-
- /**
- * Closes the transport.
- */
- public function close():void {
- throw new AbstractMethodError();
- };
-
- /**
- * Reads up to len bytes into buffer buf, starting att offset off.
- *
- * @param buf Array to read into
- * @param off Index to start reading at
- * @param len Maximum number of bytes to read
- * @return The number of bytes actually read
- * @throws TTransportException if there was an error reading data
- */
- public function read(buf:ByteArray, off:int, len:int):int {
- throw new AbstractMethodError();
- }
-
- /**
- * Guarantees that all of len bytes are actually read off the transport.
- *
- * @param buf Array to read into
- * @param off Index to start reading at
- * @param len Maximum number of bytes to read
- * @return The number of bytes actually read, which must be equal to len
- * @throws TTransportException if there was an error reading data
- */
- public function readAll(buf:ByteArray, off:int, len:int):int {
- var got:int = 0;
- var ret:int = 0;
- while (got < len) {
- ret = read(buf, off+got, len-got);
- if (ret <= 0) {
- throw new TTransportError(TTransportError.UNKNOWN, "Cannot read. Remote side has closed. Tried to read " + len + " bytes, but only got " + got + " bytes.");
- }
- got += ret;
- }
- return got;
- }
-
- /**
- * Writes the buffer to the output
- *
- * @param buf The output data buffer
- * @throws TTransportException if an error occurs writing data
- */
- public function writeAll(buf:ByteArray):void {
- write(buf, 0, buf.length);
- }
-
- /**
- * Writes up to len bytes from the buffer.
- *
- * @param buf The output data buffer
- * @param off The offset to start writing from
- * @param len The number of bytes to write
- * @throws TTransportException if there was an error writing data
- */
- public function write(buf:ByteArray, off:int, len:int):void {
- throw new AbstractMethodError();
- }
-
- /**
- * Flush any pending data out of a transport buffer.
- *
- * @throws TTransportException if there was an error writing out data.
- */
- public function flush(callback:Function=null):void {
- throw new AbstractMethodError();
- }
- }
-}
\ No newline at end of file
diff --git a/lib/as3/src/org/apache/thrift/transport/TTransportError.as b/lib/as3/src/org/apache/thrift/transport/TTransportError.as
deleted file mode 100644
index 10a6f62..0000000
--- a/lib/as3/src/org/apache/thrift/transport/TTransportError.as
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.thrift.transport {
-
- import org.apache.thrift.TError;
-
- public class TTransportError extends TError {
-
- public static const UNKNOWN:int = 0;
- public static const NOT_OPEN:int = 1;
- public static const ALREADY_OPEN:int = 2;
- public static const TIMED_OUT:int = 3;
- public static const END_OF_FILE:int = 4;
-
- public function TTransportError(error:int = UNKNOWN, message:String = "") {
- super(message, error);
- }
-
- }
-}
\ No newline at end of file
diff --git a/sonar-project.properties b/sonar-project.properties
index 855726a..f9c9e05 100755
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -37,7 +37,7 @@
sonar.cxx.cppcheck.reportPath=cppcheck-result.xml
# List of the module identifiers
-sonar.modules=module1,module3,module4,module5,module6,module7,module8,module9,module10,module11,module12,module14
+sonar.modules=module1,module3,module4,module5,module6,module7,module8,module9,module10,module11,module12
@@ -48,7 +48,7 @@
#sonar.modules=module13
# phpunit plugin is broken
-#sonar.modules=module15
+#sonar.modules=module14
module1.sonar.projectName=Apache Thrift - Java Library
module1.sonar.projectBaseDir=lib/java
@@ -126,15 +126,10 @@
module13.sonar.tests=test
module13.sonar.language=delph
-module14.sonar.projectName=Apache Thrift - Flex (as3) Library
-module14.sonar.projectBaseDir=lib/as3
+module14.sonar.projectName=Apache Thrift - PHP Library
+module14.sonar.projectBaseDir=lib/php
module14.sonar.sources=src
-module14.sonar.language=flex
-
-module15.sonar.projectName=Apache Thrift - PHP Library
-module15.sonar.projectBaseDir=lib/php
-module15.sonar.sources=src
-module15.sonar.language=php
+module14.sonar.language=php
# TODO add some more languages here
diff --git a/tutorial/Makefile.am b/tutorial/Makefile.am
index 484b485..12b3eb5 100755
--- a/tutorial/Makefile.am
+++ b/tutorial/Makefile.am
@@ -104,7 +104,6 @@
# Any folders or files not listed above being added to SUBDIR need to be placed here in
# EXTRA_DIST to be included in the release
EXTRA_DIST = \
- as3 \
d \
delphi \
erl \
diff --git a/tutorial/as3/build.xml b/tutorial/as3/build.xml
deleted file mode 100644
index f7ed32d..0000000
--- a/tutorial/as3/build.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<project name="tutorial" default="dist" basedir=".">
-
- <description>Thrift actionscript 3.0 tutorial.</description>
-
- <property name="gen" location="gen-as3" />
- <property name="src" location="src" />
- <property name="thrift.src" location="../../lib/as3/src/" />
- <property name="dist" location="dist" />
-
- <property name="final.name" value="as3-tutorial" />
- <property name="swf.name" value="${dist}/${final.name}.swf" />
-
- <target name="flex.check" unless="FLEX_HOME">
- <fail message='You must set the FLEX_HOME property pointing to your flex SDK, eg. ant -DFLEX_HOME="/Applications/Adobe Flex Builder 3/sdks/3.2.0"'/>
- </target>
-
- <target name="flex.init" depends="flex.check" unless="flex.finished">
- <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
- <property name="flex.finished" value="true"/>
- </target>
-
- <target name="init">
- <tstamp />
- <mkdir dir="${dist}"/>
- </target>
-
- <target name="dist" depends="generate, flex.init, init">
- <mxmlc output="${swf.name}" file="${src}/CalculatorUI.as">
- <source-path path-element="${gen}" />
- <source-path path-element="${src}" />
- <source-path path-element="${thrift.src}" />
- </mxmlc>
- </target>
-
- <target name="generate">
- <!-- Generate the thrift gen-java source -->
- <exec executable="../../compiler/cpp/thrift" failonerror="true">
- <arg line="--gen as3 ../shared.thrift"/>
- </exec>
- <exec executable="../../compiler/cpp/thrift" failonerror="true">
- <arg line="--gen as3 ../tutorial.thrift"/>
- </exec>
- </target>
-
- <target name="clean">
- <delete dir="${gen}"/>
- <delete dir="${dist}" />
- </target>
-
-</project>
diff --git a/tutorial/as3/src/CalculatorUI.as b/tutorial/as3/src/CalculatorUI.as
deleted file mode 100644
index d996df5..0000000
--- a/tutorial/as3/src/CalculatorUI.as
+++ /dev/null
@@ -1,142 +0,0 @@
-package {
- import flash.display.Sprite;
- import flash.text.TextField;
- import flash.text.TextFieldType;
- import flash.events.MouseEvent;
- import flash.system.Security;
-
- import org.apache.thrift.transport.TSocket;
- import org.apache.thrift.transport.TTransport;
- import org.apache.thrift.protocol.TProtocol;
- import org.apache.thrift.protocol.TBinaryProtocol;
-
- /**
- * Simple interface and connection logic implementation for tutorial.
- */
- public class CalculatorUI extends Sprite {
- public static const BUTTON_PADDING:uint = 5;
-
- private var mCalculatorClient:Calculator; // we use calculator through interface
- private var mTransport:TTransport; // Transport, used to comunicate with server
-
- private var mAddButton:Sprite;
- private var mLeft:TextField;
- private var mRight:TextField;
- private var mResult:TextField;
-
- private var pingButton:Sprite;
-
- public function CalculatorUI() {
- buildInterface();
- initSecurity();
- initConnection();
- }
-
- private function initSecurity():void {
- Security.loadPolicyFile("xmlsocket://127.0.0.1:9092");
- }
-
- /**
- * Example of initializing connection.
- */
- private function initConnection():void {
- mTransport = new TSocket("127.0.0.1", 9090); // we connect to server
- mTransport.open();
- // initialize protocol:
- var protocol:TProtocol = new TBinaryProtocol(mTransport, false, false);
- mCalculatorClient = new CalculatorImpl(protocol); // finally, we create calculator client instance
- }
-
- private function onPingClick(me:MouseEvent):void {
- if(!mTransport.isOpen()) return;
- mCalculatorClient.ping(onPingError, onPingSuccess);
- }
-
- private function onPingError(error:Error):void {
- trace("Error, while requesting ping.");
- throw error;
- }
-
- private function onPingSuccess():void {
- trace("Ping returned successfully");
- }
-
- private function onAddClick(me:MouseEvent):void {
- if(!mTransport.isOpen()) return;
- var num1:Number = Number(mLeft.text);
- var num2:Number = Number(mRight.text);
- mResult.text = "Processing...";
- mCalculatorClient.add(num1, num2, onAddError, onAddSuccess);
- }
-
- private function onAddError(error:Error):void {
- trace("Error, while requesting add.");
- throw error;
- }
-
- private function onAddSuccess(res:Number):void {
- mResult.text = String(res);
- }
-
- private function buildInterface():void {
- addChild(pingButton = buildButton("PING"));
- pingButton.x = (stage.stageWidth - pingButton.width) / 2;
- pingButton.y = 10;
- pingButton.addEventListener(MouseEvent.CLICK, onPingClick);
-
- var top:Number = pingButton.y + pingButton.height + 20;
- addChild(mLeft = buildDigitInput());
- mLeft.x = 15;
- mLeft.y = top + BUTTON_PADDING;
- addChild(mRight = buildDigitInput());
- mRight.x = mLeft.x + mLeft.width + 15;
- mRight.y = top + BUTTON_PADDING;
- addChild(mAddButton = buildButton("ADD"));
- mAddButton.x = mRight.x + mRight.width + 15;
- mAddButton.y = top;
- mAddButton.addEventListener(MouseEvent.CLICK, onAddClick);
- addChild(mResult = buildDigitInput());
- mResult.x = mAddButton.x + mAddButton.width + 15;
- mResult.y = top + BUTTON_PADDING;
- }
-
- /**
- * Simple digit-only input field.
- */
- private function buildDigitInput():TextField {
- var textField:TextField = new TextField;
- textField.width = 75;
- textField.height = 20;
- textField.restrict = "0987654321.";
- textField.type = TextFieldType.INPUT;
- textField.background = true;
- textField.backgroundColor = 0xaaaaff;
- textField.textColor = 0xffff00;
- return textField;
- }
-
- /**
- * Simple button drawing.
- */
- private function buildButton(text:String):Sprite {
- var button:Sprite = new Sprite;
- var textField:TextField = new TextField;
- textField.width = 4000;
- textField.text = text;
- textField.textColor = 0xffff00;
- textField.width = textField.textWidth + 4;
- textField.height = textField.textHeight + 4;
- textField.mouseEnabled = false;
- button.graphics.beginFill(0x0000ff);
- button.graphics.lineStyle(0, 0x000000);
- button.graphics.drawRoundRect(0, 0, textField.width + BUTTON_PADDING * 2,
- textField.height + BUTTON_PADDING * 2, BUTTON_PADDING);
- button.graphics.endFill();
- button.addChild(textField);
- textField.x = BUTTON_PADDING;
- textField.y = BUTTON_PADDING;
- button.useHandCursor = button.buttonMode = true;
- return button;
- }
- }
-}