You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2016/09/25 16:43:14 UTC
[25/55] [abbrv] [partial] thrift git commit: THRIFT-2835 Add
possibility to distribute generators separately from thrift core,
and load them dynamically
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_base_type.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_base_type.h b/compiler/cpp/src/parse/t_base_type.h
deleted file mode 100644
index 11d73e0..0000000
--- a/compiler/cpp/src/parse/t_base_type.h
+++ /dev/null
@@ -1,117 +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.
- */
-
-#ifndef T_BASE_TYPE_H
-#define T_BASE_TYPE_H
-
-#include <cstdlib>
-#include "t_type.h"
-
-/**
- * A thrift base type, which must be one of the defined enumerated types inside
- * this definition.
- *
- */
-class t_base_type : public t_type {
-public:
- /**
- * Enumeration of thrift base types
- */
- enum t_base {
- TYPE_VOID,
- TYPE_STRING,
- TYPE_BOOL,
- TYPE_I8,
- TYPE_I16,
- TYPE_I32,
- TYPE_I64,
- TYPE_DOUBLE
- };
-
- t_base_type(std::string name, t_base base)
- : t_type(name), base_(base), string_list_(false), binary_(false), string_enum_(false) {}
-
- t_base get_base() const { return base_; }
-
- bool is_void() const { return base_ == TYPE_VOID; }
-
- bool is_string() const { return base_ == TYPE_STRING; }
-
- bool is_bool() const { return base_ == TYPE_BOOL; }
-
- void set_string_list(bool val) { string_list_ = val; }
-
- bool is_string_list() const { return (base_ == TYPE_STRING) && string_list_; }
-
- void set_binary(bool val) { binary_ = val; }
-
- bool is_binary() const { return (base_ == TYPE_STRING) && binary_; }
-
- void set_string_enum(bool val) { string_enum_ = val; }
-
- bool is_string_enum() const { return base_ == TYPE_STRING && string_enum_; }
-
- void add_string_enum_val(std::string val) { string_enum_vals_.push_back(val); }
-
- const std::vector<std::string>& get_string_enum_vals() const { return string_enum_vals_; }
-
- bool is_base_type() const { return true; }
-
- static std::string t_base_name(t_base tbase) {
- switch (tbase) {
- case TYPE_VOID:
- return "void";
- break;
- case TYPE_STRING:
- return "string";
- break;
- case TYPE_BOOL:
- return "bool";
- break;
- case TYPE_I8:
- return "i8";
- break;
- case TYPE_I16:
- return "i16";
- break;
- case TYPE_I32:
- return "i32";
- break;
- case TYPE_I64:
- return "i64";
- break;
- case TYPE_DOUBLE:
- return "double";
- break;
- default:
- return "(unknown)";
- break;
- }
- }
-
-private:
- t_base base_;
-
- bool string_list_;
- bool binary_;
- bool string_enum_;
- std::vector<std::string> string_enum_vals_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_const.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_const.h b/compiler/cpp/src/parse/t_const.h
deleted file mode 100644
index 0f64bb1..0000000
--- a/compiler/cpp/src/parse/t_const.h
+++ /dev/null
@@ -1,50 +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.
- */
-
-#ifndef T_CONST_H
-#define T_CONST_H
-
-#include "t_type.h"
-#include "t_const_value.h"
-
-/**
- * A const is a constant value defined across languages that has a type and
- * a value. The trick here is that the declared type might not match the type
- * of the value object, since that is not determined until after parsing the
- * whole thing out.
- *
- */
-class t_const : public t_doc {
-public:
- t_const(t_type* type, std::string name, t_const_value* value)
- : type_(type), name_(name), value_(value) {}
-
- t_type* get_type() const { return type_; }
-
- std::string get_name() const { return name_; }
-
- t_const_value* get_value() const { return value_; }
-
-private:
- t_type* type_;
- std::string name_;
- t_const_value* value_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_const_value.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_const_value.h b/compiler/cpp/src/parse/t_const_value.h
deleted file mode 100644
index 15366ad..0000000
--- a/compiler/cpp/src/parse/t_const_value.h
+++ /dev/null
@@ -1,155 +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.
- */
-
-#ifndef T_CONST_VALUE_H
-#define T_CONST_VALUE_H
-
-#include "t_enum.h"
-#include <stdint.h>
-#include <map>
-#include <vector>
-#include <string>
-
-namespace plugin_output {
-template <typename From, typename To>
-void convert(From*, To&);
-}
-
-/**
- * A const value is something parsed that could be a map, set, list, struct
- * or whatever.
- *
- */
-class t_const_value {
-public:
- enum t_const_value_type { CV_INTEGER, CV_DOUBLE, CV_STRING, CV_MAP, CV_LIST, CV_IDENTIFIER };
-
- t_const_value() {}
-
- t_const_value(int64_t val) { set_integer(val); }
-
- t_const_value(std::string val) { set_string(val); }
-
- void set_string(std::string val) {
- valType_ = CV_STRING;
- stringVal_ = val;
- }
-
- std::string get_string() const { return stringVal_; }
-
- void set_integer(int64_t val) {
- valType_ = CV_INTEGER;
- intVal_ = val;
- }
-
- int64_t get_integer() const {
- if (valType_ == CV_IDENTIFIER) {
- if (enum_ == NULL) {
- throw "have identifier \"" + get_identifier() + "\", but unset enum on line!";
- }
- std::string identifier = get_identifier();
- std::string::size_type dot = identifier.rfind('.');
- if (dot != std::string::npos) {
- identifier = identifier.substr(dot + 1);
- }
- t_enum_value* val = enum_->get_constant_by_name(identifier);
- if (val == NULL) {
- throw "Unable to find enum value \"" + identifier + "\" in enum \"" + enum_->get_name()
- + "\"";
- }
- return val->get_value();
- } else {
- return intVal_;
- }
- }
-
- void set_double(double val) {
- valType_ = CV_DOUBLE;
- doubleVal_ = val;
- }
-
- double get_double() const { return doubleVal_; }
-
- void set_map() { valType_ = CV_MAP; }
-
- void add_map(t_const_value* key, t_const_value* val) { mapVal_[key] = val; }
-
- const std::map<t_const_value*, t_const_value*>& get_map() const { return mapVal_; }
-
- void set_list() { valType_ = CV_LIST; }
-
- void add_list(t_const_value* val) { listVal_.push_back(val); }
-
- const std::vector<t_const_value*>& get_list() const { return listVal_; }
-
- void set_identifier(std::string val) {
- valType_ = CV_IDENTIFIER;
- identifierVal_ = val;
- }
-
- std::string get_identifier() const { return identifierVal_; }
-
- std::string get_identifier_name() const {
- std::string ret = get_identifier();
- size_t s = ret.find('.');
- if (s == std::string::npos) {
- throw "error: identifier " + ret + " is unqualified!";
- }
- ret = ret.substr(s + 1);
- s = ret.find('.');
- if (s != std::string::npos) {
- ret = ret.substr(s + 1);
- }
- return ret;
- }
-
- std::string get_identifier_with_parent() const {
- std::string ret = get_identifier();
- size_t s = ret.find('.');
- if (s == std::string::npos) {
- throw "error: identifier " + ret + " is unqualified!";
- }
- size_t s2 = ret.find('.', s + 1);
- if (s2 != std::string::npos) {
- ret = ret.substr(s + 1);
- }
- return ret;
- }
-
- void set_enum(t_enum* tenum) { enum_ = tenum; }
-
- t_const_value_type get_type() const { return valType_; }
-
-private:
- std::map<t_const_value*, t_const_value*> mapVal_;
- std::vector<t_const_value*> listVal_;
- std::string stringVal_;
- int64_t intVal_;
- double doubleVal_;
- std::string identifierVal_;
- t_enum* enum_;
-
- t_const_value_type valType_;
-
- // to read enum_
- template <typename From, typename To>
- friend void plugin_output::convert(From*, To&);
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_container.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_container.h b/compiler/cpp/src/parse/t_container.h
deleted file mode 100644
index 2cdcf7e..0000000
--- a/compiler/cpp/src/parse/t_container.h
+++ /dev/null
@@ -1,47 +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.
- */
-
-#ifndef T_CONTAINER_H
-#define T_CONTAINER_H
-
-#include "t_type.h"
-
-class t_container : public t_type {
-public:
- t_container() : cpp_name_(), has_cpp_name_(false) {}
-
- virtual ~t_container() {}
-
- void set_cpp_name(std::string cpp_name) {
- cpp_name_ = cpp_name;
- has_cpp_name_ = true;
- }
-
- bool has_cpp_name() const { return has_cpp_name_; }
-
- std::string get_cpp_name() const { return cpp_name_; }
-
- bool is_container() const { return true; }
-
-private:
- std::string cpp_name_;
- bool has_cpp_name_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_doc.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_doc.h b/compiler/cpp/src/parse/t_doc.h
deleted file mode 100644
index 621513a..0000000
--- a/compiler/cpp/src/parse/t_doc.h
+++ /dev/null
@@ -1,55 +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.
- */
-
-#ifndef T_DOC_H
-#define T_DOC_H
-
-#include "globals.h"
-#include "logging.h"
-
-/**
- * Documentation stubs
- *
- */
-class t_doc {
-
-public:
- t_doc() : has_doc_(false) {}
- virtual ~t_doc() {}
-
- void set_doc(const std::string& doc) {
- doc_ = doc;
- has_doc_ = true;
- if ((g_program_doctext_lineno == g_doctext_lineno)
- && (g_program_doctext_status == STILL_CANDIDATE)) {
- g_program_doctext_status = ALREADY_PROCESSED;
- pdebug("%s", "program doctext set to ALREADY_PROCESSED");
- }
- }
-
- const std::string& get_doc() const { return doc_; }
-
- bool has_doc() { return has_doc_; }
-
-private:
- std::string doc_;
- bool has_doc_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_enum.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_enum.h b/compiler/cpp/src/parse/t_enum.h
deleted file mode 100644
index 268f89f..0000000
--- a/compiler/cpp/src/parse/t_enum.h
+++ /dev/null
@@ -1,110 +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.
- */
-
-#ifndef T_ENUM_H
-#define T_ENUM_H
-
-#include <vector>
-
-#include "t_enum_value.h"
-#include "t_type.h"
-
-/**
- * An enumerated type. A list of constant objects with a name for the type.
- *
- */
-class t_enum : public t_type {
-public:
- t_enum(t_program* program) : t_type(program) {}
-
- void set_name(const std::string& name) { name_ = name; }
-
- void append(t_enum_value* constant) { constants_.push_back(constant); }
-
- const std::vector<t_enum_value*>& get_constants() const { return constants_; }
-
- t_enum_value* get_constant_by_name(const std::string& name) {
- const std::vector<t_enum_value*>& enum_values = get_constants();
- std::vector<t_enum_value*>::const_iterator c_iter;
- for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {
- if ((*c_iter)->get_name() == name) {
- return *c_iter;
- }
- }
- return NULL;
- }
-
- t_enum_value* get_constant_by_value(int64_t value) {
- const std::vector<t_enum_value*>& enum_values = get_constants();
- std::vector<t_enum_value*>::const_iterator c_iter;
- for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {
- if ((*c_iter)->get_value() == value) {
- return *c_iter;
- }
- }
- return NULL;
- }
-
- t_enum_value* get_min_value() {
- const std::vector<t_enum_value*>& enum_values = get_constants();
- std::vector<t_enum_value*>::const_iterator c_iter;
- t_enum_value* min_value;
- if (enum_values.size() == 0) {
- min_value = NULL;
- } else {
- int min_value_value;
- min_value = enum_values.front();
- min_value_value = min_value->get_value();
- for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {
- if ((*c_iter)->get_value() < min_value_value) {
- min_value = (*c_iter);
- min_value_value = min_value->get_value();
- }
- }
- }
- return min_value;
- }
-
- t_enum_value* get_max_value() {
- const std::vector<t_enum_value*>& enum_values = get_constants();
- std::vector<t_enum_value*>::const_iterator c_iter;
- t_enum_value* max_value;
- if (enum_values.size() == 0) {
- max_value = NULL;
- } else {
- int max_value_value;
- max_value = enum_values.back();
- max_value_value = max_value->get_value();
- for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {
- if ((*c_iter)->get_value() > max_value_value) {
- max_value = (*c_iter);
- max_value_value = max_value->get_value();
- }
- }
- }
- return max_value;
- }
-
- bool is_enum() const { return true; }
-
-private:
- std::vector<t_enum_value*> constants_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_enum_value.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_enum_value.h b/compiler/cpp/src/parse/t_enum_value.h
deleted file mode 100644
index 296029b..0000000
--- a/compiler/cpp/src/parse/t_enum_value.h
+++ /dev/null
@@ -1,50 +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.
- */
-
-#ifndef T_ENUM_VALUE_H
-#define T_ENUM_VALUE_H
-
-#include <map>
-#include <string>
-#include "t_doc.h"
-
-/**
- * A constant. These are used inside of enum definitions. Constants are just
- * symbol identifiers that may or may not have an explicit value associated
- * with them.
- *
- */
-class t_enum_value : public t_doc {
-public:
- t_enum_value(std::string name, int value) : name_(name), value_(value) {}
-
- ~t_enum_value() {}
-
- const std::string& get_name() const { return name_; }
-
- int get_value() const { return value_; }
-
- std::map<std::string, std::string> annotations_;
-
-private:
- std::string name_;
- int value_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_field.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_field.h b/compiler/cpp/src/parse/t_field.h
deleted file mode 100644
index 8b459a3..0000000
--- a/compiler/cpp/src/parse/t_field.h
+++ /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.
- */
-
-#ifndef T_FIELD_H
-#define T_FIELD_H
-
-#include <map>
-#include <string>
-#include <sstream>
-
-#include "t_doc.h"
-#include "t_type.h"
-
-// Forward declare for xsd_attrs
-class t_struct;
-
-/**
- * Class to represent a field in a thrift structure. A field has a data type,
- * a symbolic name, and a numeric identifier.
- *
- */
-class t_field : public t_doc {
-public:
- t_field(t_type* type, std::string name)
- : type_(type),
- name_(name),
- key_(0),
- value_(NULL),
- xsd_optional_(false),
- xsd_nillable_(false),
- xsd_attrs_(NULL),
- reference_(false) {}
-
- t_field(t_type* type, std::string name, int32_t key)
- : type_(type),
- name_(name),
- key_(key),
- req_(T_OPT_IN_REQ_OUT),
- value_(NULL),
- xsd_optional_(false),
- xsd_nillable_(false),
- xsd_attrs_(NULL),
- reference_(false) {}
-
- ~t_field() {}
-
- t_type* get_type() { return type_; }
-
- const t_type* get_type() const { return type_; }
-
- const std::string& get_name() const { return name_; }
-
- int32_t get_key() const { return key_; }
-
- enum e_req { T_REQUIRED, T_OPTIONAL, T_OPT_IN_REQ_OUT };
-
- void set_req(e_req req) { req_ = req; }
-
- e_req get_req() const { return req_; }
-
- void set_value(t_const_value* value) { value_ = value; }
-
- t_const_value* get_value() { return value_; }
-
- const t_const_value* get_value() const { return value_; }
-
- void set_xsd_optional(bool xsd_optional) { xsd_optional_ = xsd_optional; }
-
- bool get_xsd_optional() const { return xsd_optional_; }
-
- void set_xsd_nillable(bool xsd_nillable) { xsd_nillable_ = xsd_nillable; }
-
- bool get_xsd_nillable() const { return xsd_nillable_; }
-
- void set_xsd_attrs(t_struct* xsd_attrs) { xsd_attrs_ = xsd_attrs; }
-
- t_struct* get_xsd_attrs() { return xsd_attrs_; }
-
- /**
- * Comparator to sort fields in ascending order by key.
- * Make this a functor instead of a function to help GCC inline it.
- * The arguments are (const) references to const pointers to const t_fields.
- */
- struct key_compare {
- bool operator()(t_field const* const& a, t_field const* const& b) {
- return a->get_key() < b->get_key();
- }
- };
-
- std::map<std::string, std::string> annotations_;
-
- bool get_reference() { return reference_; }
-
- void set_reference(bool reference) { reference_ = reference; }
-
-private:
- t_type* type_;
- std::string name_;
- int32_t key_;
- e_req req_;
- t_const_value* value_;
-
- bool xsd_optional_;
- bool xsd_nillable_;
- t_struct* xsd_attrs_;
- bool reference_;
-};
-
-/**
- * A simple struct for the parser to use to store a field ID, and whether or
- * not it was specified by the user or automatically chosen.
- */
-struct t_field_id {
- int32_t value;
- bool auto_assigned;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_function.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_function.h b/compiler/cpp/src/parse/t_function.h
deleted file mode 100644
index 96886f3..0000000
--- a/compiler/cpp/src/parse/t_function.h
+++ /dev/null
@@ -1,84 +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.
- */
-
-#ifndef T_FUNCTION_H
-#define T_FUNCTION_H
-
-#include <string>
-#include "t_type.h"
-#include "t_struct.h"
-#include "t_doc.h"
-
-/**
- * Representation of a function. Key parts are return type, function name,
- * optional modifiers, and an argument list, which is implemented as a thrift
- * struct.
- *
- */
-class t_function : public t_doc {
-public:
- t_function(t_type* returntype, std::string name, t_struct* arglist, bool oneway = false)
- : returntype_(returntype), name_(name), arglist_(arglist), oneway_(oneway) {
- xceptions_ = new t_struct(NULL);
- if (oneway_ && (!returntype_->is_void())) {
- pwarning(1, "Oneway methods should return void.\n");
- }
- }
-
- t_function(t_type* returntype,
- std::string name,
- t_struct* arglist,
- t_struct* xceptions,
- bool oneway = false)
- : returntype_(returntype),
- name_(name),
- arglist_(arglist),
- xceptions_(xceptions),
- oneway_(oneway) {
- if (oneway_ && !xceptions_->get_members().empty()) {
- throw std::string("Oneway methods can't throw exceptions.");
- }
- if (oneway_ && (!returntype_->is_void())) {
- pwarning(1, "Oneway methods should return void.\n");
- }
- }
-
- ~t_function() {}
-
- t_type* get_returntype() const { return returntype_; }
-
- const std::string& get_name() const { return name_; }
-
- t_struct* get_arglist() const { return arglist_; }
-
- t_struct* get_xceptions() const { return xceptions_; }
-
- bool is_oneway() const { return oneway_; }
-
- std::map<std::string, std::string> annotations_;
-
-private:
- t_type* returntype_;
- std::string name_;
- t_struct* arglist_;
- t_struct* xceptions_;
- bool oneway_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_list.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_list.h b/compiler/cpp/src/parse/t_list.h
deleted file mode 100644
index ac0d981..0000000
--- a/compiler/cpp/src/parse/t_list.h
+++ /dev/null
@@ -1,41 +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.
- */
-
-#ifndef T_LIST_H
-#define T_LIST_H
-
-#include "t_container.h"
-
-/**
- * A list is a lightweight container type that just wraps another data type.
- *
- */
-class t_list : public t_container {
-public:
- t_list(t_type* elem_type) : elem_type_(elem_type) {}
-
- t_type* get_elem_type() const { return elem_type_; }
-
- bool is_list() const { return true; }
-
-private:
- t_type* elem_type_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_map.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_map.h b/compiler/cpp/src/parse/t_map.h
deleted file mode 100644
index 269aeab..0000000
--- a/compiler/cpp/src/parse/t_map.h
+++ /dev/null
@@ -1,45 +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.
- */
-
-#ifndef T_MAP_H
-#define T_MAP_H
-
-#include "t_container.h"
-
-/**
- * A map is a lightweight container type that just wraps another two data
- * types.
- *
- */
-class t_map : public t_container {
-public:
- t_map(t_type* key_type, t_type* val_type) : key_type_(key_type), val_type_(val_type) {}
-
- t_type* get_key_type() const { return key_type_; }
-
- t_type* get_val_type() const { return val_type_; }
-
- bool is_map() const { return true; }
-
-private:
- t_type* key_type_;
- t_type* val_type_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_program.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
deleted file mode 100644
index 563e9e0..0000000
--- a/compiler/cpp/src/parse/t_program.h
+++ /dev/null
@@ -1,395 +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.
- */
-
-#ifndef T_PROGRAM_H
-#define T_PROGRAM_H
-
-#include <map>
-#include <string>
-#include <vector>
-
-// For program_name()
-#include "main.h"
-
-#include "t_doc.h"
-#include "t_scope.h"
-#include "t_base_type.h"
-#include "t_typedef.h"
-#include "t_enum.h"
-#include "t_const.h"
-#include "t_struct.h"
-#include "t_service.h"
-#include "t_list.h"
-#include "t_map.h"
-#include "t_set.h"
-#include "generate/t_generator_registry.h"
-//#include "t_doc.h"
-
-/**
- * Top level class representing an entire thrift program. A program consists
- * fundamentally of the following:
- *
- * Typedefs
- * Enumerations
- * Constants
- * Structs
- * Exceptions
- * Services
- *
- * The program module also contains the definitions of the base types.
- *
- */
-class t_program : public t_doc {
-public:
- t_program(std::string path, std::string name)
- : path_(path), name_(name), out_path_("./"), out_path_is_absolute_(false), scope_(new t_scope) {}
-
- t_program(std::string path) : path_(path), out_path_("./"), out_path_is_absolute_(false) {
- name_ = program_name(path);
- scope_ = new t_scope();
- }
-
- ~t_program() {
- if (scope_) {
- delete scope_;
- scope_ = NULL;
- }
- }
-
- // Path accessor
- const std::string& get_path() const { return path_; }
-
- // Output path accessor
- const std::string& get_out_path() const { return out_path_; }
-
- // Create gen-* dir accessor
- bool is_out_path_absolute() const { return out_path_is_absolute_; }
-
- // Name accessor
- const std::string& get_name() const { return name_; }
-
- // Namespace
- const std::string& get_namespace() const { return namespace_; }
-
- // Include prefix accessor
- const std::string& get_include_prefix() const { return include_prefix_; }
-
- // Accessors for program elements
- const std::vector<t_typedef*>& get_typedefs() const { return typedefs_; }
- const std::vector<t_enum*>& get_enums() const { return enums_; }
- const std::vector<t_const*>& get_consts() const { return consts_; }
- const std::vector<t_struct*>& get_structs() const { return structs_; }
- const std::vector<t_struct*>& get_xceptions() const { return xceptions_; }
- const std::vector<t_struct*>& get_objects() const { return objects_; }
- const std::vector<t_service*>& get_services() const { return services_; }
- const std::map<std::string, std::string>& get_namespaces() const { return namespaces_; }
-
- // Program elements
- void add_typedef(t_typedef* td) { typedefs_.push_back(td); }
- void add_enum(t_enum* te) { enums_.push_back(te); }
- void add_const(t_const* tc) { consts_.push_back(tc); }
- void add_struct(t_struct* ts) {
- objects_.push_back(ts);
- structs_.push_back(ts);
- }
- void add_xception(t_struct* tx) {
- objects_.push_back(tx);
- xceptions_.push_back(tx);
- }
- void add_service(t_service* ts) { services_.push_back(ts); }
-
- // Programs to include
- const std::vector<t_program*>& get_includes() const { return includes_; }
-
- void set_out_path(std::string out_path, bool out_path_is_absolute) {
- out_path_ = out_path;
- out_path_is_absolute_ = out_path_is_absolute;
- // Ensure that it ends with a trailing '/' (or '\' for windows machines)
- char c = out_path_.at(out_path_.size() - 1);
- if (!(c == '/' || c == '\\')) {
- out_path_.push_back('/');
- }
- }
-
- // Typename collision detection
- /**
- * Search for typename collisions
- * @param t the type to test for collisions
- * @return true if a certain collision was found, otherwise false
- */
- bool is_unique_typename(t_type* t) {
- int occurrences = program_typename_count(this, t);
- for (std::vector<t_program*>::iterator it = includes_.begin(); it != includes_.end(); ++it) {
- occurrences += program_typename_count(*it, t);
- }
- return 0 == occurrences;
- }
-
- /**
- * Search all type collections for duplicate typenames
- * @param prog the program to search
- * @param t the type to test for collisions
- * @return the number of certain typename collisions
- */
- int program_typename_count(t_program* prog, t_type* t) {
- int occurrences = 0;
- occurrences += collection_typename_count(prog, prog->typedefs_, t);
- occurrences += collection_typename_count(prog, prog->enums_, t);
- occurrences += collection_typename_count(prog, prog->objects_, t);
- occurrences += collection_typename_count(prog, prog->services_, t);
- return occurrences;
- }
-
- /**
- * Search a type collection for duplicate typenames
- * @param prog the program to search
- * @param type_collection the type collection to search
- * @param t the type to test for collisions
- * @return the number of certain typename collisions
- */
- template <class T>
- int collection_typename_count(t_program* prog, T type_collection, t_type* t) {
- int occurrences = 0;
- for (typename T::iterator it = type_collection.begin(); it != type_collection.end(); ++it)
- if (t != *it && 0 == t->get_name().compare((*it)->get_name()) && is_common_namespace(prog, t))
- ++occurrences;
- return occurrences;
- }
-
- /**
- * Determine whether identical typenames will collide based on namespaces.
- *
- * Because we do not know which languages the user will generate code for,
- * collisions within programs (IDL files) having namespace declarations can be
- * difficult to determine. Only guaranteed collisions return true (cause an error).
- * Possible collisions involving explicit namespace declarations produce a warning.
- * Other possible collisions go unreported.
- * @param prog the program containing the preexisting typename
- * @param t the type containing the typename match
- * @return true if a collision within namespaces is found, otherwise false
- */
- bool is_common_namespace(t_program* prog, t_type* t) {
- // Case 1: Typenames are in the same program [collision]
- if (prog == t->get_program()) {
- pwarning(1,
- "Duplicate typename %s found in %s",
- t->get_name().c_str(),
- t->get_program()->get_name().c_str());
- return true;
- }
-
- // Case 2: Both programs have identical namespace scope/name declarations [collision]
- bool match = true;
- for (std::map<std::string, std::string>::iterator it = prog->namespaces_.begin();
- it != prog->namespaces_.end();
- ++it) {
- if (0 == it->second.compare(t->get_program()->get_namespace(it->first))) {
- pwarning(1,
- "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
- t->get_name().c_str(),
- t->get_program()->get_name().c_str(),
- it->first.c_str(),
- it->second.c_str(),
- prog->get_name().c_str(),
- it->first.c_str(),
- it->second.c_str());
- } else {
- match = false;
- }
- }
- for (std::map<std::string, std::string>::iterator it = t->get_program()->namespaces_.begin();
- it != t->get_program()->namespaces_.end();
- ++it) {
- if (0 == it->second.compare(prog->get_namespace(it->first))) {
- pwarning(1,
- "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
- t->get_name().c_str(),
- t->get_program()->get_name().c_str(),
- it->first.c_str(),
- it->second.c_str(),
- prog->get_name().c_str(),
- it->first.c_str(),
- it->second.c_str());
- } else {
- match = false;
- }
- }
- if (0 == prog->namespaces_.size() && 0 == t->get_program()->namespaces_.size()) {
- pwarning(1,
- "Duplicate typename %s found in %s and %s",
- t->get_name().c_str(),
- t->get_program()->get_name().c_str(),
- prog->get_name().c_str());
- }
- return match;
- }
-
- // Scoping and namespacing
- void set_namespace(std::string name) { namespace_ = name; }
-
- // Scope accessor
- t_scope* scope() const { return scope_; }
-
- // Includes
-
- void add_include(t_program* program) {
- includes_.push_back(program);
- }
-
- void add_include(std::string path, std::string include_site) {
- t_program* program = new t_program(path);
-
- // include prefix for this program is the site at which it was included
- // (minus the filename)
- std::string include_prefix;
- std::string::size_type last_slash = std::string::npos;
- if ((last_slash = include_site.rfind("/")) != std::string::npos) {
- include_prefix = include_site.substr(0, last_slash);
- }
-
- program->set_include_prefix(include_prefix);
- includes_.push_back(program);
- }
-
- std::vector<t_program*>& get_includes() { return includes_; }
-
- void set_include_prefix(std::string include_prefix) {
- include_prefix_ = include_prefix;
-
- // this is intended to be a directory; add a trailing slash if necessary
- std::string::size_type len = include_prefix_.size();
- if (len > 0 && include_prefix_[len - 1] != '/') {
- include_prefix_ += '/';
- }
- }
-
- // Language neutral namespace / packaging
- void set_namespace(std::string language, std::string name_space) {
- if (language != "*") {
- size_t sub_index = language.find('.');
- std::string base_language = language.substr(0, sub_index);
- std::string sub_namespace;
-
- if (base_language == "smalltalk") {
- pwarning(1, "Namespace 'smalltalk' is deprecated. Use 'st' instead");
- base_language = "st";
- }
-
- t_generator_registry::gen_map_t my_copy = t_generator_registry::get_generator_map();
-
- t_generator_registry::gen_map_t::iterator it;
- it = my_copy.find(base_language);
-
- if (it == my_copy.end()) {
- std::string warning = "No generator named '" + base_language + "' could be found!";
- pwarning(1, warning.c_str());
- } else {
- if (sub_index != std::string::npos) {
- std::string sub_namespace = language.substr(sub_index + 1);
- if (!it->second->is_valid_namespace(sub_namespace)) {
- std::string warning = base_language + " generator does not accept '" + sub_namespace
- + "' as sub-namespace!";
- pwarning(1, warning.c_str());
- }
- }
- }
- }
-
- namespaces_[language] = name_space;
- }
-
- std::string get_namespace(std::string language) const {
- std::map<std::string, std::string>::const_iterator iter;
- if ((iter = namespaces_.find(language)) != namespaces_.end()
- || (iter = namespaces_.find("*")) != namespaces_.end()) {
- return iter->second;
- }
- return std::string();
- }
-
- const std::map<std::string, std::string>& get_all_namespaces(){
- return namespaces_;
- }
-
- void set_namespace_annotations(std::string language, std::map<std::string, std::string> annotations) {
- namespace_annotations_[language] = annotations;
- }
-
- const std::map<std::string, std::string>& get_namespace_annotations(std::string language) {
- return namespace_annotations_[language];
- }
-
- // Language specific namespace / packaging
-
- void add_cpp_include(std::string path) { cpp_includes_.push_back(path); }
-
- const std::vector<std::string>& get_cpp_includes() { return cpp_includes_; }
-
- void add_c_include(std::string path) { c_includes_.push_back(path); }
-
- const std::vector<std::string>& get_c_includes() { return c_includes_; }
-
-private:
- // File path
- std::string path_;
-
- // Name
- std::string name_;
-
- // Output directory
- std::string out_path_;
-
- // Output directory is absolute location for generated source (no gen-*)
- bool out_path_is_absolute_;
-
- // Namespace
- std::string namespace_;
-
- // Included programs
- std::vector<t_program*> includes_;
-
- // Include prefix for this program, if any
- std::string include_prefix_;
-
- // Identifier lookup scope
- t_scope* scope_;
-
- // Components to generate code for
- std::vector<t_typedef*> typedefs_;
- std::vector<t_enum*> enums_;
- std::vector<t_const*> consts_;
- std::vector<t_struct*> objects_;
- std::vector<t_struct*> structs_;
- std::vector<t_struct*> xceptions_;
- std::vector<t_service*> services_;
-
- // Dynamic namespaces
- std::map<std::string, std::string> namespaces_;
-
- // Annotations for dynamic namespaces
- std::map<std::string, std::map<std::string, std::string> > namespace_annotations_;
-
- // C++ extra includes
- std::vector<std::string> cpp_includes_;
-
- // C extra includes
- std::vector<std::string> c_includes_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_scope.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h
deleted file mode 100644
index 565fd8f..0000000
--- a/compiler/cpp/src/parse/t_scope.h
+++ /dev/null
@@ -1,181 +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.
- */
-
-#ifndef T_SCOPE_H
-#define T_SCOPE_H
-
-#include <map>
-#include <string>
-#include <sstream>
-
-#include "t_type.h"
-#include "t_service.h"
-#include "t_const.h"
-#include "t_const_value.h"
-#include "t_base_type.h"
-#include "t_map.h"
-#include "t_list.h"
-
-namespace plugin_output {
-template <typename From, typename To>
-void convert(From*, To&);
-}
-
-/**
- * This represents a variable scope used for looking up predefined types and
- * services. Typically, a scope is associated with a t_program. Scopes are not
- * used to determine code generation, but rather to resolve identifiers at
- * parse time.
- *
- */
-class t_scope {
-public:
- t_scope() {}
-
- void add_type(std::string name, t_type* type) { types_[name] = type; }
-
- t_type* get_type(std::string name) { return types_[name]; }
-
- void add_service(std::string name, t_service* service) { services_[name] = service; }
-
- t_service* get_service(std::string name) { return services_[name]; }
-
- void add_constant(std::string name, t_const* constant) {
- if (constants_.find(name) != constants_.end()) {
- throw "Enum " + name + " is already defined!";
- } else {
- constants_[name] = constant;
- }
- }
-
- t_const* get_constant(std::string name) { return constants_[name]; }
-
- void print() {
- std::map<std::string, t_type*>::iterator iter;
- for (iter = types_.begin(); iter != types_.end(); ++iter) {
- printf("%s => %s\n", iter->first.c_str(), iter->second->get_name().c_str());
- }
- }
-
- void resolve_const_value(t_const_value* const_val, t_type* ttype) {
- if (ttype->is_map()) {
- const std::map<t_const_value*, t_const_value*>& map = const_val->get_map();
- std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
- for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
- resolve_const_value(v_iter->first, ((t_map*)ttype)->get_key_type());
- resolve_const_value(v_iter->second, ((t_map*)ttype)->get_val_type());
- }
- } else if (ttype->is_list() || ttype->is_set()) {
- const std::vector<t_const_value*>& val = const_val->get_list();
- std::vector<t_const_value*>::const_iterator v_iter;
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- resolve_const_value((*v_iter), ((t_list*)ttype)->get_elem_type());
- }
- } else if (ttype->is_struct()) {
- t_struct* tstruct = (t_struct*)ttype;
- const std::map<t_const_value*, t_const_value*>& map = const_val->get_map();
- std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
- for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
- t_field* field = tstruct->get_field_by_name(v_iter->first->get_string());
- if (field == NULL) {
- throw "No field named \"" + v_iter->first->get_string()
- + "\" was found in struct of type \"" + tstruct->get_name() + "\"";
- }
- resolve_const_value(v_iter->second, field->get_type());
- }
- } else if (const_val->get_type() == t_const_value::CV_IDENTIFIER) {
- if (ttype->is_enum()) {
- const_val->set_enum((t_enum*)ttype);
- } else {
- t_const* constant = get_constant(const_val->get_identifier());
- if (constant == NULL) {
- throw "No enum value or constant found named \"" + const_val->get_identifier() + "\"!";
- }
-
- // Resolve typedefs to the underlying type
- t_type* const_type = constant->get_type()->get_true_type();
-
- if (const_type->is_base_type()) {
- switch (((t_base_type*)const_type)->get_base()) {
- case t_base_type::TYPE_I16:
- case t_base_type::TYPE_I32:
- case t_base_type::TYPE_I64:
- case t_base_type::TYPE_BOOL:
- case t_base_type::TYPE_I8:
- const_val->set_integer(constant->get_value()->get_integer());
- break;
- case t_base_type::TYPE_STRING:
- const_val->set_string(constant->get_value()->get_string());
- break;
- case t_base_type::TYPE_DOUBLE:
- const_val->set_double(constant->get_value()->get_double());
- break;
- case t_base_type::TYPE_VOID:
- throw "Constants cannot be of type VOID";
- }
- } else if (const_type->is_map()) {
- const std::map<t_const_value*, t_const_value*>& map = constant->get_value()->get_map();
- std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
-
- const_val->set_map();
- for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
- const_val->add_map(v_iter->first, v_iter->second);
- }
- } else if (const_type->is_list()) {
- const std::vector<t_const_value*>& val = constant->get_value()->get_list();
- std::vector<t_const_value*>::const_iterator v_iter;
-
- const_val->set_list();
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- const_val->add_list(*v_iter);
- }
- }
- }
- } else if (ttype->is_enum()) {
- // enum constant with non-identifier value. set the enum and find the
- // value's name.
- t_enum* tenum = (t_enum*)ttype;
- t_enum_value* enum_value = tenum->get_constant_by_value(const_val->get_integer());
- if (enum_value == NULL) {
- std::ostringstream valstm;
- valstm << const_val->get_integer();
- throw "Couldn't find a named value in enum " + tenum->get_name() + " for value "
- + valstm.str();
- }
- const_val->set_identifier(tenum->get_name() + "." + enum_value->get_name());
- const_val->set_enum(tenum);
- }
- }
-
-private:
- // Map of names to types
- std::map<std::string, t_type*> types_;
-
- // Map of names to constants
- std::map<std::string, t_const*> constants_;
-
- // Map of names to services
- std::map<std::string, t_service*> services_;
-
- // to list map entries
- template <typename From, typename To>
- friend void plugin_output::convert(From*, To&);
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_service.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_service.h b/compiler/cpp/src/parse/t_service.h
deleted file mode 100644
index 6fa8398..0000000
--- a/compiler/cpp/src/parse/t_service.h
+++ /dev/null
@@ -1,61 +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.
- */
-
-#ifndef T_SERVICE_H
-#define T_SERVICE_H
-
-#include "t_function.h"
-#include <vector>
-
-class t_program;
-
-/**
- * A service consists of a set of functions.
- *
- */
-class t_service : public t_type {
-public:
- t_service(t_program* program) : t_type(program), extends_(NULL) {}
-
- bool is_service() const { return true; }
-
- void set_extends(t_service* extends) { extends_ = extends; }
-
- void add_function(t_function* func) {
- std::vector<t_function*>::const_iterator iter;
- for (iter = functions_.begin(); iter != functions_.end(); ++iter) {
- if (func->get_name() == (*iter)->get_name()) {
- throw "Function " + func->get_name() + " is already defined";
- }
- }
- functions_.push_back(func);
- }
-
- const std::vector<t_function*>& get_functions() const { return functions_; }
-
- t_service* get_extends() { return extends_; }
-
- const t_service* get_extends() const { return extends_; }
-
-private:
- std::vector<t_function*> functions_;
- t_service* extends_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_set.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_set.h b/compiler/cpp/src/parse/t_set.h
deleted file mode 100644
index 8a46480..0000000
--- a/compiler/cpp/src/parse/t_set.h
+++ /dev/null
@@ -1,41 +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.
- */
-
-#ifndef T_SET_H
-#define T_SET_H
-
-#include "t_container.h"
-
-/**
- * A set is a lightweight container type that just wraps another data type.
- *
- */
-class t_set : public t_container {
-public:
- t_set(t_type* elem_type) : elem_type_(elem_type) {}
-
- t_type* get_elem_type() const { return elem_type_; }
-
- bool is_set() const { return true; }
-
-private:
- t_type* elem_type_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_struct.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h
deleted file mode 100644
index 1f48f91..0000000
--- a/compiler/cpp/src/parse/t_struct.h
+++ /dev/null
@@ -1,171 +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.
- */
-
-#ifndef T_STRUCT_H
-#define T_STRUCT_H
-
-#include <algorithm>
-#include <vector>
-#include <utility>
-#include <string>
-
-#include "t_type.h"
-#include "t_field.h"
-
-// Forward declare that puppy
-class t_program;
-
-/**
- * A struct is a container for a set of member fields that has a name. Structs
- * are also used to implement exception types.
- *
- */
-class t_struct : public t_type {
-public:
- typedef std::vector<t_field*> members_type;
-
- t_struct(t_program* program)
- : t_type(program),
- is_xception_(false),
- is_union_(false),
- members_validated(false),
- members_with_value(0),
- xsd_all_(false) {}
-
- t_struct(t_program* program, const std::string& name)
- : t_type(program, name),
- is_xception_(false),
- is_union_(false),
- members_validated(false),
- members_with_value(0),
- xsd_all_(false) {}
-
- void set_name(const std::string& name) {
- name_ = name;
- validate_union_members();
- }
-
- void set_xception(bool is_xception) { is_xception_ = is_xception; }
-
- void validate_union_member(t_field* field) {
- if (is_union_ && (!name_.empty())) {
-
- // 1) unions can't have required fields
- // 2) union members are implicitly optional, otherwise bugs like THRIFT-3650 wait to happen
- if (field->get_req() != t_field::T_OPTIONAL) {
- // no warning on default requiredness, but do warn on anything else that is explicitly asked for
- if(field->get_req() != t_field::T_OPT_IN_REQ_OUT) {
- pwarning(1,
- "Union %s field %s: union members must be optional, ignoring specified requiredness.\n",
- name_.c_str(),
- field->get_name().c_str());
- }
- field->set_req(t_field::T_OPTIONAL);
- }
-
- // unions may have up to one member defaulted, but not more
- if (field->get_value() != NULL) {
- if (1 < ++members_with_value) {
- throw "Error: Field " + field->get_name() + " provides another default value for union "
- + name_;
- }
- }
- }
- }
-
- void validate_union_members() {
- if (is_union_ && (!name_.empty()) && (!members_validated)) {
- members_type::const_iterator m_iter;
- for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
- validate_union_member(*m_iter);
- }
- members_validated = true;
- }
- }
-
- void set_union(bool is_union) {
- is_union_ = is_union;
- validate_union_members();
- }
-
- void set_xsd_all(bool xsd_all) { xsd_all_ = xsd_all; }
-
- bool get_xsd_all() const { return xsd_all_; }
-
- bool append(t_field* elem) {
- typedef members_type::iterator iter_type;
- std::pair<iter_type, iter_type> bounds = std::equal_range(members_in_id_order_.begin(),
- members_in_id_order_.end(),
- elem,
- t_field::key_compare());
- if (bounds.first != bounds.second) {
- return false;
- }
- // returns false when there is a conflict of field names
- if (get_field_by_name(elem->get_name()) != NULL) {
- return false;
- }
- members_.push_back(elem);
- members_in_id_order_.insert(bounds.second, elem);
- validate_union_member(elem);
- return true;
- }
-
- const members_type& get_members() const { return members_; }
-
- const members_type& get_sorted_members() { return members_in_id_order_; }
-
- bool is_struct() const { return !is_xception_; }
-
- bool is_xception() const { return is_xception_; }
-
- bool is_union() const { return is_union_; }
-
- t_field* get_field_by_name(std::string field_name) {
- members_type::const_iterator m_iter;
- for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
- if ((*m_iter)->get_name() == field_name) {
- return *m_iter;
- }
- }
- return NULL;
- }
-
- const t_field* get_field_by_name(std::string field_name) const {
- members_type::const_iterator m_iter;
- for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
- if ((*m_iter)->get_name() == field_name) {
- return *m_iter;
- }
- }
- return NULL;
- }
-
-private:
- members_type members_;
- members_type members_in_id_order_;
- bool is_xception_;
- bool is_union_;
- bool members_validated;
- int members_with_value;
-
- bool xsd_all_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_type.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h
deleted file mode 100644
index bea4ee1..0000000
--- a/compiler/cpp/src/parse/t_type.h
+++ /dev/null
@@ -1,108 +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.
- */
-
-#ifndef T_TYPE_H
-#define T_TYPE_H
-
-#include <string>
-#include <map>
-#include <cstring>
-#include <stdint.h>
-#include "t_doc.h"
-
-class t_program;
-
-/**
- * Generic representation of a thrift type. These objects are used by the
- * parser module to build up a tree of object that are all explicitly typed.
- * The generic t_type class exports a variety of useful methods that are
- * used by the code generator to branch based upon different handling for the
- * various types.
- *
- */
-class t_type : public t_doc {
-public:
- virtual ~t_type() {}
-
- virtual void set_name(const std::string& name) { name_ = name; }
-
- virtual const std::string& get_name() const { return name_; }
-
- virtual bool is_void() const { return false; }
- virtual bool is_base_type() const { return false; }
- virtual bool is_string() const { return false; }
- virtual bool is_bool() const { return false; }
- virtual bool is_typedef() const { return false; }
- virtual bool is_enum() const { return false; }
- virtual bool is_struct() const { return false; }
- virtual bool is_xception() const { return false; }
- virtual bool is_container() const { return false; }
- virtual bool is_list() const { return false; }
- virtual bool is_set() const { return false; }
- virtual bool is_map() const { return false; }
- virtual bool is_service() const { return false; }
-
- t_program* get_program() { return program_; }
-
- const t_program* get_program() const { return program_; }
-
- t_type* get_true_type();
- const t_type* get_true_type() const;
-
- // This function will break (maybe badly) unless 0 <= num <= 16.
- static char nybble_to_xdigit(int num) {
- if (num < 10) {
- return '0' + num;
- } else {
- return 'A' + num - 10;
- }
- }
-
- static std::string byte_to_hex(uint8_t byte) {
- std::string rv;
- rv += nybble_to_xdigit(byte >> 4);
- rv += nybble_to_xdigit(byte & 0x0f);
- return rv;
- }
-
- std::map<std::string, std::string> annotations_;
-
-protected:
- t_type() : program_(NULL) { ; }
-
- t_type(t_program* program) : program_(program) { ; }
-
- t_type(t_program* program, std::string name) : program_(program), name_(name) { ; }
-
- t_type(std::string name) : program_(NULL), name_(name) { ; }
-
- t_program* program_;
- std::string name_;
-};
-
-/**
- * Placeholder struct for returning the key and value of an annotation
- * during parsing.
- */
-struct t_annotation {
- std::string key;
- std::string val;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_typedef.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_typedef.cc b/compiler/cpp/src/parse/t_typedef.cc
deleted file mode 100644
index ddbe749..0000000
--- a/compiler/cpp/src/parse/t_typedef.cc
+++ /dev/null
@@ -1,34 +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 <cstdio>
-
-#include "t_typedef.h"
-#include "t_program.h"
-
-t_type* t_typedef::get_type() const {
- if (type_ == NULL) {
- t_type* type = get_program()->scope()->get_type(symbolic_);
- if (type == NULL) {
- printf("Type \"%s\" not defined\n", symbolic_.c_str());
- exit(1);
- }
- return type;
- }
- return type_;
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/parse/t_typedef.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_typedef.h b/compiler/cpp/src/parse/t_typedef.h
deleted file mode 100644
index a39a246..0000000
--- a/compiler/cpp/src/parse/t_typedef.h
+++ /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.
- */
-
-#ifndef T_TYPEDEF_H
-#define T_TYPEDEF_H
-
-#include <string>
-#include "t_type.h"
-
-/**
- * A typedef is a mapping from a symbolic name to another type. In dymanically
- * typed languages (i.e. php/python) the code generator can actually usually
- * ignore typedefs and just use the underlying type directly, though in C++
- * the symbolic naming can be quite useful for code clarity.
- *
- */
-class t_typedef : public t_type {
-public:
- t_typedef(t_program* program, t_type* type, const std::string& symbolic)
- : t_type(program, symbolic), type_(type), symbolic_(symbolic), forward_(false), seen_(false) {}
-
- /**
- * This constructor is used to refer to a type that is lazily
- * resolved at a later time, like for forward declarations or
- * recursive types.
- */
- t_typedef(t_program* program, const std::string& symbolic, bool forward)
- : t_type(program, symbolic),
- type_(NULL),
- symbolic_(symbolic),
- forward_(forward),
- seen_(false) {}
-
- ~t_typedef() {}
-
- t_type* get_type() const;
-
- const std::string& get_symbolic() const { return symbolic_; }
-
- bool is_forward_typedef() const { return forward_; }
-
- bool is_typedef() const { return true; }
-
-private:
- t_type* type_;
- std::string symbolic_;
- bool forward_;
- mutable bool seen_;
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/platform.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/platform.h b/compiler/cpp/src/platform.h
deleted file mode 100644
index 8cbe9db..0000000
--- a/compiler/cpp/src/platform.h
+++ /dev/null
@@ -1,47 +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.
- */
-
-/**
- * define for mkdir,since the method signature
- * is different for the non-POSIX MinGW
- */
-
-#ifdef _MSC_VER
-#include "windows/config.h"
-#endif
-
-#ifdef _WIN32
-#include <direct.h>
-#include <io.h>
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-
-#ifdef _WIN32
-#define MKDIR(x) mkdir(x)
-#else
-#define MKDIR(x) mkdir(x, S_IRWXU | S_IRWXG | S_IRWXO)
-#endif
-
-#ifdef PATH_MAX
-#define THRIFT_PATH_MAX PATH_MAX
-#else
-#define THRIFT_PATH_MAX MAX_PATH
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/052abc39/compiler/cpp/src/plugin/Makefile.am
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/plugin/Makefile.am b/compiler/cpp/src/plugin/Makefile.am
deleted file mode 100644
index 7e3c82d..0000000
--- a/compiler/cpp/src/plugin/Makefile.am
+++ /dev/null
@@ -1,47 +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.
-#
-#
-# Contains some contributions under the Thrift Software License.
-# Please see doc/old-thrift-license.txt in the Thrift distribution for
-# details.
-
-AUTOMAKE_OPTIONS = subdir-objects
-
-if WITH_PLUGIN
-plugin_gen = plugin_types.h \
- plugin_types.cpp \
- plugin_constants.h \
- plugin_constants.cpp
-
-BUILT_SOURCES = $(plugin_gen)
-gen.stamp: plugin.thrift $(top_builddir)/compiler/cpp/src/thrift-bootstrap
- @$(RM) -f gen.tmp
- @touch gen.tmp
- $(top_builddir)/compiler/cpp/src/thrift-bootstrap -gen cpp -out . $<
- @mv -f gen.tmp $@
-
-$(plugin_gen): gen.stamp
- @if test -f $@; then :; else \
- $(RM) -f gen.stamp; \
- $(MAKE) $(AM_MAKEFLAGS) gen.stamp; \
- fi
-
-clean-local:
- $(RM) version.h windows/version.h $(plugin_gen)
-endif