Baseline commit for thrift, which is pillar v2
Reviewed By: aditya
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664711 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/src/parse/t_function.h b/compiler/src/parse/t_function.h
new file mode 100644
index 0000000..1caf54a
--- /dev/null
+++ b/compiler/src/parse/t_function.h
@@ -0,0 +1,51 @@
+#ifndef T_FUNCTION_H
+#define T_FUNCTION_H
+
+#include <string>
+#include "t_type.h"
+#include "t_struct.h"
+
+/**
+ * Representation of a function. Key parst are return type, function name,
+ * optional modifiers, and an argument list. Each function also has a
+ * hash signature that is used in the network protocol.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class t_function {
+ public:
+ t_function(t_type* returntype, std::string name, t_struct* arglist) :
+ returntype_(returntype), name_(name), arglist_(arglist) {}
+
+ ~t_function() {}
+
+ /**
+ * Implementation of the Fowler / Noll / Vo (FNV) Hash
+ * http://www.isthe.com/chongo/tech/comp/fnv/
+ */
+ static uint32_t fnv32(const char *s) {
+ uint32_t hash = (uint32_t)216613626;
+ while (*s) {
+ hash +=
+ (hash << 1) +
+ (hash << 4) +
+ (hash << 7) +
+ (hash << 8) +
+ (hash << 24);
+ hash ^= *s++;
+ }
+ return hash;
+ }
+
+ t_type* get_returntype() const { return returntype_; }
+ const std::string& get_name() const { return name_; }
+ t_struct* get_arglist() const { return arglist_; }
+ uint32_t get_hash() const { return fnv32(name_.c_str()); }
+
+ private:
+ t_type* returntype_;
+ std::string name_;
+ t_struct* arglist_;
+};
+
+#endif