You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by rl...@apache.org on 2016/05/18 02:50:36 UTC
[23/51] [abbrv] [partial] incubator-hawq git commit: HAWQ-735. Import
thrift-0.9.3 into depends/thirdparty/thrift folder
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/globals.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/globals.h b/depends/thirdparty/thrift/compiler/cpp/src/globals.h
new file mode 100644
index 0000000..af90616
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/globals.h
@@ -0,0 +1,156 @@
+/*
+ * 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_GLOBALS_H
+#define T_GLOBALS_H
+
+#include <set>
+#include <queue>
+#include <stack>
+#include <vector>
+#include <string>
+
+/**
+ * This module contains all the global variables (slap on the wrist) that are
+ * shared throughout the program. The reason for this is to facilitate simple
+ * interaction between the parser and the rest of the program. Before calling
+ * yyparse(), the main.cc program will make necessary adjustments to these
+ * global variables such that the parser does the right thing and puts entries
+ * into the right containers, etc.
+ *
+ */
+
+/**
+ * Hooray for forward declaration of types!
+ */
+
+class t_program;
+class t_scope;
+class t_type;
+
+/**
+ * Parsing mode, two passes up in this gin rummy!
+ */
+
+enum PARSE_MODE { INCLUDES = 1, PROGRAM = 2 };
+
+/**
+ * Strictness level
+ */
+extern int g_strict;
+
+/**
+ * The master program parse tree. This is accessed from within the parser code
+ * to build up the program elements.
+ */
+extern t_program* g_program;
+
+/**
+ * Global types for the parser to be able to reference
+ */
+
+extern t_type* g_type_void;
+extern t_type* g_type_string;
+extern t_type* g_type_binary;
+extern t_type* g_type_slist;
+extern t_type* g_type_bool;
+extern t_type* g_type_byte;
+extern t_type* g_type_i16;
+extern t_type* g_type_i32;
+extern t_type* g_type_i64;
+extern t_type* g_type_double;
+
+/**
+ * The scope that we are currently parsing into
+ */
+extern t_scope* g_scope;
+
+/**
+ * The parent scope to also load symbols into
+ */
+extern t_scope* g_parent_scope;
+
+/**
+ * The prefix for the parent scope entries
+ */
+extern std::string g_parent_prefix;
+
+/**
+ * The parsing pass that we are on. We do different things on each pass.
+ */
+extern PARSE_MODE g_parse_mode;
+
+/**
+ * Global time string, used in formatting error messages etc.
+ */
+extern char* g_time_str;
+
+/**
+ * The last parsed doctext comment.
+ */
+extern char* g_doctext;
+
+/**
+ * The location of the last parsed doctext comment.
+ */
+extern int g_doctext_lineno;
+
+/**
+ * Status of program level doctext candidate
+ */
+enum PROGDOCTEXT_STATUS {
+ INVALID = 0,
+ STILL_CANDIDATE = 1, // the text may or may not be the program doctext
+ ALREADY_PROCESSED = 2, // doctext has been used and is no longer available
+ ABSOLUTELY_SURE = 3, // this is the program doctext
+ NO_PROGRAM_DOCTEXT = 4 // there is no program doctext
+};
+
+/**
+ * The program level doctext. Stored separately to make parsing easier.
+ */
+extern char* g_program_doctext_candidate;
+extern int g_program_doctext_lineno;
+extern PROGDOCTEXT_STATUS g_program_doctext_status;
+
+/**
+ * Whether or not negative field keys are accepted.
+ *
+ * When a field does not have a user-specified key, thrift automatically
+ * assigns a negative value. However, this is fragile since changes to the
+ * file may unintentionally change the key numbering, resulting in a new
+ * protocol that is not backwards compatible.
+ *
+ * When g_allow_neg_field_keys is enabled, users can explicitly specify
+ * negative keys. This way they can write a .thrift file with explicitly
+ * specified keys that is still backwards compatible with older .thrift files
+ * that did not specify key values.
+ */
+extern int g_allow_neg_field_keys;
+
+/**
+ * Whether or not 64-bit constants will generate a warning.
+ *
+ * Some languages don't support 64-bit constants, but many do, so we can
+ * suppress this warning for projects that don't use any non-64-bit-safe
+ * languages.
+ */
+extern int g_allow_64bit_consts;
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/logging.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/logging.h b/depends/thirdparty/thrift/compiler/cpp/src/logging.h
new file mode 100644
index 0000000..3f1fce8
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/logging.h
@@ -0,0 +1,45 @@
+/*
+ * 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_LOGGING_H
+#define T_LOGGING_H
+
+#include <string>
+
+/**
+ * Parse debugging output, used to print helpful info
+ */
+void pdebug(const char* fmt, ...);
+
+/**
+ * Parser warning
+ */
+void pwarning(int level, const char* fmt, ...);
+
+/**
+ * Print verbose output message
+ */
+void pverbose(const char* fmt, ...);
+
+/**
+ * Failure!
+ */
+void failure(const char* fmt, ...);
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/main.cc
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/main.cc b/depends/thirdparty/thrift/compiler/cpp/src/main.cc
new file mode 100644
index 0000000..e11d9b0
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/main.cc
@@ -0,0 +1,1290 @@
+/*
+ * 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.
+ */
+
+/**
+ * thrift - a lightweight cross-language rpc/serialization tool
+ *
+ * This file contains the main compiler engine for Thrift, which invokes the
+ * scanner/parser to build the thrift object tree. The interface generation
+ * code for each language lives in a file by the language name under the
+ * generate/ folder, and all parse structures live in parse/
+ *
+ */
+
+#include <cassert>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+#include <string>
+#include <algorithm>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <limits.h>
+
+#ifdef _WIN32
+#include <windows.h> /* for GetFullPathName */
+#endif
+
+// Careful: must include globals first for extern definitions
+#include "globals.h"
+
+#include "platform.h"
+#include "main.h"
+#include "parse/t_program.h"
+#include "parse/t_scope.h"
+#include "generate/t_generator.h"
+#include "audit/t_audit.h"
+
+#include "version.h"
+
+using namespace std;
+
+/**
+ * Global program tree
+ */
+t_program* g_program;
+
+/**
+ * Global types
+ */
+
+t_type* g_type_void;
+t_type* g_type_string;
+t_type* g_type_binary;
+t_type* g_type_slist;
+t_type* g_type_bool;
+t_type* g_type_byte;
+t_type* g_type_i16;
+t_type* g_type_i32;
+t_type* g_type_i64;
+t_type* g_type_double;
+
+/**
+ * Global scope
+ */
+t_scope* g_scope;
+
+/**
+ * Parent scope to also parse types
+ */
+t_scope* g_parent_scope;
+
+/**
+ * Prefix for putting types in parent scope
+ */
+string g_parent_prefix;
+
+/**
+ * Parsing pass
+ */
+PARSE_MODE g_parse_mode;
+
+/**
+ * Current directory of file being parsed
+ */
+string g_curdir;
+
+/**
+ * Current file being parsed
+ */
+string g_curpath;
+
+/**
+ * Search path for inclusions
+ */
+vector<string> g_incl_searchpath;
+
+/**
+ * Global debug state
+ */
+int g_debug = 0;
+
+/**
+ * Strictness level
+ */
+int g_strict = 127;
+
+/**
+ * Warning level
+ */
+int g_warn = 1;
+
+/**
+ * Verbose output
+ */
+int g_verbose = 0;
+
+/**
+ * Global time string
+ */
+char* g_time_str;
+
+/**
+ * The last parsed doctext comment.
+ */
+char* g_doctext;
+
+/**
+ * The location of the last parsed doctext comment.
+ */
+int g_doctext_lineno;
+
+/**
+ * The First doctext comment
+ */
+char* g_program_doctext_candidate;
+int g_program_doctext_lineno = 0;
+PROGDOCTEXT_STATUS g_program_doctext_status = INVALID;
+
+/**
+ * Whether or not negative field keys are accepted.
+ */
+int g_allow_neg_field_keys;
+
+/**
+ * Whether or not 64-bit constants will generate a warning.
+ */
+int g_allow_64bit_consts = 0;
+
+/**
+ * Flags to control code generation
+ */
+bool gen_recurse = false;
+
+/**
+ * Flags to control thrift audit
+ */
+bool g_audit = false;
+
+/**
+ * Flag to control return status
+ */
+bool g_return_failure = false;
+bool g_audit_fatal = true;
+
+/**
+ * Win32 doesn't have realpath, so use fallback implementation in that case,
+ * otherwise this just calls through to realpath
+ */
+char* saferealpath(const char* path, char* resolved_path) {
+#ifdef _WIN32
+ char buf[MAX_PATH];
+ char* basename;
+ DWORD len = GetFullPathName(path, MAX_PATH, buf, &basename);
+ if (len == 0 || len > MAX_PATH - 1) {
+ strcpy(resolved_path, path);
+ } else {
+ strcpy(resolved_path, buf);
+ }
+
+ // Replace backslashes with forward slashes so the
+ // rest of the code behaves correctly.
+ size_t resolved_len = strlen(resolved_path);
+ for (size_t i = 0; i < resolved_len; i++) {
+ if (resolved_path[i] == '\\') {
+ resolved_path[i] = '/';
+ }
+ }
+ return resolved_path;
+#else
+ return realpath(path, resolved_path);
+#endif
+}
+
+bool check_is_directory(const char* dir_name) {
+#ifdef _WIN32
+ DWORD attributes = ::GetFileAttributesA(dir_name);
+ if (attributes == INVALID_FILE_ATTRIBUTES) {
+ fprintf(stderr,
+ "Output directory %s is unusable: GetLastError() = %ld\n",
+ dir_name,
+ GetLastError());
+ return false;
+ }
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
+ fprintf(stderr, "Output directory %s exists but is not a directory\n", dir_name);
+ return false;
+ }
+ return true;
+#else
+ struct stat sb;
+ if (stat(dir_name, &sb) < 0) {
+ fprintf(stderr, "Output directory %s is unusable: %s\n", dir_name, strerror(errno));
+ return false;
+ }
+ if (!S_ISDIR(sb.st_mode)) {
+ fprintf(stderr, "Output directory %s exists but is not a directory\n", dir_name);
+ return false;
+ }
+ return true;
+#endif
+}
+
+/**
+ * Report an error to the user. This is called yyerror for historical
+ * reasons (lex and yacc expect the error reporting routine to be called
+ * this). Call this function to report any errors to the user.
+ * yyerror takes printf style arguments.
+ *
+ * @param fmt C format string followed by additional arguments
+ */
+void yyerror(const char* fmt, ...) {
+ va_list args;
+ fprintf(stderr, "[ERROR:%s:%d] (last token was '%s')\n", g_curpath.c_str(), yylineno, yytext);
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+
+ fprintf(stderr, "\n");
+}
+
+/**
+ * Prints a debug message from the parser.
+ *
+ * @param fmt C format string followed by additional arguments
+ */
+void pdebug(const char* fmt, ...) {
+ if (g_debug == 0) {
+ return;
+ }
+ va_list args;
+ printf("[PARSE:%d] ", yylineno);
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+ printf("\n");
+}
+
+/**
+ * Prints a verbose output mode message
+ *
+ * @param fmt C format string followed by additional arguments
+ */
+void pverbose(const char* fmt, ...) {
+ if (g_verbose == 0) {
+ return;
+ }
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+/**
+ * Prints a warning message
+ *
+ * @param fmt C format string followed by additional arguments
+ */
+void pwarning(int level, const char* fmt, ...) {
+ if (g_warn < level) {
+ return;
+ }
+ va_list args;
+ printf("[WARNING:%s:%d] ", g_curpath.c_str(), yylineno);
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+ printf("\n");
+}
+
+/**
+ * Prints a failure message and exits
+ *
+ * @param fmt C format string followed by additional arguments
+ */
+void failure(const char* fmt, ...) {
+ va_list args;
+ fprintf(stderr, "[FAILURE:%s:%d] ", g_curpath.c_str(), yylineno);
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ printf("\n");
+ exit(1);
+}
+
+/**
+ * Converts a string filename into a thrift program name
+ */
+string program_name(string filename) {
+ string::size_type slash = filename.rfind("/");
+ if (slash != string::npos) {
+ filename = filename.substr(slash + 1);
+ }
+ string::size_type dot = filename.rfind(".");
+ if (dot != string::npos) {
+ filename = filename.substr(0, dot);
+ }
+ return filename;
+}
+
+/**
+ * Gets the directory path of a filename
+ */
+string directory_name(string filename) {
+ string::size_type slash = filename.rfind("/");
+ // No slash, just use the current directory
+ if (slash == string::npos) {
+ return ".";
+ }
+ return filename.substr(0, slash);
+}
+
+/**
+ * Finds the appropriate file path for the given filename
+ */
+string include_file(string filename) {
+ // Absolute path? Just try that
+ if (filename[0] == '/') {
+ // Realpath!
+ char rp[THRIFT_PATH_MAX];
+ if (saferealpath(filename.c_str(), rp) == NULL) {
+ pwarning(0, "Cannot open include file %s\n", filename.c_str());
+ return std::string();
+ }
+
+ // Stat this file
+ struct stat finfo;
+ if (stat(rp, &finfo) == 0) {
+ return rp;
+ }
+ } else { // relative path, start searching
+ // new search path with current dir global
+ vector<string> sp = g_incl_searchpath;
+ sp.insert(sp.begin(), g_curdir);
+
+ // iterate through paths
+ vector<string>::iterator it;
+ for (it = sp.begin(); it != sp.end(); it++) {
+ string sfilename = *(it) + "/" + filename;
+
+ // Realpath!
+ char rp[THRIFT_PATH_MAX];
+ if (saferealpath(sfilename.c_str(), rp) == NULL) {
+ continue;
+ }
+
+ // Stat this files
+ struct stat finfo;
+ if (stat(rp, &finfo) == 0) {
+ return rp;
+ }
+ }
+ }
+
+ // Uh oh
+ pwarning(0, "Could not find include file %s\n", filename.c_str());
+ return std::string();
+}
+
+/**
+ * Clears any previously stored doctext string.
+ * Also prints a warning if we are discarding information.
+ */
+void clear_doctext() {
+ if (g_doctext != NULL) {
+ pwarning(2, "Uncaptured doctext at on line %d.", g_doctext_lineno);
+ }
+ free(g_doctext);
+ g_doctext = NULL;
+}
+
+/**
+ * Reset program doctext information after processing a file
+ */
+void reset_program_doctext_info() {
+ if (g_program_doctext_candidate != NULL) {
+ free(g_program_doctext_candidate);
+ g_program_doctext_candidate = NULL;
+ }
+ g_program_doctext_lineno = 0;
+ g_program_doctext_status = INVALID;
+ pdebug("%s", "program doctext set to INVALID");
+}
+
+/**
+ * We are sure the program doctext candidate is really the program doctext.
+ */
+void declare_valid_program_doctext() {
+ if ((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
+ g_program_doctext_status = ABSOLUTELY_SURE;
+ pdebug("%s", "program doctext set to ABSOLUTELY_SURE");
+ } else {
+ g_program_doctext_status = NO_PROGRAM_DOCTEXT;
+ pdebug("%s", "program doctext set to NO_PROGRAM_DOCTEXT");
+ }
+}
+
+/**
+ * Cleans up text commonly found in doxygen-like comments
+ *
+ * Warning: if you mix tabs and spaces in a non-uniform way,
+ * you will get what you deserve.
+ */
+char* clean_up_doctext(char* doctext) {
+ // Convert to C++ string, and remove Windows's carriage returns.
+ string docstring = doctext;
+ docstring.erase(remove(docstring.begin(), docstring.end(), '\r'), docstring.end());
+
+ // Separate into lines.
+ vector<string> lines;
+ string::size_type pos = string::npos;
+ string::size_type last;
+ while (true) {
+ last = (pos == string::npos) ? 0 : pos + 1;
+ pos = docstring.find('\n', last);
+ if (pos == string::npos) {
+ // First bit of cleaning. If the last line is only whitespace, drop it.
+ string::size_type nonwhite = docstring.find_first_not_of(" \t", last);
+ if (nonwhite != string::npos) {
+ lines.push_back(docstring.substr(last));
+ }
+ break;
+ }
+ lines.push_back(docstring.substr(last, pos - last));
+ }
+
+ // A very profound docstring.
+ if (lines.empty()) {
+ return NULL;
+ }
+
+ // Clear leading whitespace from the first line.
+ pos = lines.front().find_first_not_of(" \t");
+ lines.front().erase(0, pos);
+
+ // If every nonblank line after the first has the same number of spaces/tabs,
+ // then a star, remove them.
+ bool have_prefix = true;
+ bool found_prefix = false;
+ string::size_type prefix_len = 0;
+ vector<string>::iterator l_iter;
+ for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
+ if (l_iter->empty()) {
+ continue;
+ }
+
+ pos = l_iter->find_first_not_of(" \t");
+ if (!found_prefix) {
+ if (pos != string::npos) {
+ if (l_iter->at(pos) == '*') {
+ found_prefix = true;
+ prefix_len = pos;
+ } else {
+ have_prefix = false;
+ break;
+ }
+ } else {
+ // Whitespace-only line. Truncate it.
+ l_iter->clear();
+ }
+ } else if (l_iter->size() > pos && l_iter->at(pos) == '*' && pos == prefix_len) {
+ // Business as usual.
+ } else if (pos == string::npos) {
+ // Whitespace-only line. Let's truncate it for them.
+ l_iter->clear();
+ } else {
+ // The pattern has been broken.
+ have_prefix = false;
+ break;
+ }
+ }
+
+ // If our prefix survived, delete it from every line.
+ if (have_prefix) {
+ // Get the star too.
+ prefix_len++;
+ for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
+ l_iter->erase(0, prefix_len);
+ }
+ }
+
+ // Now delete the minimum amount of leading whitespace from each line.
+ prefix_len = string::npos;
+ for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
+ if (l_iter->empty()) {
+ continue;
+ }
+ pos = l_iter->find_first_not_of(" \t");
+ if (pos != string::npos && (prefix_len == string::npos || pos < prefix_len)) {
+ prefix_len = pos;
+ }
+ }
+
+ // If our prefix survived, delete it from every line.
+ if (prefix_len != string::npos) {
+ for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
+ l_iter->erase(0, prefix_len);
+ }
+ }
+
+ // Remove trailing whitespace from every line.
+ for (l_iter = lines.begin(); l_iter != lines.end(); ++l_iter) {
+ pos = l_iter->find_last_not_of(" \t");
+ if (pos != string::npos && pos != l_iter->length() - 1) {
+ l_iter->erase(pos + 1);
+ }
+ }
+
+ // If the first line is empty, remove it.
+ // Don't do this earlier because a lot of steps skip the first line.
+ if (lines.front().empty()) {
+ lines.erase(lines.begin());
+ }
+
+ // Now rejoin the lines and copy them back into doctext.
+ docstring.clear();
+ for (l_iter = lines.begin(); l_iter != lines.end(); ++l_iter) {
+ docstring += *l_iter;
+ docstring += '\n';
+ }
+
+ // assert(docstring.length() <= strlen(doctext)); may happen, see THRIFT-1755
+ if (docstring.length() <= strlen(doctext)) {
+ strcpy(doctext, docstring.c_str());
+ } else {
+ free(doctext); // too short
+ doctext = strdup(docstring.c_str());
+ }
+ return doctext;
+}
+
+/** Set to true to debug docstring parsing */
+static bool dump_docs = false;
+
+/**
+ * Dumps docstrings to stdout
+ * Only works for top-level definitions and the whole program doc
+ * (i.e., not enum constants, struct fields, or functions.
+ */
+void dump_docstrings(t_program* program) {
+ string progdoc = program->get_doc();
+ if (!progdoc.empty()) {
+ printf("Whole program doc:\n%s\n", progdoc.c_str());
+ }
+ const vector<t_typedef*>& typedefs = program->get_typedefs();
+ vector<t_typedef*>::const_iterator t_iter;
+ for (t_iter = typedefs.begin(); t_iter != typedefs.end(); ++t_iter) {
+ t_typedef* td = *t_iter;
+ if (td->has_doc()) {
+ printf("typedef %s:\n%s\n", td->get_name().c_str(), td->get_doc().c_str());
+ }
+ }
+ const vector<t_enum*>& enums = program->get_enums();
+ vector<t_enum*>::const_iterator e_iter;
+ for (e_iter = enums.begin(); e_iter != enums.end(); ++e_iter) {
+ t_enum* en = *e_iter;
+ if (en->has_doc()) {
+ printf("enum %s:\n%s\n", en->get_name().c_str(), en->get_doc().c_str());
+ }
+ }
+ const vector<t_const*>& consts = program->get_consts();
+ vector<t_const*>::const_iterator c_iter;
+ for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
+ t_const* co = *c_iter;
+ if (co->has_doc()) {
+ printf("const %s:\n%s\n", co->get_name().c_str(), co->get_doc().c_str());
+ }
+ }
+ const vector<t_struct*>& structs = program->get_structs();
+ vector<t_struct*>::const_iterator s_iter;
+ for (s_iter = structs.begin(); s_iter != structs.end(); ++s_iter) {
+ t_struct* st = *s_iter;
+ if (st->has_doc()) {
+ printf("struct %s:\n%s\n", st->get_name().c_str(), st->get_doc().c_str());
+ }
+ }
+ const vector<t_struct*>& xceptions = program->get_xceptions();
+ vector<t_struct*>::const_iterator x_iter;
+ for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
+ t_struct* xn = *x_iter;
+ if (xn->has_doc()) {
+ printf("xception %s:\n%s\n", xn->get_name().c_str(), xn->get_doc().c_str());
+ }
+ }
+ const vector<t_service*>& services = program->get_services();
+ vector<t_service*>::const_iterator v_iter;
+ for (v_iter = services.begin(); v_iter != services.end(); ++v_iter) {
+ t_service* sv = *v_iter;
+ if (sv->has_doc()) {
+ printf("service %s:\n%s\n", sv->get_name().c_str(), sv->get_doc().c_str());
+ }
+ }
+}
+
+/**
+ * Emits a warning on list<byte>, binary type is typically a much better choice.
+ */
+void check_for_list_of_bytes(t_type* list_elem_type) {
+ if ((g_parse_mode == PROGRAM) && (list_elem_type != NULL) && list_elem_type->is_base_type()) {
+ t_base_type* tbase = (t_base_type*)list_elem_type;
+ if (tbase->get_base() == t_base_type::TYPE_BYTE) {
+ pwarning(1, "Consider using the more efficient \"binary\" type instead of \"list<byte>\".");
+ }
+ }
+}
+
+/**
+ * Prints the version number
+ */
+void version() {
+ printf("Thrift version %s\n", THRIFT_VERSION);
+}
+
+/**
+ * Display the usage message and then exit with an error code.
+ */
+void usage() {
+ fprintf(stderr, "Usage: thrift [options] file\n\n");
+ fprintf(stderr, "Use thrift -help for a list of options\n");
+ exit(1);
+}
+
+/**
+ * Diplays the help message and then exits with an error code.
+ */
+void help() {
+ fprintf(stderr, "Usage: thrift [options] file\n");
+ fprintf(stderr, "Options:\n");
+ fprintf(stderr, " -version Print the compiler version\n");
+ fprintf(stderr, " -o dir Set the output directory for gen-* packages\n");
+ fprintf(stderr, " (default: current directory)\n");
+ fprintf(stderr, " -out dir Set the ouput location for generated files.\n");
+ fprintf(stderr, " (no gen-* folder will be created)\n");
+ fprintf(stderr, " -I dir Add a directory to the list of directories\n");
+ fprintf(stderr, " searched for include directives\n");
+ fprintf(stderr, " -nowarn Suppress all compiler warnings (BAD!)\n");
+ fprintf(stderr, " -strict Strict compiler warnings on\n");
+ fprintf(stderr, " -v[erbose] Verbose mode\n");
+ fprintf(stderr, " -r[ecurse] Also generate included files\n");
+ fprintf(stderr, " -debug Parse debug trace to stdout\n");
+ fprintf(stderr,
+ " --allow-neg-keys Allow negative field keys (Used to "
+ "preserve protocol\n");
+ fprintf(stderr, " compatibility with older .thrift files)\n");
+ fprintf(stderr, " --allow-64bit-consts Do not print warnings about using 64-bit constants\n");
+ fprintf(stderr, " --gen STR Generate code with a dynamically-registered generator.\n");
+ fprintf(stderr, " STR has the form language[:key1=val1[,key2[,key3=val3]]].\n");
+ fprintf(stderr, " Keys and values are options passed to the generator.\n");
+ fprintf(stderr, " Many options will not require values.\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Options related to audit operation\n");
+ fprintf(stderr, " --audit OldFile Old Thrift file to be audited with 'file'\n");
+ fprintf(stderr, " -Iold dir Add a directory to the list of directories\n");
+ fprintf(stderr, " searched for include directives for old thrift file\n");
+ fprintf(stderr, " -Inew dir Add a directory to the list of directories\n");
+ fprintf(stderr, " searched for include directives for new thrift file\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Available generators (and options):\n");
+
+ t_generator_registry::gen_map_t gen_map = t_generator_registry::get_generator_map();
+ t_generator_registry::gen_map_t::iterator iter;
+ for (iter = gen_map.begin(); iter != gen_map.end(); ++iter) {
+ fprintf(stderr,
+ " %s (%s):\n",
+ iter->second->get_short_name().c_str(),
+ iter->second->get_long_name().c_str());
+ fprintf(stderr, "%s", iter->second->get_documentation().c_str());
+ }
+ exit(1);
+}
+
+/**
+ * You know, when I started working on Thrift I really thought it wasn't going
+ * to become a programming language because it was just a generator and it
+ * wouldn't need runtime type information and all that jazz. But then we
+ * decided to add constants, and all of a sudden that means runtime type
+ * validation and inference, except the "runtime" is the code generator
+ * runtime.
+ */
+void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
+ if (type->is_void()) {
+ throw "type error: cannot declare a void const: " + name;
+ }
+
+ 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:
+ if (value->get_type() != t_const_value::CV_STRING) {
+ throw "type error: const \"" + name + "\" was declared as string";
+ }
+ break;
+ case t_base_type::TYPE_BOOL:
+ if (value->get_type() != t_const_value::CV_INTEGER) {
+ throw "type error: const \"" + name + "\" was declared as bool";
+ }
+ break;
+ case t_base_type::TYPE_BYTE:
+ if (value->get_type() != t_const_value::CV_INTEGER) {
+ throw "type error: const \"" + name + "\" was declared as byte";
+ }
+ break;
+ case t_base_type::TYPE_I16:
+ if (value->get_type() != t_const_value::CV_INTEGER) {
+ throw "type error: const \"" + name + "\" was declared as i16";
+ }
+ break;
+ case t_base_type::TYPE_I32:
+ if (value->get_type() != t_const_value::CV_INTEGER) {
+ throw "type error: const \"" + name + "\" was declared as i32";
+ }
+ break;
+ case t_base_type::TYPE_I64:
+ if (value->get_type() != t_const_value::CV_INTEGER) {
+ throw "type error: const \"" + name + "\" was declared as i64";
+ }
+ break;
+ case t_base_type::TYPE_DOUBLE:
+ if (value->get_type() != t_const_value::CV_INTEGER
+ && value->get_type() != t_const_value::CV_DOUBLE) {
+ throw "type error: const \"" + name + "\" was declared as double";
+ }
+ break;
+ default:
+ throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase) + name;
+ }
+ } else if (type->is_enum()) {
+ if (value->get_type() != t_const_value::CV_IDENTIFIER) {
+ throw "type error: const \"" + name + "\" was declared as enum";
+ }
+
+ // see if there's a dot in the identifier
+ std::string name_portion = value->get_identifier_name();
+
+ const vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();
+ vector<t_enum_value*>::const_iterator c_iter;
+ bool found = false;
+
+ for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {
+ if ((*c_iter)->get_name() == name_portion) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw "type error: const " + name + " was declared as type " + type->get_name()
+ + " which is an enum, but " + value->get_identifier()
+ + " is not a valid value for that enum";
+ }
+ } else if (type->is_struct() || type->is_xception()) {
+ if (value->get_type() != t_const_value::CV_MAP) {
+ throw "type error: const \"" + name + "\" was declared as struct/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*>& val = value->get_map();
+ map<t_const_value*, t_const_value*>::const_iterator v_iter;
+ for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
+ if (v_iter->first->get_type() != t_const_value::CV_STRING) {
+ throw "type error: " + name + " struct key must be string";
+ }
+ t_type* field_type = NULL;
+ 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 == NULL) {
+ throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
+ }
+
+ validate_const_rec(name + "." + v_iter->first->get_string(), field_type, v_iter->second);
+ }
+ } else if (type->is_map()) {
+ t_type* k_type = ((t_map*)type)->get_key_type();
+ t_type* v_type = ((t_map*)type)->get_val_type();
+ const map<t_const_value*, t_const_value*>& val = value->get_map();
+ map<t_const_value*, t_const_value*>::const_iterator v_iter;
+ for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
+ validate_const_rec(name + "<key>", k_type, v_iter->first);
+ validate_const_rec(name + "<val>", v_type, v_iter->second);
+ }
+ } else if (type->is_list() || type->is_set()) {
+ t_type* e_type;
+ if (type->is_list()) {
+ e_type = ((t_list*)type)->get_elem_type();
+ } else {
+ e_type = ((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) {
+ validate_const_rec(name + "<elem>", e_type, *v_iter);
+ }
+ }
+}
+
+/**
+ * Check simple identifier names
+ * It's easier to do it this way instead of rewriting the whole grammar etc.
+ */
+void validate_simple_identifier(const char* identifier) {
+ string name(identifier);
+ if (name.find(".") != string::npos) {
+ yyerror("Identifier %s can't have a dot.", identifier);
+ exit(1);
+ }
+}
+
+/**
+ * Check the type of the parsed const information against its declared type
+ */
+void validate_const_type(t_const* c) {
+ validate_const_rec(c->get_name(), c->get_type(), c->get_value());
+}
+
+/**
+ * Check the type of a default value assigned to a field.
+ */
+void validate_field_value(t_field* field, t_const_value* cv) {
+ validate_const_rec(field->get_name(), field->get_type(), cv);
+}
+
+/**
+ * Check that all the elements of a throws block are actually exceptions.
+ */
+bool validate_throws(t_struct* throws) {
+ const vector<t_field*>& members = throws->get_members();
+ vector<t_field*>::const_iterator m_iter;
+ for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
+ if (!t_generator::get_true_type((*m_iter)->get_type())->is_xception()) {
+ return false;
+ }
+ }
+ return true;
+}
+
+/**
+ * Skips UTF-8 BOM if there is one
+ */
+bool skip_utf8_bom(FILE* f) {
+
+ // pretty straightforward, but works
+ if (fgetc(f) == 0xEF) {
+ if (fgetc(f) == 0xBB) {
+ if (fgetc(f) == 0xBF) {
+ return true;
+ }
+ }
+ }
+
+ rewind(f);
+ return false;
+}
+
+/**
+ * Parses a program
+ */
+void parse(t_program* program, t_program* parent_program) {
+ // Get scope file path
+ string path = program->get_path();
+
+ // Set current dir global, which is used in the include_file function
+ g_curdir = directory_name(path);
+ g_curpath = path;
+
+ // Open the file
+ // skip UTF-8 BOM if there is one
+ yyin = fopen(path.c_str(), "r");
+ if (yyin == 0) {
+ failure("Could not open input file: \"%s\"", path.c_str());
+ }
+ if (skip_utf8_bom(yyin))
+ pverbose("Skipped UTF-8 BOM at %s\n", path.c_str());
+
+ // Create new scope and scan for includes
+ pverbose("Scanning %s for includes\n", path.c_str());
+ g_parse_mode = INCLUDES;
+ g_program = program;
+ g_scope = program->scope();
+ try {
+ yylineno = 1;
+ if (yyparse() != 0) {
+ failure("Parser error during include pass.");
+ }
+ } catch (string x) {
+ failure(x.c_str());
+ }
+ fclose(yyin);
+
+ // Recursively parse all the include programs
+ vector<t_program*>& includes = program->get_includes();
+ vector<t_program*>::iterator iter;
+ for (iter = includes.begin(); iter != includes.end(); ++iter) {
+ parse(*iter, program);
+ }
+
+ // reset program doctext status before parsing a new file
+ reset_program_doctext_info();
+
+ // Parse the program file
+ g_parse_mode = PROGRAM;
+ g_program = program;
+ g_scope = program->scope();
+ g_parent_scope = (parent_program != NULL) ? parent_program->scope() : NULL;
+ g_parent_prefix = program->get_name() + ".";
+ g_curpath = path;
+
+ // Open the file
+ // skip UTF-8 BOM if there is one
+ yyin = fopen(path.c_str(), "r");
+ if (yyin == 0) {
+ failure("Could not open input file: \"%s\"", path.c_str());
+ }
+ if (skip_utf8_bom(yyin))
+ pverbose("Skipped UTF-8 BOM at %s\n", path.c_str());
+
+ pverbose("Parsing %s for types\n", path.c_str());
+ yylineno = 1;
+ try {
+ if (yyparse() != 0) {
+ failure("Parser error during types pass.");
+ }
+ } catch (string x) {
+ failure(x.c_str());
+ }
+ fclose(yyin);
+}
+
+/**
+ * Generate code
+ */
+void generate(t_program* program, const vector<string>& generator_strings) {
+ // Oooohh, recursive code generation, hot!!
+ if (gen_recurse) {
+ const vector<t_program*>& includes = program->get_includes();
+ for (size_t i = 0; i < includes.size(); ++i) {
+ // Propagate output path from parent to child programs
+ includes[i]->set_out_path(program->get_out_path(), program->is_out_path_absolute());
+
+ generate(includes[i], generator_strings);
+ }
+ }
+
+ // Generate code!
+ try {
+ pverbose("Program: %s\n", program->get_path().c_str());
+
+ // Compute fingerprints. - not anymore, we do it on the fly now
+ // generate_all_fingerprints(program);
+
+ if (dump_docs) {
+ dump_docstrings(program);
+ }
+
+ vector<string>::const_iterator iter;
+ for (iter = generator_strings.begin(); iter != generator_strings.end(); ++iter) {
+ t_generator* generator = t_generator_registry::get_generator(program, *iter);
+
+ if (generator == NULL) {
+ pwarning(1, "Unable to get a generator for \"%s\".\n", iter->c_str());
+ } else {
+ pverbose("Generating \"%s\"\n", iter->c_str());
+ generator->generate_program();
+ delete generator;
+ }
+ }
+ } catch (string s) {
+ printf("Error: %s\n", s.c_str());
+ } catch (const char* exc) {
+ printf("Error: %s\n", exc);
+ }
+}
+
+void audit(t_program* new_program, t_program* old_program, string new_thrift_include_path, string old_thrift_include_path)
+{
+ vector<string> temp_incl_searchpath = g_incl_searchpath;
+ if(!old_thrift_include_path.empty()) {
+ g_incl_searchpath.push_back(old_thrift_include_path);
+ }
+
+ parse(old_program, NULL);
+
+ g_incl_searchpath = temp_incl_searchpath;
+ if(!new_thrift_include_path.empty()) {
+ g_incl_searchpath.push_back(new_thrift_include_path);
+ }
+
+ parse(new_program, NULL);
+
+ compare_namespace(new_program, old_program);
+ compare_services(new_program->get_services(), old_program->get_services());
+ compare_enums(new_program->get_enums(), old_program->get_enums());
+ compare_structs(new_program->get_structs(), old_program->get_structs());
+ compare_structs(new_program->get_xceptions(), old_program->get_xceptions());
+ compare_consts(new_program->get_consts(), old_program->get_consts());
+}
+
+/**
+ * Parse it up.. then spit it back out, in pretty much every language. Alright
+ * not that many languages, but the cool ones that we care about.
+ */
+int main(int argc, char** argv) {
+ int i;
+ std::string out_path;
+ bool out_path_is_absolute = false;
+
+ // Setup time string
+ time_t now = time(NULL);
+ g_time_str = ctime(&now);
+
+ // Check for necessary arguments, you gotta have at least a filename and
+ // an output language flag
+ if (argc < 2) {
+ usage();
+ }
+
+ vector<string> generator_strings;
+ string old_thrift_include_path;
+ string new_thrift_include_path;
+ string old_input_file;
+
+ // Set the current path to a dummy value to make warning messages clearer.
+ g_curpath = "arguments";
+
+ // Hacky parameter handling... I didn't feel like using a library sorry!
+ for (i = 1; i < argc - 1; i++) {
+ char* arg;
+
+ arg = strtok(argv[i], " ");
+ while (arg != NULL) {
+ // Treat double dashes as single dashes
+ if (arg[0] == '-' && arg[1] == '-') {
+ ++arg;
+ }
+
+ if (strcmp(arg, "-help") == 0) {
+ help();
+ } else if (strcmp(arg, "-version") == 0) {
+ version();
+ exit(0);
+ } else if (strcmp(arg, "-debug") == 0) {
+ g_debug = 1;
+ } else if (strcmp(arg, "-nowarn") == 0) {
+ g_warn = 0;
+ } else if (strcmp(arg, "-strict") == 0) {
+ g_strict = 255;
+ g_warn = 2;
+ } else if (strcmp(arg, "-v") == 0 || strcmp(arg, "-verbose") == 0) {
+ g_verbose = 1;
+ } else if (strcmp(arg, "-r") == 0 || strcmp(arg, "-recurse") == 0) {
+ gen_recurse = true;
+ } else if (strcmp(arg, "-allow-neg-keys") == 0) {
+ g_allow_neg_field_keys = true;
+ } else if (strcmp(arg, "-allow-64bit-consts") == 0) {
+ g_allow_64bit_consts = true;
+ } else if (strcmp(arg, "-gen") == 0) {
+ arg = argv[++i];
+ if (arg == NULL) {
+ fprintf(stderr, "Missing generator specification\n");
+ usage();
+ }
+ generator_strings.push_back(arg);
+ } else if (strcmp(arg, "-I") == 0) {
+ // An argument of "-I\ asdf" is invalid and has unknown results
+ arg = argv[++i];
+
+ if (arg == NULL) {
+ fprintf(stderr, "Missing Include directory\n");
+ usage();
+ }
+ g_incl_searchpath.push_back(arg);
+ } else if ((strcmp(arg, "-o") == 0) || (strcmp(arg, "-out") == 0)) {
+ out_path_is_absolute = (strcmp(arg, "-out") == 0) ? true : false;
+ arg = argv[++i];
+ if (arg == NULL) {
+ fprintf(stderr, "-o: missing output directory\n");
+ usage();
+ }
+ out_path = arg;
+
+#ifdef _WIN32
+ // strip out trailing \ on Windows
+ std::string::size_type last = out_path.length() - 1;
+ if (out_path[last] == '\\') {
+ out_path.erase(last);
+ }
+#endif
+ if (!check_is_directory(out_path.c_str()))
+ return -1;
+ } else if (strcmp(arg, "-audit") == 0) {
+ g_audit = true;
+ arg = argv[++i];
+ if (arg == NULL) {
+ fprintf(stderr, "Missing old thrift file name for audit operation\n");
+ usage();
+ }
+ char old_thrift_file_rp[THRIFT_PATH_MAX];
+
+ if (saferealpath(arg, old_thrift_file_rp) == NULL) {
+ failure("Could not open input file with realpath: %s", arg);
+ }
+ old_input_file = string(old_thrift_file_rp);
+ } else if(strcmp(arg, "-audit-nofatal") == 0){
+ g_audit_fatal = false;
+ } else if (strcmp(arg, "-Iold") == 0) {
+ arg = argv[++i];
+ if (arg == NULL) {
+ fprintf(stderr, "Missing Include directory for old thrift file\n");
+ usage();
+ }
+ old_thrift_include_path = string(arg);
+ } else if (strcmp(arg, "-Inew") == 0) {
+ arg = argv[++i];
+ if(arg == NULL) {
+ fprintf(stderr, "Missing Include directory for new thrift file\n");
+ usage();
+ }
+ new_thrift_include_path = string(arg);
+ } else {
+ fprintf(stderr, "Unrecognized option: %s\n", arg);
+ usage();
+ }
+
+ // Tokenize more
+ arg = strtok(NULL, " ");
+ }
+ }
+
+ // display help
+ if ((strcmp(argv[argc - 1], "-help") == 0) || (strcmp(argv[argc - 1], "--help") == 0)) {
+ help();
+ }
+
+ // if you're asking for version, you have a right not to pass a file
+ if ((strcmp(argv[argc - 1], "-version") == 0) || (strcmp(argv[argc - 1], "--version") == 0)) {
+ version();
+ exit(0);
+ }
+
+ // Initialize global types
+ g_type_void = new t_base_type("void", t_base_type::TYPE_VOID);
+ g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
+ g_type_binary = new t_base_type("string", t_base_type::TYPE_STRING);
+ ((t_base_type*)g_type_binary)->set_binary(true);
+ g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
+ ((t_base_type*)g_type_slist)->set_string_list(true);
+ g_type_bool = new t_base_type("bool", t_base_type::TYPE_BOOL);
+ g_type_byte = new t_base_type("byte", t_base_type::TYPE_BYTE);
+ g_type_i16 = new t_base_type("i16", t_base_type::TYPE_I16);
+ g_type_i32 = new t_base_type("i32", t_base_type::TYPE_I32);
+ g_type_i64 = new t_base_type("i64", t_base_type::TYPE_I64);
+ g_type_double = new t_base_type("double", t_base_type::TYPE_DOUBLE);
+
+ if(g_audit)
+ {
+ // Audit operation
+
+ if (old_input_file.empty()) {
+ fprintf(stderr, "Missing file name of old thrift file for audit\n");
+ usage();
+ }
+
+ char new_thrift_file_rp[THRIFT_PATH_MAX];
+ if (argv[i] == NULL) {
+ fprintf(stderr, "Missing file name of new thrift file for audit\n");
+ usage();
+ }
+ if (saferealpath(argv[i], new_thrift_file_rp) == NULL) {
+ failure("Could not open input file with realpath: %s", argv[i]);
+ }
+ string new_input_file(new_thrift_file_rp);
+
+ t_program new_program(new_input_file);
+ t_program old_program(old_input_file);
+
+ audit(&new_program, &old_program, new_thrift_include_path, old_thrift_include_path);
+
+ } else {
+ // Generate options
+
+ // You gotta generate something!
+ if (generator_strings.empty()) {
+ fprintf(stderr, "No output language(s) specified\n");
+ usage();
+ }
+
+ // Real-pathify it
+ char rp[THRIFT_PATH_MAX];
+ if (argv[i] == NULL) {
+ fprintf(stderr, "Missing file name\n");
+ usage();
+ }
+ if (saferealpath(argv[i], rp) == NULL) {
+ failure("Could not open input file with realpath: %s", argv[i]);
+ }
+ string input_file(rp);
+
+ // Instance of the global parse tree
+ t_program* program = new t_program(input_file);
+ if (out_path.size()) {
+ program->set_out_path(out_path, out_path_is_absolute);
+ }
+
+ // Compute the cpp include prefix.
+ // infer this from the filename passed in
+ string input_filename = argv[i];
+ string include_prefix;
+
+ string::size_type last_slash = string::npos;
+ if ((last_slash = input_filename.rfind("/")) != string::npos) {
+ include_prefix = input_filename.substr(0, last_slash);
+ }
+
+ program->set_include_prefix(include_prefix);
+
+ // Parse it!
+ parse(program, NULL);
+
+ // The current path is not really relevant when we are doing generation.
+ // Reset the variable to make warning messages clearer.
+ g_curpath = "generation";
+ // Reset yylineno for the heck of it. Use 1 instead of 0 because
+ // That is what shows up during argument parsing.
+ yylineno = 1;
+
+ // Generate it!
+ generate(program, generator_strings);
+ delete program;
+ }
+
+ // Clean up. Who am I kidding... this program probably orphans heap memory
+ // all over the place, but who cares because it is about to exit and it is
+ // all referenced and used by this wacky parse tree up until now anyways.
+
+ delete g_type_void;
+ delete g_type_string;
+ delete g_type_bool;
+ delete g_type_byte;
+ delete g_type_i16;
+ delete g_type_i32;
+ delete g_type_i64;
+ delete g_type_double;
+
+ // Finished
+ if (g_return_failure && g_audit_fatal) {
+ exit(2);
+ }
+ // Finished
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/main.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/main.h b/depends/thirdparty/thrift/compiler/cpp/src/main.h
new file mode 100644
index 0000000..cd4b032
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/main.h
@@ -0,0 +1,107 @@
+/*
+ * 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_MAIN_H
+#define T_MAIN_H
+
+#include <string>
+#include <cstdio>
+
+#include "logging.h"
+
+#include "parse/t_const.h"
+#include "parse/t_field.h"
+
+/**
+ * Defined in the flex library
+ */
+
+extern "C" { int yylex(void); }
+
+int yyparse(void);
+
+/**
+ * Expected to be defined by Flex/Bison
+ */
+void yyerror(const char* fmt, ...);
+
+/**
+ * Check simple identifier names
+ */
+void validate_simple_identifier(const char* identifier);
+
+/**
+ * Check constant types
+ */
+void validate_const_type(t_const* c);
+
+/**
+ * Check constant types
+ */
+void validate_field_value(t_field* field, t_const_value* cv);
+
+/**
+ * Check members of a throws block
+ */
+bool validate_throws(t_struct* throws);
+
+/**
+ * Converts a string filename into a thrift program name
+ */
+std::string program_name(std::string filename);
+
+/**
+ * Gets the directory path of a filename
+ */
+std::string directory_name(std::string filename);
+
+/**
+ * Get the absolute path for an include file
+ */
+std::string include_file(std::string filename);
+
+/**
+ * Clears any previously stored doctext string.
+ */
+void clear_doctext();
+
+/**
+ * Cleans up text commonly found in doxygen-like comments
+ */
+char* clean_up_doctext(char* doctext);
+
+/**
+ * We are sure the program doctext candidate is really the program doctext.
+ */
+void declare_valid_program_doctext();
+
+/**
+ * Emits a warning on list<byte>, binary type is typically a much better choice.
+ */
+void check_for_list_of_bytes(t_type* list_elem_type);
+
+/**
+ * Flex utilities
+ */
+
+extern int yylineno;
+extern char yytext[];
+extern std::FILE* yyin;
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/md5.c
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/md5.c b/depends/thirdparty/thrift/compiler/cpp/src/md5.c
new file mode 100644
index 0000000..c35d96c
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/md5.c
@@ -0,0 +1,381 @@
+/*
+ Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.c is L. Peter Deutsch
+ <gh...@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order
+ either statically or dynamically; added missing #include <string.h>
+ in library.
+ 2002-03-11 lpd Corrected argument list for main(), and added int return
+ type, in test program and T value program.
+ 2002-02-21 lpd Added missing #include <stdio.h> in test program.
+ 2000-07-03 lpd Patched to eliminate warnings about "constant is
+ unsigned in ANSI C, signed in traditional"; made test program
+ self-checking.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
+ 1999-05-03 lpd Original version.
+ */
+
+#include "md5.h"
+#include <string.h>
+
+#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
+#ifdef ARCH_IS_BIG_ENDIAN
+# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
+#else
+# define BYTE_ORDER 0
+#endif
+
+#define T_MASK ((md5_word_t)~0)
+#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
+#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
+#define T3 0x242070db
+#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
+#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
+#define T6 0x4787c62a
+#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
+#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
+#define T9 0x698098d8
+#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
+#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
+#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
+#define T13 0x6b901122
+#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
+#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
+#define T16 0x49b40821
+#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
+#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
+#define T19 0x265e5a51
+#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
+#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
+#define T22 0x02441453
+#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
+#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
+#define T25 0x21e1cde6
+#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
+#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
+#define T28 0x455a14ed
+#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
+#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
+#define T31 0x676f02d9
+#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
+#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
+#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
+#define T35 0x6d9d6122
+#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
+#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
+#define T38 0x4bdecfa9
+#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
+#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
+#define T41 0x289b7ec6
+#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
+#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
+#define T44 0x04881d05
+#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
+#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
+#define T47 0x1fa27cf8
+#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
+#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
+#define T50 0x432aff97
+#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
+#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
+#define T53 0x655b59c3
+#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
+#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
+#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
+#define T57 0x6fa87e4f
+#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
+#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
+#define T60 0x4e0811a1
+#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
+#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
+#define T63 0x2ad7d2bb
+#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
+
+
+static void
+md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
+{
+ md5_word_t
+ a = pms->abcd[0], b = pms->abcd[1],
+ c = pms->abcd[2], d = pms->abcd[3];
+ md5_word_t t;
+#if BYTE_ORDER > 0
+ /* Define storage only for big-endian CPUs. */
+ md5_word_t X[16];
+#else
+ /* Define storage for little-endian or both types of CPUs. */
+ md5_word_t xbuf[16];
+ const md5_word_t *X;
+#endif
+
+ {
+#if BYTE_ORDER == 0
+ /*
+ * Determine dynamically whether this is a big-endian or
+ * little-endian machine, since we can use a more efficient
+ * algorithm on the latter.
+ */
+ static const int w = 1;
+
+ if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
+#endif
+#if BYTE_ORDER <= 0 /* little-endian */
+ {
+ /*
+ * On little-endian machines, we can process properly aligned
+ * data without copying it.
+ */
+ if (!((data - (const md5_byte_t *)0) & 3)) {
+ /* data are properly aligned */
+ X = (const md5_word_t *)data;
+ } else {
+ /* not aligned */
+ memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
+ }
+#endif
+#if BYTE_ORDER == 0
+ else /* dynamic big-endian */
+#endif
+#if BYTE_ORDER >= 0 /* big-endian */
+ {
+ /*
+ * On big-endian machines, we must arrange the bytes in the
+ * right order.
+ */
+ const md5_byte_t *xp = data;
+ int i;
+
+# if BYTE_ORDER == 0
+ X = xbuf; /* (dynamic only) */
+# else
+# define xbuf X /* (static only) */
+# endif
+ for (i = 0; i < 16; ++i, xp += 4)
+ xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+ }
+#endif
+ }
+
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+
+ /* Round 1. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
+#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + F(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 7, T1);
+ SET(d, a, b, c, 1, 12, T2);
+ SET(c, d, a, b, 2, 17, T3);
+ SET(b, c, d, a, 3, 22, T4);
+ SET(a, b, c, d, 4, 7, T5);
+ SET(d, a, b, c, 5, 12, T6);
+ SET(c, d, a, b, 6, 17, T7);
+ SET(b, c, d, a, 7, 22, T8);
+ SET(a, b, c, d, 8, 7, T9);
+ SET(d, a, b, c, 9, 12, T10);
+ SET(c, d, a, b, 10, 17, T11);
+ SET(b, c, d, a, 11, 22, T12);
+ SET(a, b, c, d, 12, 7, T13);
+ SET(d, a, b, c, 13, 12, T14);
+ SET(c, d, a, b, 14, 17, T15);
+ SET(b, c, d, a, 15, 22, T16);
+#undef SET
+
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + G(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, T17);
+ SET(d, a, b, c, 6, 9, T18);
+ SET(c, d, a, b, 11, 14, T19);
+ SET(b, c, d, a, 0, 20, T20);
+ SET(a, b, c, d, 5, 5, T21);
+ SET(d, a, b, c, 10, 9, T22);
+ SET(c, d, a, b, 15, 14, T23);
+ SET(b, c, d, a, 4, 20, T24);
+ SET(a, b, c, d, 9, 5, T25);
+ SET(d, a, b, c, 14, 9, T26);
+ SET(c, d, a, b, 3, 14, T27);
+ SET(b, c, d, a, 8, 20, T28);
+ SET(a, b, c, d, 13, 5, T29);
+ SET(d, a, b, c, 2, 9, T30);
+ SET(c, d, a, b, 7, 14, T31);
+ SET(b, c, d, a, 12, 20, T32);
+#undef SET
+
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + H(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, T33);
+ SET(d, a, b, c, 8, 11, T34);
+ SET(c, d, a, b, 11, 16, T35);
+ SET(b, c, d, a, 14, 23, T36);
+ SET(a, b, c, d, 1, 4, T37);
+ SET(d, a, b, c, 4, 11, T38);
+ SET(c, d, a, b, 7, 16, T39);
+ SET(b, c, d, a, 10, 23, T40);
+ SET(a, b, c, d, 13, 4, T41);
+ SET(d, a, b, c, 0, 11, T42);
+ SET(c, d, a, b, 3, 16, T43);
+ SET(b, c, d, a, 6, 23, T44);
+ SET(a, b, c, d, 9, 4, T45);
+ SET(d, a, b, c, 12, 11, T46);
+ SET(c, d, a, b, 15, 16, T47);
+ SET(b, c, d, a, 2, 23, T48);
+#undef SET
+
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + I(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, T49);
+ SET(d, a, b, c, 7, 10, T50);
+ SET(c, d, a, b, 14, 15, T51);
+ SET(b, c, d, a, 5, 21, T52);
+ SET(a, b, c, d, 12, 6, T53);
+ SET(d, a, b, c, 3, 10, T54);
+ SET(c, d, a, b, 10, 15, T55);
+ SET(b, c, d, a, 1, 21, T56);
+ SET(a, b, c, d, 8, 6, T57);
+ SET(d, a, b, c, 15, 10, T58);
+ SET(c, d, a, b, 6, 15, T59);
+ SET(b, c, d, a, 13, 21, T60);
+ SET(a, b, c, d, 4, 6, T61);
+ SET(d, a, b, c, 11, 10, T62);
+ SET(c, d, a, b, 2, 15, T63);
+ SET(b, c, d, a, 9, 21, T64);
+#undef SET
+
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
+ pms->abcd[0] += a;
+ pms->abcd[1] += b;
+ pms->abcd[2] += c;
+ pms->abcd[3] += d;
+}
+
+void
+md5_init(md5_state_t *pms)
+{
+ pms->count[0] = pms->count[1] = 0;
+ pms->abcd[0] = 0x67452301;
+ pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
+ pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+ pms->abcd[3] = 0x10325476;
+}
+
+void
+md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
+{
+ const md5_byte_t *p = data;
+ int left = nbytes;
+ int offset = (pms->count[0] >> 3) & 63;
+ md5_word_t nbits = (md5_word_t)(nbytes << 3);
+
+ if (nbytes <= 0)
+ return;
+
+ /* Update the message length. */
+ pms->count[1] += nbytes >> 29;
+ pms->count[0] += nbits;
+ if (pms->count[0] < nbits)
+ pms->count[1]++;
+
+ /* Process an initial partial block. */
+ if (offset) {
+ int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+ memcpy(pms->buf + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(pms, pms->buf);
+ }
+
+ /* Process full blocks. */
+ for (; left >= 64; p += 64, left -= 64)
+ md5_process(pms, p);
+
+ /* Process a final partial block. */
+ if (left)
+ memcpy(pms->buf, p, left);
+}
+
+void
+md5_finish(md5_state_t *pms, md5_byte_t digest[16])
+{
+ static const md5_byte_t pad[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ md5_byte_t data[8];
+ int i;
+
+ /* Save the length before padding. */
+ for (i = 0; i < 8; ++i)
+ data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ /* Pad to 56 bytes mod 64. */
+ md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ /* Append the length. */
+ md5_append(pms, data, 8);
+ for (i = 0; i < 16; ++i)
+ digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/md5.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/md5.h b/depends/thirdparty/thrift/compiler/cpp/src/md5.h
new file mode 100644
index 0000000..3fbe498
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/md5.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <gh...@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Removed support for non-ANSI compilers; removed
+ references to Ghostscript; clarified derivation from RFC 1321;
+ now handles byte order either statically or dynamically.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <pu...@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+#ifndef md5_INCLUDED
+#define md5_INCLUDED
+
+/*
+ * This package supports both compile-time and run-time determination of CPU
+ * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
+ * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * defined as non-zero, the code will be compiled to run only on big-endian
+ * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
+ * run on either big- or little-endian CPUs, but will run slightly less
+ * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
+ */
+
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ md5_word_t count[2]; /* message length in bits, lsw first */
+ md5_word_t abcd[4]; /* digest buffer */
+ md5_byte_t buf[64]; /* accumulate block */
+} md5_state_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Initialize the algorithm. */
+void md5_init(md5_state_t* pms);
+
+/* Append a string to the message. */
+void md5_append(md5_state_t* pms, const md5_byte_t* data, int nbytes);
+
+/* Finish the message and return the digest. */
+void md5_finish(md5_state_t* pms, md5_byte_t digest[16]);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* md5_INCLUDED */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/parse.cc
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/parse.cc b/depends/thirdparty/thrift/compiler/cpp/src/parse/parse.cc
new file mode 100644
index 0000000..b22ee52
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/parse.cc
@@ -0,0 +1,31 @@
+/*
+ * 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 "t_type.h"
+#include "t_typedef.h"
+
+#include "main.h"
+
+t_type* t_type::get_true_type() {
+ t_type* type = this;
+ while (type->is_typedef()) {
+ type = ((t_typedef*)type)->get_type();
+ }
+ return type;
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_base_type.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_base_type.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_base_type.h
new file mode 100644
index 0000000..9be1f80
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_base_type.h
@@ -0,0 +1,117 @@
+/*
+ * 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_BYTE,
+ 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_BYTE:
+ return "byte";
+ 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/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const.h
new file mode 100644
index 0000000..0f64bb1
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const.h
@@ -0,0 +1,50 @@
+/*
+ * 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/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const_value.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const_value.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const_value.h
new file mode 100644
index 0000000..7e6e3f6
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_const_value.h
@@ -0,0 +1,146 @@
+/*
+ * 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>
+
+/**
+ * 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_;
+};
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_container.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_container.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_container.h
new file mode 100644
index 0000000..0d992b7
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_container.h
@@ -0,0 +1,47 @@
+/*
+ * 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() { return has_cpp_name_; }
+
+ std::string get_cpp_name() { 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/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_doc.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_doc.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_doc.h
new file mode 100644
index 0000000..9d310b7
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_doc.h
@@ -0,0 +1,54 @@
+/*
+ * 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) {}
+
+ 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/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum.h
new file mode 100644
index 0000000..7b6a020
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum.h
@@ -0,0 +1,110 @@
+/*
+ * 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 "t_enum_value.h"
+#include <vector>
+
+/**
+ * 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() { 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; }
+
+ virtual std::string get_fingerprint_material() const { return "enum"; }
+
+private:
+ std::vector<t_enum_value*> constants_;
+};
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum_value.h
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum_value.h b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum_value.h
new file mode 100644
index 0000000..5979f06
--- /dev/null
+++ b/depends/thirdparty/thrift/compiler/cpp/src/parse/t_enum_value.h
@@ -0,0 +1,49 @@
+/*
+ * 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 <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