You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2013/01/11 11:43:25 UTC

[6/6] git commit: THRIFT-1826 update c_glib source header paths Patch: Simon South

Updated Branches:
  refs/heads/master f5305b0b6 -> e3da76836


THRIFT-1826 update c_glib source header paths
Patch: Simon South


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/e3da7683
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/e3da7683
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/e3da7683

Branch: refs/heads/master
Commit: e3da768367d0a3e013a00a5a365e58aed3bffa32
Parents: f5305b0
Author: Roger Meier <ro...@apache.org>
Authored: Fri Jan 11 11:41:53 2013 +0100
Committer: Roger Meier <ro...@apache.org>
Committed: Fri Jan 11 11:41:53 2013 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_c_glib_generator.cc    |   10 +-
 lib/c_glib/Makefile.am                             |   74 +-
 .../src/thrift/c_glib/processor/thrift_processor.c |   44 +
 .../src/thrift/c_glib/processor/thrift_processor.h |   75 ++
 .../c_glib/protocol/thrift_binary_protocol.c       |  868 +++++++++++++++
 .../c_glib/protocol/thrift_binary_protocol.h       |   70 ++
 .../protocol/thrift_binary_protocol_factory.c      |   50 +
 .../protocol/thrift_binary_protocol_factory.h      |   54 +
 .../src/thrift/c_glib/protocol/thrift_protocol.c   |  589 ++++++++++
 .../src/thrift/c_glib/protocol/thrift_protocol.h   |  338 ++++++
 .../c_glib/protocol/thrift_protocol_factory.c      |   43 +
 .../c_glib/protocol/thrift_protocol_factory.h      |   71 ++
 .../src/thrift/c_glib/server/thrift_server.c       |  174 +++
 .../src/thrift/c_glib/server/thrift_server.h       |   91 ++
 .../thrift/c_glib/server/thrift_simple_server.c    |  118 ++
 .../thrift/c_glib/server/thrift_simple_server.h    |   68 ++
 lib/c_glib/src/thrift/c_glib/thrift.c              |   32 +
 lib/c_glib/src/thrift/c_glib/thrift.h              |   37 +
 .../thrift/c_glib/thrift_application_exception.c   |  179 +++
 .../thrift/c_glib/thrift_application_exception.h   |   82 ++
 lib/c_glib/src/thrift/c_glib/thrift_struct.c       |   52 +
 lib/c_glib/src/thrift/c_glib/thrift_struct.h       |   66 ++
 .../c_glib/transport/thrift_buffered_transport.c   |  368 ++++++
 .../c_glib/transport/thrift_buffered_transport.h   |   75 ++
 .../c_glib/transport/thrift_framed_transport.c     |  360 ++++++
 .../c_glib/transport/thrift_framed_transport.h     |   75 ++
 .../thrift/c_glib/transport/thrift_memory_buffer.c |  229 ++++
 .../thrift/c_glib/transport/thrift_memory_buffer.h |   69 ++
 .../thrift/c_glib/transport/thrift_server_socket.c |  256 +++++
 .../thrift/c_glib/transport/thrift_server_socket.h |   88 ++
 .../c_glib/transport/thrift_server_transport.c     |   62 +
 .../c_glib/transport/thrift_server_transport.h     |   87 ++
 .../src/thrift/c_glib/transport/thrift_socket.c    |  312 ++++++
 .../src/thrift/c_glib/transport/thrift_socket.h    |   73 ++
 .../src/thrift/c_glib/transport/thrift_transport.c |  108 ++
 .../src/thrift/c_glib/transport/thrift_transport.h |  150 +++
 .../c_glib/transport/thrift_transport_factory.c    |   44 +
 .../c_glib/transport/thrift_transport_factory.h    |   69 ++
 lib/c_glib/src/thrift/processor/thrift_processor.c |   44 -
 lib/c_glib/src/thrift/processor/thrift_processor.h |   75 --
 .../src/thrift/protocol/thrift_binary_protocol.c   |  868 ---------------
 .../src/thrift/protocol/thrift_binary_protocol.h   |   70 --
 .../protocol/thrift_binary_protocol_factory.c      |   50 -
 .../protocol/thrift_binary_protocol_factory.h      |   54 -
 lib/c_glib/src/thrift/protocol/thrift_protocol.c   |  589 ----------
 lib/c_glib/src/thrift/protocol/thrift_protocol.h   |  338 ------
 .../src/thrift/protocol/thrift_protocol_factory.c  |   43 -
 .../src/thrift/protocol/thrift_protocol_factory.h  |   71 --
 lib/c_glib/src/thrift/server/thrift_server.c       |  174 ---
 lib/c_glib/src/thrift/server/thrift_server.h       |   91 --
 .../src/thrift/server/thrift_simple_server.c       |  118 --
 .../src/thrift/server/thrift_simple_server.h       |   68 --
 lib/c_glib/src/thrift/thrift.c                     |   32 -
 lib/c_glib/src/thrift/thrift.h                     |   37 -
 .../src/thrift/thrift_application_exception.c      |  179 ---
 .../src/thrift/thrift_application_exception.h      |   82 --
 lib/c_glib/src/thrift/thrift_struct.c              |   52 -
 lib/c_glib/src/thrift/thrift_struct.h              |   66 --
 .../thrift/transport/thrift_buffered_transport.c   |  368 ------
 .../thrift/transport/thrift_buffered_transport.h   |   75 --
 .../src/thrift/transport/thrift_framed_transport.c |  360 ------
 .../src/thrift/transport/thrift_framed_transport.h |   75 --
 .../src/thrift/transport/thrift_memory_buffer.c    |  229 ----
 .../src/thrift/transport/thrift_memory_buffer.h    |   69 --
 .../src/thrift/transport/thrift_server_socket.c    |  256 -----
 .../src/thrift/transport/thrift_server_socket.h    |   88 --
 .../src/thrift/transport/thrift_server_transport.c |   62 -
 .../src/thrift/transport/thrift_server_transport.h |   87 --
 lib/c_glib/src/thrift/transport/thrift_socket.c    |  312 ------
 lib/c_glib/src/thrift/transport/thrift_socket.h    |   73 --
 lib/c_glib/src/thrift/transport/thrift_transport.c |  108 --
 lib/c_glib/src/thrift/transport/thrift_transport.h |  150 ---
 .../thrift/transport/thrift_transport_factory.c    |   44 -
 .../thrift/transport/thrift_transport_factory.h    |   69 --
 lib/c_glib/test/testbinaryprotocol.c               |    8 +-
 lib/c_glib/test/testbufferedtransport.c            |   10 +-
 lib/c_glib/test/testframedtransport.c              |   10 +-
 lib/c_glib/test/testmemorybuffer.c                 |   10 +-
 lib/c_glib/test/testoptionalrequired.c             |    8 +-
 lib/c_glib/test/testsimpleserver.c                 |    8 +-
 lib/c_glib/test/teststruct.c                       |    2 +-
 lib/c_glib/test/testthrifttest.c                   |    4 +-
 lib/c_glib/test/testthrifttestclient.cpp           |    6 +-
 lib/c_glib/test/testtransportsocket.c              |    8 +-
 lib/c_glib/thrift_c_glib.pc.in                     |    2 +-
 85 files changed, 5606 insertions(+), 5606 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index 8012770..f16a7fc 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -197,8 +197,8 @@ void t_c_glib_generator::init_generator() {
   f_types_ <<
     "/* base includes */" << endl <<
     "#include <glib-object.h>" << endl <<
-    "#include <thrift/thrift_struct.h>" << endl <<
-    "#include <thrift/protocol/thrift_protocol.h>" << endl;
+    "#include <thrift/c_glib/thrift_struct.h>" << endl <<
+    "#include <thrift/c_glib/protocol/thrift_protocol.h>" << endl;
 
   /* include other thrift includes */
   const vector<t_program *> &includes = program_->get_includes();
@@ -229,7 +229,7 @@ void t_c_glib_generator::init_generator() {
     endl <<
     "#include \"" << this->nspace_lc << program_name_u << 
         "_types.h\"" << endl <<
-    "#include <thrift/thrift.h>" << endl <<
+    "#include <thrift/c_glib/thrift.h>" << endl <<
     endl;
 
   f_types_ <<
@@ -422,8 +422,8 @@ void t_c_glib_generator::generate_service (t_service *tservice) {
   // include the headers
   f_service_ <<
     "#include <string.h>" << endl <<
-    "#include <thrift/thrift.h>" << endl <<
-    "#include <thrift/thrift_application_exception.h>" << endl <<
+    "#include <thrift/c_glib/thrift.h>" << endl <<
+    "#include <thrift/c_glib/thrift_application_exception.h>" << endl <<
     "#include \"" << filename << ".h\"" << endl <<
     endl;
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/c_glib/Makefile.am b/lib/c_glib/Makefile.am
index d89b22c..f72ff96 100644
--- a/lib/c_glib/Makefile.am
+++ b/lib/c_glib/Makefile.am
@@ -24,7 +24,7 @@ pkgconfigdir = $(libdir)/pkgconfig
 lib_LTLIBRARIES = libthrift_c_glib.la
 pkgconfig_DATA = thrift_c_glib.pc
 
-common_cflags = -g -Wall -W -Werror -Isrc -I src/thrift $(GLIB_CFLAGS)
+common_cflags = -g -Wall -W -Werror -Isrc -I src/thrift/c_glib $(GLIB_CFLAGS)
 common_ldflags = -g -Wall -W $(GLIB_LDFLAGS) @GCOV_LDFLAGS@
 
 # this removes optimizations and adds coverage flags
@@ -32,56 +32,56 @@ CFLAGS = @GCOV_CFLAGS@
 
 # Define the source files for the module
 
-libthrift_c_glib_la_SOURCES = src/thrift/thrift.c \
-                              src/thrift/thrift_struct.c \
-                              src/thrift/thrift_application_exception.c \
-                              src/thrift/processor/thrift_processor.c \
-                              src/thrift/protocol/thrift_protocol.c \
-                              src/thrift/protocol/thrift_protocol_factory.c \
-                              src/thrift/protocol/thrift_binary_protocol.c \
-                              src/thrift/protocol/thrift_binary_protocol_factory.c \
-                              src/thrift/transport/thrift_transport.c \
-                              src/thrift/transport/thrift_transport_factory.c \
-                              src/thrift/transport/thrift_socket.c \
-                              src/thrift/transport/thrift_server_transport.c \
-                              src/thrift/transport/thrift_server_socket.c \
-                              src/thrift/transport/thrift_buffered_transport.c \
-                              src/thrift/transport/thrift_framed_transport.c \
-                              src/thrift/transport/thrift_memory_buffer.c \
-                              src/thrift/server/thrift_server.c \
-                              src/thrift/server/thrift_simple_server.c
+libthrift_c_glib_la_SOURCES = src/thrift/c_glib/thrift.c \
+                              src/thrift/c_glib/thrift_struct.c \
+                              src/thrift/c_glib/thrift_application_exception.c \
+                              src/thrift/c_glib/processor/thrift_processor.c \
+                              src/thrift/c_glib/protocol/thrift_protocol.c \
+                              src/thrift/c_glib/protocol/thrift_protocol_factory.c \
+                              src/thrift/c_glib/protocol/thrift_binary_protocol.c \
+                              src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c \
+                              src/thrift/c_glib/transport/thrift_transport.c \
+                              src/thrift/c_glib/transport/thrift_transport_factory.c \
+                              src/thrift/c_glib/transport/thrift_socket.c \
+                              src/thrift/c_glib/transport/thrift_server_transport.c \
+                              src/thrift/c_glib/transport/thrift_server_socket.c \
+                              src/thrift/c_glib/transport/thrift_buffered_transport.c \
+                              src/thrift/c_glib/transport/thrift_framed_transport.c \
+                              src/thrift/c_glib/transport/thrift_memory_buffer.c \
+                              src/thrift/c_glib/server/thrift_server.c \
+                              src/thrift/c_glib/server/thrift_simple_server.c
 
 libthrift_c_glib_la_CFLAGS = $(common_cflags)
 
 include_thriftdir = $(includedir)/thrift/c_glib
 include_thrift_HEADERS = \
                          $(top_builddir)/config.h \
-                         src/thrift/thrift.h \
-                         src/thrift/thrift_application_exception.h \
-                         src/thrift/thrift_struct.h
+                         src/thrift/c_glib/thrift.h \
+                         src/thrift/c_glib/thrift_application_exception.h \
+                         src/thrift/c_glib/thrift_struct.h
 
 include_protocoldir = $(include_thriftdir)/protocol
-include_protocol_HEADERS = src/thrift/protocol/thrift_protocol.h \
-                           src/thrift/protocol/thrift_protocol_factory.h \
-                           src/thrift/protocol/thrift_binary_protocol.h \
-                           src/thrift/protocol/thrift_binary_protocol_factory.h
+include_protocol_HEADERS = src/thrift/c_glib/protocol/thrift_protocol.h \
+                           src/thrift/c_glib/protocol/thrift_protocol_factory.h \
+                           src/thrift/c_glib/protocol/thrift_binary_protocol.h \
+                           src/thrift/c_glib/protocol/thrift_binary_protocol_factory.h
 
 include_transportdir = $(include_thriftdir)/transport
-include_transport_HEADERS = src/thrift/transport/thrift_buffered_transport.h \
-                            src/thrift/transport/thrift_framed_transport.h \
-                            src/thrift/transport/thrift_memory_buffer.h \
-                            src/thrift/transport/thrift_server_socket.h \
-                            src/thrift/transport/thrift_server_transport.h \
-                            src/thrift/transport/thrift_socket.h \
-                            src/thrift/transport/thrift_transport.h \
-                            src/thrift/transport/thrift_transport_factory.h
+include_transport_HEADERS = src/thrift/c_glib/transport/thrift_buffered_transport.h \
+                            src/thrift/c_glib/transport/thrift_framed_transport.h \
+                            src/thrift/c_glib/transport/thrift_memory_buffer.h \
+                            src/thrift/c_glib/transport/thrift_server_socket.h \
+                            src/thrift/c_glib/transport/thrift_server_transport.h \
+                            src/thrift/c_glib/transport/thrift_socket.h \
+                            src/thrift/c_glib/transport/thrift_transport.h \
+                            src/thrift/c_glib/transport/thrift_transport_factory.h
 
 include_serverdir = $(include_thriftdir)/server
-include_server_HEADERS = src/thrift/server/thrift_server.h \
-                         src/thrift/server/thrift_simple_server.h
+include_server_HEADERS = src/thrift/c_glib/server/thrift_server.h \
+                         src/thrift/c_glib/server/thrift_simple_server.h
 
 include_processordir = $(include_thriftdir)/processor
-include_processor_HEADERS = src/thrift/processor/thrift_processor.h
+include_processor_HEADERS = src/thrift/c_glib/processor/thrift_processor.h
 
 
 EXTRA_DIST = \

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.c b/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.c
new file mode 100644
index 0000000..dac8783
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.c
@@ -0,0 +1,44 @@
+/*
+ * 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 <thrift/c_glib/thrift.h>
+#include <thrift/c_glib/processor/thrift_processor.h>
+
+G_DEFINE_ABSTRACT_TYPE(ThriftProcessor, thrift_processor, G_TYPE_OBJECT)
+
+gboolean
+thrift_processor_process (ThriftProcessor *processor, ThriftProtocol *in,
+                          ThriftProtocol *out)
+{
+  return THRIFT_PROCESSOR_GET_CLASS (processor)->process (processor, in, out);
+}
+
+/* class initializer for ThriftProcessor */
+static void
+thrift_processor_class_init (ThriftProcessorClass *cls)
+{
+  /* set these as virtual methods to be implemented by a subclass */
+  cls->process = thrift_processor_process;
+}
+
+static void
+thrift_processor_init (ThriftProcessor *processor)
+{
+  THRIFT_UNUSED_VAR (processor);
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.h b/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.h
new file mode 100644
index 0000000..a96a555
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/processor/thrift_processor.h
@@ -0,0 +1,75 @@
+/*
+ * 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 _THRIFT_PROCESSOR_H
+#define _THRIFT_PROCESSOR_H
+
+#include <glib-object.h>
+
+#include <thrift/c_glib/protocol/thrift_protocol.h>
+
+G_BEGIN_DECLS
+
+/*! \file thrift_processor.h
+ *  \brief Abstract class for Thrift processors.
+ */
+
+/* type macros */
+#define THRIFT_TYPE_PROCESSOR (thrift_processor_get_type ())
+#define THRIFT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_PROCESSOR, ThriftProcessor))
+#define THRIFT_IS_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_PROCESSOR))
+#define THRIFT_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_PROCESSOR, ThriftProcessorClass))
+#define THRIFT_IS_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_PROCESSOR))
+#define THRIFT_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_PROCESSOR, ThriftProcessorClass))
+
+/*!
+ * Thrift Processorobject
+ */
+struct _ThriftProcessor
+{
+  GObject parent;
+};
+typedef struct _ThriftProcessor ThriftProcessor;
+
+/*!
+ * Thrift Processor class
+ */
+struct _ThriftProcessorClass
+{
+  GObjectClass parent;
+
+  /* vtable */
+  gboolean (*process) (ThriftProcessor *processor, ThriftProtocol *in,
+                       ThriftProtocol *out);
+};
+typedef struct _ThriftProcessorClass ThriftProcessorClass;
+
+/* used by THRIFT_TYPE_PROCESSOR */
+GType thrift_processor_get_type (void);
+
+/*!
+ * Processes the request.
+ * \public \memberof ThriftProcessorClass
+ */
+gboolean thrift_processor_process (ThriftProcessor *processor,
+                                   ThriftProtocol *in, ThriftProtocol *out);
+
+G_END_DECLS
+
+#endif /* _THRIFT_PROCESSOR_H */

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c
new file mode 100644
index 0000000..da59628
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c
@@ -0,0 +1,868 @@
+/*
+ * 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 <string.h>
+#include <stdio.h>
+
+#include <thrift/c_glib/thrift.h>
+#include <thrift/c_glib/protocol/thrift_protocol.h>
+#include <thrift/c_glib/protocol/thrift_binary_protocol.h>
+
+G_DEFINE_TYPE(ThriftBinaryProtocol, thrift_binary_protocol, THRIFT_TYPE_PROTOCOL)
+
+static guint64
+thrift_bitwise_cast_guint64 (gdouble v)
+{
+  union {
+    gdouble from;
+    guint64 to;
+  } u;
+  u.from = v;
+  return u.to;
+}
+
+static gdouble
+thrift_bitwise_cast_gdouble (guint64 v)
+{
+  union {
+    guint64 from;
+    gdouble to;
+  } u;
+  u.from = v;
+  return u.to;
+}
+
+gint32
+thrift_binary_protocol_write_message_begin (ThriftProtocol *protocol,
+    const gchar *name, const ThriftMessageType message_type,
+    const gint32 seqid, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 version = (THRIFT_BINARY_PROTOCOL_VERSION_1)
+                   | ((gint32) message_type);
+  gint32 ret;
+  gint32 xfer = 0;
+
+  if ((ret = thrift_protocol_write_i32 (protocol, version, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  if ((ret = thrift_protocol_write_string (protocol, name, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  if ((ret = thrift_protocol_write_i32 (protocol, seqid, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_write_message_end (ThriftProtocol *protocol,
+                                          GError **error)
+{
+  /* satisfy -Wall */
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_struct_begin (ThriftProtocol *protocol,
+                                           const gchar *name,
+                                           GError **error)
+{
+  /* satisfy -Wall */
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (name);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_struct_end (ThriftProtocol *protocol,
+                                         GError **error)
+{
+  /* satisfy -Wall */
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_field_begin (ThriftProtocol *protocol,
+                                          const gchar *name,
+                                          const ThriftType field_type,
+                                          const gint16 field_id,
+                                          GError **error)
+{
+  THRIFT_UNUSED_VAR (name);
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 ret;
+  gint32 xfer = 0;
+
+  if ((ret = thrift_protocol_write_byte (protocol, (gint8) field_type,
+                                         error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  if ((ret = thrift_protocol_write_i16 (protocol, field_id, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_write_field_end (ThriftProtocol *protocol,
+                                        GError **error)
+{
+  /* satisfy -Wall */
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_field_stop (ThriftProtocol *protocol,
+                                         GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  return thrift_protocol_write_byte (protocol, (gint8) T_STOP, error);
+}
+
+gint32
+thrift_binary_protocol_write_map_begin (ThriftProtocol *protocol,
+                                        const ThriftType key_type,
+                                        const ThriftType value_type,
+                                        const guint32 size,
+                                        GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 ret;
+  gint32 xfer = 0;
+
+  if ((ret = thrift_protocol_write_byte (protocol, (gint8) key_type,
+                                         error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  if ((ret = thrift_protocol_write_byte (protocol, (gint8) value_type,
+                                         error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  if ((ret = thrift_protocol_write_i32 (protocol, (gint32) size, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_write_map_end (ThriftProtocol *protocol,
+                                      GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_list_begin (ThriftProtocol *protocol,
+                                         const ThriftType element_type,
+                                         const guint32 size, 
+                                         GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1); 
+
+  gint32 ret;
+  gint32 xfer = 0;
+
+  if ((ret = thrift_protocol_write_byte (protocol, (gint8) element_type,
+                                         error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if ((ret = thrift_protocol_write_i32 (protocol, (gint32) size, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_write_list_end (ThriftProtocol *protocol,
+                                       GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_set_begin (ThriftProtocol *protocol,
+                                        const ThriftType element_type,
+                                        const guint32 size, 
+                                        GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  return thrift_protocol_write_list_begin (protocol, element_type,
+                                           size, error);
+}
+
+gint32
+thrift_binary_protocol_write_set_end (ThriftProtocol *protocol, GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_write_bool (ThriftProtocol *protocol,
+                                   const gboolean value, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  guint8 tmp = value ? 1 : 0;
+  return thrift_protocol_write_byte (protocol, tmp, error);
+}
+
+gint32
+thrift_binary_protocol_write_byte (ThriftProtocol *protocol, const gint8 value,
+                                   GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+   
+  if (thrift_transport_write (protocol->transport,
+                              (const gpointer) &value, 1, error))
+  {
+    return 1;
+  } else {
+    return -1;
+  }
+}
+
+gint32
+thrift_binary_protocol_write_i16 (ThriftProtocol *protocol, const gint16 value,
+                                  GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint16 net = g_htons (value);
+  if (thrift_transport_write (protocol->transport,
+                              (const gpointer) &net, 2, error))
+  {
+    return 2;
+  } else {
+    return -1;
+  }
+}
+
+gint32
+thrift_binary_protocol_write_i32 (ThriftProtocol *protocol, const gint32 value,
+                                  GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 net = g_htonl (value);
+  if (thrift_transport_write (protocol->transport,
+                              (const gpointer) &net, 4, error))
+  {
+    return 4;
+  } else {
+    return -1;
+  }
+}
+
+gint32
+thrift_binary_protocol_write_i64 (ThriftProtocol *protocol, const gint64 value,
+                                  GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint64 net = GUINT64_TO_BE (value);
+  if (thrift_transport_write (protocol->transport,
+                              (const gpointer) &net, 8, error))
+  {
+    return 8;
+  } else {
+    return -1;
+  }
+}
+
+gint32
+thrift_binary_protocol_write_double (ThriftProtocol *protocol,
+                                     const gdouble value, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  guint64 bits = GUINT64_FROM_BE (thrift_bitwise_cast_guint64 (value));
+  if (thrift_transport_write (protocol->transport,
+                              (const gpointer) &bits, 8, error))
+  {
+    return 8;
+  } else {
+    return -1;
+  }
+}
+
+gint32
+thrift_binary_protocol_write_string (ThriftProtocol *protocol,
+                                     const gchar *str, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  guint32 len = str != NULL ? strlen (str) : 0;
+  /* write the string length + 1 which includes the null terminator */
+  return thrift_protocol_write_binary (protocol, (const gpointer) str, 
+                                       len, error);
+}
+
+gint32
+thrift_binary_protocol_write_binary (ThriftProtocol *protocol,
+                                     const gpointer buf,
+                                     const guint32 len, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gint32 xfer = 0;
+
+  if ((ret = thrift_protocol_write_i32 (protocol, len, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if (len > 0)
+  {
+    if (thrift_transport_write (protocol->transport,
+                                (const gpointer) buf, len, error) == FALSE)
+    {
+      return -1;
+    }
+    xfer += len;
+  }
+
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_read_message_begin (ThriftProtocol *protocol,
+                                           gchar **name,
+                                           ThriftMessageType *message_type,
+                                           gint32 *seqid, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 ret;
+  gint32 xfer = 0;
+  gint32 sz;
+
+  if ((ret = thrift_protocol_read_i32 (protocol, &sz, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if (sz < 0)
+  {
+    /* check for version */
+    guint32 version = sz & THRIFT_BINARY_PROTOCOL_VERSION_MASK;
+    if (version != THRIFT_BINARY_PROTOCOL_VERSION_1)
+    {
+      g_set_error (error, THRIFT_PROTOCOL_ERROR,
+                   THRIFT_PROTOCOL_ERROR_BAD_VERSION,
+                   "expected version %d, got %d",
+                   THRIFT_BINARY_PROTOCOL_VERSION_1, version);
+      return -1;
+    }
+
+    *message_type = (ThriftMessageType) (sz & 0x000000ff);
+
+    if ((ret = thrift_protocol_read_string (protocol, name, error)) < 0)
+    {
+      return -1;
+    }
+    xfer += ret;
+
+    if ((ret = thrift_protocol_read_i32 (protocol, seqid, error)) < 0)
+    {
+      return -1;
+    }
+    xfer += ret;
+  }
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_read_message_end (ThriftProtocol *protocol,
+                                         GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_struct_begin (ThriftProtocol *protocol,
+                                          gchar **name,
+                                          GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  *name = NULL;
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_struct_end (ThriftProtocol *protocol,
+                                        GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_field_begin (ThriftProtocol *protocol,
+                                         gchar **name,
+                                         ThriftType *field_type,
+                                         gint16 *field_id,
+                                         GError **error)
+{
+  THRIFT_UNUSED_VAR (name);
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 ret;
+  gint32 xfer = 0;
+  gint8 type;
+
+  if ((ret = thrift_protocol_read_byte (protocol, &type, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  *field_type = (ThriftType) type;
+  if (*field_type == T_STOP)
+  {
+    *field_id = 0;
+    return xfer;
+  }
+  if ((ret = thrift_protocol_read_i16 (protocol, field_id, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_read_field_end (ThriftProtocol *protocol,
+                                       GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_map_begin (ThriftProtocol *protocol,
+                                       ThriftType *key_type,
+                                       ThriftType *value_type,
+                                       guint32 *size,
+                                       GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 ret;
+  gint32 xfer = 0;
+  gint8 k, v;
+  gint32 sizei;
+
+  if ((ret = thrift_protocol_read_byte (protocol, &k, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  *key_type = (ThriftType) k;
+
+  if ((ret = thrift_protocol_read_byte (protocol, &v, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  *value_type = (ThriftType) v;
+
+  if ((ret = thrift_protocol_read_i32 (protocol, &sizei, error)) <0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if (sizei < 0)
+  {
+    g_set_error (error, THRIFT_PROTOCOL_ERROR,
+                 THRIFT_PROTOCOL_ERROR_NEGATIVE_SIZE,
+                 "got negative size of %d", sizei);
+    return -1;
+  }
+
+  *size = (guint32) sizei;
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_read_map_end (ThriftProtocol *protocol,
+                                     GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_list_begin (ThriftProtocol *protocol,
+                                        ThriftType *element_type,
+                                        guint32 *size, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  gint32 ret;
+  gint32 xfer = 0;
+  gint8 e;
+  gint32 sizei;
+
+  if ((ret = thrift_protocol_read_byte (protocol, &e, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+  *element_type = (ThriftType) e;
+
+  if ((ret = thrift_protocol_read_i32 (protocol, &sizei, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if (sizei < 0)
+  {
+    g_set_error (error, THRIFT_PROTOCOL_ERROR,
+                 THRIFT_PROTOCOL_ERROR_NEGATIVE_SIZE,
+                 "got negative size of %d", sizei);
+    return -1;
+  }
+
+  *size = (guint32) sizei;
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_read_list_end (ThriftProtocol *protocol,
+                                      GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_set_begin (ThriftProtocol *protocol,
+                                       ThriftType *element_type,
+                                       guint32 *size, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  return thrift_protocol_read_list_begin (protocol, element_type, size, error);
+}
+
+gint32
+thrift_binary_protocol_read_set_end (ThriftProtocol *protocol,
+                                     GError **error)
+{
+  THRIFT_UNUSED_VAR (protocol);
+  THRIFT_UNUSED_VAR (error);
+  return 0;
+}
+
+gint32
+thrift_binary_protocol_read_bool (ThriftProtocol *protocol, gboolean *value,
+                                  GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gpointer b[1];
+
+  if ((ret = 
+       thrift_transport_read (protocol->transport,
+                              b, 1, error)) < 0)
+  {
+    return -1;
+  }
+  *value = *(gint8 *) b != 0;
+  return ret;
+}
+
+gint32
+thrift_binary_protocol_read_byte (ThriftProtocol *protocol, gint8 *value,
+                                  GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gpointer b[1];
+
+  if ((ret =
+       thrift_transport_read (protocol->transport,
+                              b, 1, error)) < 0)
+  {
+    return -1;
+  }
+  *value = *(gint8 *) b;
+  return ret;
+}
+
+gint32
+thrift_binary_protocol_read_i16 (ThriftProtocol *protocol, gint16 *value,
+                                 GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gpointer b[2];
+
+  if ((ret =
+       thrift_transport_read (protocol->transport,
+                              b, 2, error)) < 0)
+  {
+    return -1;
+  }
+  *value = *(gint16 *) b;
+  *value = g_ntohs (*value);
+  return ret;
+}
+
+gint32
+thrift_binary_protocol_read_i32 (ThriftProtocol *protocol, gint32 *value,
+                                 GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gpointer b[4];
+
+  if ((ret =
+       thrift_transport_read (protocol->transport,
+                              b, 4, error)) < 0)
+  {
+    return -1;
+  }
+  *value = *(gint32 *) b;
+  *value = g_ntohl (*value);
+  return ret;
+}
+
+gint32
+thrift_binary_protocol_read_i64 (ThriftProtocol *protocol, gint64 *value,
+                                 GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gpointer b[8];
+
+  if ((ret =
+       thrift_transport_read (protocol->transport,
+                              b, 8, error)) < 0)
+  {
+    return -1;
+  }
+  *value = *(gint64 *) b;
+  *value = GUINT64_FROM_BE (*value);
+  return ret;
+}
+
+gint32
+thrift_binary_protocol_read_double (ThriftProtocol *protocol,
+                                    gdouble *value, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gpointer b[8];
+
+  if ((ret =
+       thrift_transport_read (protocol->transport,
+                              b, 8, error)) < 0)
+  {
+    return -1;
+  }
+  guint64 bits = *(guint64 *) b;
+  bits = GUINT64_FROM_BE (bits);
+  *value = thrift_bitwise_cast_gdouble (bits);
+  return ret;
+}
+
+gint32
+thrift_binary_protocol_read_string (ThriftProtocol *protocol,
+                                    gchar **str, GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  guint32 len;
+  gint32 ret;
+  gint32 xfer = 0;
+  gint32 read_len = 0;
+
+  /* read the length into read_len */
+  if ((ret =
+       thrift_protocol_read_i32 (protocol, &read_len, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if (read_len > 0)
+  {
+    /* allocate the memory for the string */
+    len = (guint32) read_len + 1; // space for null terminator
+    *str = g_new0 (gchar, len);
+    if ((ret =
+         thrift_transport_read (protocol->transport,
+                                *str, read_len, error)) < 0)
+    {
+      g_free (*str);
+      *str = NULL;
+      len = 0;
+      return -1;
+    }
+    xfer += ret;
+  } else {
+    *str = NULL;
+  }
+
+  return xfer;
+}
+
+gint32
+thrift_binary_protocol_read_binary (ThriftProtocol *protocol,
+                                    gpointer *buf, guint32 *len,
+                                    GError **error)
+{
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+  gint32 ret;
+  gint32 xfer = 0;
+  gint32 read_len = 0;
+ 
+  /* read the length into read_len */
+  if ((ret =
+       thrift_protocol_read_i32 (protocol, &read_len, error)) < 0)
+  {
+    return -1;
+  }
+  xfer += ret;
+
+  if (read_len > 0)
+  {
+    /* allocate the memory as an array of unsigned char for binary data */
+    *len = (guint32) read_len;
+    *buf = g_new (guchar, *len);
+    if ((ret =
+         thrift_transport_read (protocol->transport,
+                                *buf, *len, error)) < 0)
+    {
+      g_free (*buf);
+      *buf = NULL;
+      *len = 0;
+      return -1;
+    }
+    xfer += ret;
+  } else {
+    *buf = NULL;
+  }
+
+  return xfer;
+}
+
+static void
+thrift_binary_protocol_init (ThriftBinaryProtocol *protocol)
+{
+  THRIFT_UNUSED_VAR (protocol);
+}
+
+/* initialize the class */
+static void
+thrift_binary_protocol_class_init (ThriftBinaryProtocolClass *klass)
+{
+  ThriftProtocolClass *cls = THRIFT_PROTOCOL_CLASS (klass);
+
+  cls->write_message_begin = thrift_binary_protocol_write_message_begin;
+  cls->write_message_end = thrift_binary_protocol_write_message_end;
+  cls->write_struct_begin = thrift_binary_protocol_write_struct_begin;
+  cls->write_struct_end = thrift_binary_protocol_write_struct_end;
+  cls->write_field_begin = thrift_binary_protocol_write_field_begin;
+  cls->write_field_end = thrift_binary_protocol_write_field_end;
+  cls->write_field_stop = thrift_binary_protocol_write_field_stop;
+  cls->write_map_begin = thrift_binary_protocol_write_map_begin;
+  cls->write_map_end = thrift_binary_protocol_write_map_end;
+  cls->write_list_begin = thrift_binary_protocol_write_list_begin;
+  cls->write_list_end = thrift_binary_protocol_write_list_end;
+  cls->write_set_begin = thrift_binary_protocol_write_set_begin;
+  cls->write_set_end = thrift_binary_protocol_write_set_end;
+  cls->write_bool = thrift_binary_protocol_write_bool;
+  cls->write_byte = thrift_binary_protocol_write_byte;
+  cls->write_i16 = thrift_binary_protocol_write_i16;
+  cls->write_i32 = thrift_binary_protocol_write_i32;
+  cls->write_i64 = thrift_binary_protocol_write_i64;
+  cls->write_double = thrift_binary_protocol_write_double;
+  cls->write_string = thrift_binary_protocol_write_string;
+  cls->write_binary = thrift_binary_protocol_write_binary;
+  cls->read_message_begin = thrift_binary_protocol_read_message_begin;
+  cls->read_message_end = thrift_binary_protocol_read_message_end;
+  cls->read_struct_begin = thrift_binary_protocol_read_struct_begin;
+  cls->read_struct_end = thrift_binary_protocol_read_struct_end;
+  cls->read_field_begin = thrift_binary_protocol_read_field_begin;
+  cls->read_field_end = thrift_binary_protocol_read_field_end;
+  cls->read_map_begin = thrift_binary_protocol_read_map_begin;
+  cls->read_map_end = thrift_binary_protocol_read_map_end;
+  cls->read_list_begin = thrift_binary_protocol_read_list_begin;
+  cls->read_list_end = thrift_binary_protocol_read_list_end;
+  cls->read_set_begin = thrift_binary_protocol_read_set_begin;
+  cls->read_set_end = thrift_binary_protocol_read_set_end;
+  cls->read_bool = thrift_binary_protocol_read_bool;
+  cls->read_byte = thrift_binary_protocol_read_byte;
+  cls->read_i16 = thrift_binary_protocol_read_i16;
+  cls->read_i32 = thrift_binary_protocol_read_i32;
+  cls->read_i64 = thrift_binary_protocol_read_i64;
+  cls->read_double = thrift_binary_protocol_read_double;
+  cls->read_string = thrift_binary_protocol_read_string;
+  cls->read_binary = thrift_binary_protocol_read_binary;
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.h b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.h
new file mode 100644
index 0000000..b9e6b19
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.h
@@ -0,0 +1,70 @@
+/*
+ * 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 _THRIFT_BINARY_PROTOCOL_H
+#define _THRIFT_BINARY_PROTOCOL_H
+
+#include <glib-object.h>
+
+#include <thrift/c_glib/protocol/thrift_protocol.h>
+#include <thrift/c_glib/transport/thrift_transport.h>
+
+G_BEGIN_DECLS
+
+/*! \file thrift_binary_protocol.h
+ *  \brief Binary protocol implementation of a Thrift protocol.  Implements the
+ *         ThriftProtocol interface.
+ */
+
+/* type macros */
+#define THRIFT_TYPE_BINARY_PROTOCOL (thrift_binary_protocol_get_type ())
+#define THRIFT_BINARY_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_BINARY_PROTOCOL, ThriftBinaryProtocol))
+#define THRIFT_IS_BINARY_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_BINARY_PROTOCOL))
+#define THRIFT_BINARY_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_BINARY_PROTOCOL, ThriftBinaryProtocolClass))
+#define THRIFT_IS_BINARY_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_BINARY_PROTOCOL))
+#define THRIFT_BINARY_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_BINARY_PROTOCOL, ThriftBinaryProtocolClass))
+
+/* version numbers */
+#define THRIFT_BINARY_PROTOCOL_VERSION_1 0x80010000
+#define THRIFT_BINARY_PROTOCOL_VERSION_MASK 0xffff0000
+
+/*!
+ * Thrift Binary Protocol instance.
+ */
+struct _ThriftBinaryProtocol
+{
+  ThriftProtocol parent;
+};
+typedef struct _ThriftBinaryProtocol ThriftBinaryProtocol;
+
+/*!
+ * Thrift Binary Protocol class.
+ */
+struct _ThriftBinaryProtocolClass
+{
+  ThriftProtocolClass parent;
+};
+typedef struct _ThriftBinaryProtocolClass ThriftBinaryProtocolClass;
+
+/* used by THRIFT_TYPE_BINARY_PROTOCOL */
+GType thrift_binary_protocol_get_type (void);
+
+G_END_DECLS
+
+#endif /* _THRIFT_BINARY_PROTOCOL_H */

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
new file mode 100644
index 0000000..390c809
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
@@ -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.
+ */
+
+#include <thrift/c_glib/thrift.h>
+#include <thrift/c_glib/protocol/thrift_binary_protocol.h>
+#include <thrift/c_glib/protocol/thrift_binary_protocol_factory.h>
+
+G_DEFINE_TYPE(ThriftBinaryProtocolFactory, thrift_binary_protocol_factory, THRIFT_TYPE_PROTOCOL_FACTORY)
+
+ThriftProtocol *
+thrift_binary_protocol_factory_get_protocol (ThriftProtocolFactory *factory,
+                                             ThriftTransport *transport)
+{
+  THRIFT_UNUSED_VAR (factory);
+
+  ThriftBinaryProtocol *tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL,
+                                           "transport", transport, NULL);
+
+  return THRIFT_PROTOCOL (tb);
+}
+
+static void
+thrift_binary_protocol_factory_class_init (ThriftBinaryProtocolFactoryClass *cls)
+{
+  ThriftProtocolFactoryClass *protocol_factory_class = THRIFT_PROTOCOL_FACTORY_CLASS (cls);
+
+  protocol_factory_class->get_protocol = thrift_binary_protocol_factory_get_protocol;
+}
+
+static void
+thrift_binary_protocol_factory_init (ThriftBinaryProtocolFactory *factory)
+{
+  THRIFT_UNUSED_VAR (factory);
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.h b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.h
new file mode 100644
index 0000000..a4256b2
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.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 _THRIFT_BINARY_PROTOCOL_FACTORY_H
+#define _THRIFT_BINARY_PROTOCOL_FACTORY_H
+
+#include <glib-object.h>
+
+#include <thrift/c_glib/protocol/thrift_protocol_factory.h>
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define THRIFT_TYPE_BINARY_PROTOCOL_FACTORY (thrift_binary_protocol_factory_get_type ())
+#define THRIFT_BINARY_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, ThriftBinaryProtocolFactory))
+#define THRIFT_IS_BINARY_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY))
+#define THRIFT_BINARY_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, ThriftBinaryProtocolFactoryClass))
+#define THRIFT_IS_BINARY_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY))
+#define THRIFT_BINARY_PROTOCOL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, ThriftBinaryProtocolFactoryClass))
+
+struct _ThriftBinaryProtocolFactory
+{
+  ThriftProtocolFactory parent;
+};
+typedef struct _ThriftBinaryProtocolFactory ThriftBinaryProtocolFactory;
+
+struct _ThriftBinaryProtocolFactoryClass
+{
+  ThriftProtocolFactoryClass parent;
+};
+typedef struct _ThriftBinaryProtocolFactoryClass ThriftBinaryProtocolFactoryClass;
+
+/* used by THRIFT_TYPE_BINARY_PROTOCOL_FACTORY */
+GType thrift_binary_protocol_factory_get_type (void);
+
+G_END_DECLS
+
+#endif /* _THRIFT_BINARY_PROTOCOL_FACTORY_H */

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.c
new file mode 100644
index 0000000..d6315d8
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.c
@@ -0,0 +1,589 @@
+/*
+ * 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 <thrift/c_glib/thrift.h>
+#include <thrift/c_glib/protocol/thrift_protocol.h>
+#include <thrift/c_glib/transport/thrift_transport.h>
+
+/* define the GError domain string */
+#define THRIFT_PROTOCOL_ERROR_DOMAIN "thrift-protocol-error-quark"
+
+/* object properties */
+enum _ThriftProtocolProperties
+{
+  PROP_0,
+  PROP_THRIFT_PROTOCOL_TRANSPORT
+};
+
+G_DEFINE_ABSTRACT_TYPE(ThriftProtocol, thrift_protocol, G_TYPE_OBJECT)
+
+void
+thrift_protocol_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  ThriftProtocol *protocol = THRIFT_PROTOCOL (object);
+
+  THRIFT_UNUSED_VAR (pspec);
+
+  switch (property_id)
+  {
+    case PROP_THRIFT_PROTOCOL_TRANSPORT:
+      g_value_set_object (value, protocol->transport);
+      break;
+  }
+}
+
+void
+thrift_protocol_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+
+  ThriftProtocol *protocol = THRIFT_PROTOCOL (object);
+
+  THRIFT_UNUSED_VAR (pspec);
+
+  switch (property_id)
+  {
+    case PROP_THRIFT_PROTOCOL_TRANSPORT:
+      protocol->transport = g_value_get_object (value);
+      break;
+  }
+}
+
+
+gint32
+thrift_protocol_write_message_begin (ThriftProtocol *protocol, 
+                                     const gchar *name, 
+                                     const ThriftMessageType message_type,
+                                     const gint32 seqid, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_message_begin
+                                                   (protocol, name,
+                                                    message_type, seqid,
+                                                    error);
+}
+
+gint32
+thrift_protocol_write_message_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_message_end (protocol,
+                                                                  error);
+}
+
+gint32
+thrift_protocol_write_struct_begin (ThriftProtocol *protocol, const gchar *name,
+                                    GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_struct_begin (protocol,
+                                                   name, error);
+}
+
+gint32
+thrift_protocol_write_struct_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_struct_end (protocol,
+                                                                 error);
+}
+
+gint32
+thrift_protocol_write_field_begin (ThriftProtocol *protocol,
+                                   const gchar *name,
+                                   const ThriftType field_type,
+                                   const gint16 field_id,
+                                   GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_field_begin (protocol,
+                                                   name, field_type,
+                                                   field_id, error);
+}
+
+gint32
+thrift_protocol_write_field_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_field_end (protocol,
+                                                                error);
+}
+
+gint32
+thrift_protocol_write_field_stop (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_field_stop (protocol,
+                                                                 error);
+}
+
+gint32
+thrift_protocol_write_map_begin (ThriftProtocol *protocol,
+                                 const ThriftType key_type,
+                                 const ThriftType value_type,
+                                 const guint32 size, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_map_begin (protocol,
+                                                   key_type, value_type,
+                                                   size, error);
+}
+
+gint32
+thrift_protocol_write_map_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_map_end (protocol,
+                                                              error);
+}
+
+gint32
+thrift_protocol_write_list_begin (ThriftProtocol *protocol,
+                                  const ThriftType element_type,
+                                  const guint32 size, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_list_begin (protocol,
+                                                   element_type, size,
+                                                   error);
+}
+
+gint32
+thrift_protocol_write_list_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_list_end (protocol,
+                                                               error);
+}
+
+gint32
+thrift_protocol_write_set_begin (ThriftProtocol *protocol,
+                                 const ThriftType element_type,
+                                 const guint32 size, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_set_begin (protocol,
+                                                   element_type, size,
+                                                   error);
+}
+
+gint32
+thrift_protocol_write_set_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_set_end (protocol,
+                                                              error);
+}
+
+gint32
+thrift_protocol_write_bool (ThriftProtocol *protocol,
+                            const gboolean value, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_bool (protocol, value,
+                                                           error);
+}
+
+gint32
+thrift_protocol_write_byte (ThriftProtocol *protocol, const gint8 value,
+                            GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_byte (protocol, value,
+                                                           error);
+}
+
+gint32
+thrift_protocol_write_i16 (ThriftProtocol *protocol, const gint16 value,
+                           GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_i16 (protocol, value,
+                                                          error);
+}
+
+gint32
+thrift_protocol_write_i32 (ThriftProtocol *protocol, const gint32 value,
+                           GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_i32 (protocol, value,
+                                                          error);
+}
+
+gint32
+thrift_protocol_write_i64 (ThriftProtocol *protocol, const gint64 value,
+                           GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_i64 (protocol, value,
+                                                          error);
+}
+
+gint32
+thrift_protocol_write_double (ThriftProtocol *protocol,
+                              const gdouble value, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_double (protocol,
+                                                             value, error);
+}
+
+gint32
+thrift_protocol_write_string (ThriftProtocol *protocol,
+                              const gchar *str, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_string (protocol, str,
+                                                             error);
+}
+
+gint32
+thrift_protocol_write_binary (ThriftProtocol *protocol, const gpointer buf,
+                              const guint32 len, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->write_binary (protocol, buf,
+                                                             len, error);
+}
+
+gint32 
+thrift_protocol_read_message_begin (ThriftProtocol *protocol,
+                                    gchar **name,
+                                    ThriftMessageType *message_type,
+                                    gint32 *seqid, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_message_begin (protocol,
+                                                   name, message_type,
+                                                   seqid, error);
+}
+
+gint32 
+thrift_protocol_read_message_end (ThriftProtocol *protocol,
+                                  GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_message_end (protocol,
+                                                                 error);
+}
+
+gint32 
+thrift_protocol_read_struct_begin (ThriftProtocol *protocol,
+                                   gchar **name,
+                                   GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_struct_begin (protocol,
+                                                                  name,
+                                                                  error);
+}
+
+gint32
+thrift_protocol_read_struct_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_struct_end (protocol,
+                                                                error);
+}
+
+gint32 
+thrift_protocol_read_field_begin (ThriftProtocol *protocol,
+                                  gchar **name,
+                                  ThriftType *field_type,
+                                  gint16 *field_id,
+                                  GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_field_begin (protocol,
+                                                                 name,
+                                                                 field_type,
+                                                                 field_id,
+                                                                 error);
+}
+
+gint32 
+thrift_protocol_read_field_end (ThriftProtocol *protocol,
+                                GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_field_end (protocol,
+                                                               error);
+}
+
+gint32 
+thrift_protocol_read_map_begin (ThriftProtocol *protocol,
+                                ThriftType *key_type,
+                                ThriftType *value_type, guint32 *size,
+                                GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_map_begin (protocol,
+                                                               key_type,
+                                                               value_type,
+                                                               size,
+                                                               error); 
+}
+
+gint32 
+thrift_protocol_read_map_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_map_end (protocol,
+                                                             error);
+}
+
+gint32 
+thrift_protocol_read_list_begin (ThriftProtocol *protocol,
+                                 ThriftType *element_type,
+                                 guint32 *size, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_list_begin (protocol,
+                                                                element_type,
+                                                                size, error);
+}
+
+gint32
+thrift_protocol_read_list_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_list_end (protocol,
+                                                              error);
+}
+
+gint32
+thrift_protocol_read_set_begin (ThriftProtocol *protocol,
+                                ThriftType *element_type,
+                                guint32 *size, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_set_begin (protocol,
+                                                               element_type,
+                                                               size, error);
+}
+
+gint32
+thrift_protocol_read_set_end (ThriftProtocol *protocol, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_set_end (protocol,
+                                                             error);
+}
+
+gint32
+thrift_protocol_read_bool (ThriftProtocol *protocol, gboolean *value,
+                           GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_bool (protocol, value,
+                                                          error);
+}
+
+gint32
+thrift_protocol_read_byte (ThriftProtocol *protocol, gint8 *value,
+                           GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_byte (protocol, value,
+                                                          error);
+}
+
+gint32
+thrift_protocol_read_i16 (ThriftProtocol *protocol, gint16 *value,
+                          GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_i16 (protocol, value,
+                                                         error);
+}
+
+gint32
+thrift_protocol_read_i32 (ThriftProtocol *protocol, gint32 *value,
+                          GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_i32 (protocol, value,
+                                                         error);
+}
+
+gint32
+thrift_protocol_read_i64 (ThriftProtocol *protocol, gint64 *value,
+                          GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_i64 (protocol, value,
+                                                         error);
+}
+
+gint32
+thrift_protocol_read_double (ThriftProtocol *protocol,
+                             gdouble *value, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_double (protocol, value,
+                                                            error);
+}
+
+gint32
+thrift_protocol_read_string (ThriftProtocol *protocol,
+                             gchar **str, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_string (protocol, str,
+                                                            error);
+}
+
+gint32
+thrift_protocol_read_binary (ThriftProtocol *protocol, gpointer *buf, 
+                             guint32 *len, GError **error)
+{
+  return THRIFT_PROTOCOL_GET_CLASS (protocol)->read_binary (protocol, buf,
+                                                            len, error);
+}
+
+gint32
+thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type, GError **error)
+{
+  switch (type)
+  {
+    case T_BOOL:
+      {
+        gboolean boolv;
+        return thrift_protocol_read_bool (protocol, &boolv, error);
+      }
+    case T_BYTE:
+      {
+        gint8 bytev;
+        return thrift_protocol_read_byte (protocol, &bytev, error);
+      }
+
+    case T_I16:
+      {
+        gint16 i16;
+        return thrift_protocol_read_i16 (protocol, &i16, error);
+      }
+    case T_I32:
+      {
+        gint32 i32;
+        return thrift_protocol_read_i32 (protocol, &i32, error);
+      }
+    case T_I64:
+      {
+        gint64 i64;
+        return thrift_protocol_read_i64 (protocol, &i64, error);
+      }
+    case T_DOUBLE:
+      {
+        gdouble dub;
+        return thrift_protocol_read_double (protocol, &dub, error);
+      }
+    case T_STRING:
+      {
+        gpointer data;
+        guint32 len;
+        gint32 ret = thrift_protocol_read_binary (protocol, &data, &len, error);
+        g_free (data);
+        return ret;
+      }
+    case T_STRUCT:
+      {
+        guint32 result = 0;
+        gchar *name;
+        gint16 fid;
+        ThriftType ftype;
+        result += thrift_protocol_read_struct_begin (protocol, &name, error);
+
+        while (1)
+        {
+          result += thrift_protocol_read_field_begin (protocol, &name, &ftype,
+                                                      &fid, error);
+          if (ftype == T_STOP)
+          {
+            break;
+          }
+          result += thrift_protocol_skip (protocol, ftype, error);
+          result += thrift_protocol_read_field_end (protocol, error);
+        }
+        result += thrift_protocol_read_struct_end (protocol, error);
+        return result;
+      }
+    case T_MAP:
+      {
+        guint32 result = 0;
+        ThriftType elem_type;
+        guint32 i, size;
+        result += thrift_protocol_read_set_begin (protocol, &elem_type, &size,
+                                                  error);
+        for (i = 0; i < size; i++)
+        {
+          result += thrift_protocol_skip (protocol, elem_type, error);
+        }
+        result += thrift_protocol_read_set_end (protocol, error);
+        return result;
+      }
+    case T_LIST:
+      {
+        guint32 result = 0;
+        ThriftType elem_type;
+        guint32 i, size;
+        result += thrift_protocol_read_list_begin (protocol, &elem_type, &size,
+                                                   error);
+        for (i = 0; i < size; i++)
+        {
+          result += thrift_protocol_skip (protocol, elem_type, error);
+        }
+        result += thrift_protocol_read_list_end (protocol, error);
+        return result;
+      }
+    default:
+      return 0;
+  }
+}
+
+/* define the GError domain for Thrift protocols */
+GQuark
+thrift_protocol_error_quark (void)
+{
+  return g_quark_from_static_string (THRIFT_PROTOCOL_ERROR_DOMAIN);
+}
+
+
+static void
+thrift_protocol_init (ThriftProtocol *protocol)
+{
+  protocol->transport = NULL;
+}
+
+static void
+thrift_protocol_class_init (ThriftProtocolClass *cls)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
+
+  gobject_class->get_property = thrift_protocol_get_property;
+  gobject_class->set_property = thrift_protocol_set_property;
+
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_PROTOCOL_TRANSPORT,
+      g_param_spec_object ("transport", "Transport", "Thrift Transport",
+                           THRIFT_TYPE_TRANSPORT,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  cls->write_message_begin = thrift_protocol_write_message_begin;
+  cls->write_message_end = thrift_protocol_write_message_end;
+  cls->write_struct_begin = thrift_protocol_write_struct_begin;
+  cls->write_struct_end = thrift_protocol_write_struct_end;
+  cls->write_field_begin = thrift_protocol_write_field_begin;
+  cls->write_field_end = thrift_protocol_write_field_end;
+  cls->write_field_stop = thrift_protocol_write_field_stop;
+  cls->write_map_begin = thrift_protocol_write_map_begin;
+  cls->write_map_end = thrift_protocol_write_map_end;
+  cls->write_list_begin = thrift_protocol_write_list_begin;
+  cls->write_list_end = thrift_protocol_write_list_end;
+  cls->write_set_begin = thrift_protocol_write_set_begin;
+  cls->write_set_end = thrift_protocol_write_set_end;
+  cls->write_bool = thrift_protocol_write_bool;
+  cls->write_byte = thrift_protocol_write_byte;
+  cls->write_i16 = thrift_protocol_write_i16;
+  cls->write_i32 = thrift_protocol_write_i32;
+  cls->write_i64 = thrift_protocol_write_i64;
+  cls->write_double = thrift_protocol_write_double;
+  cls->write_string = thrift_protocol_write_string;
+  cls->write_binary = thrift_protocol_write_binary;
+  cls->read_message_begin = thrift_protocol_read_message_begin;
+  cls->read_message_end = thrift_protocol_read_message_end;
+  cls->read_struct_begin = thrift_protocol_read_struct_begin;
+  cls->read_struct_end = thrift_protocol_read_struct_end;
+  cls->read_field_begin = thrift_protocol_read_field_begin;
+  cls->read_field_end = thrift_protocol_read_field_end;
+  cls->read_map_begin = thrift_protocol_read_map_begin;
+  cls->read_map_end = thrift_protocol_read_map_end;
+  cls->read_list_begin = thrift_protocol_read_list_begin;
+  cls->read_set_begin = thrift_protocol_read_set_begin;
+  cls->read_set_end = thrift_protocol_read_set_end;
+  cls->read_bool = thrift_protocol_read_bool;
+  cls->read_byte = thrift_protocol_read_byte;
+  cls->read_i16 = thrift_protocol_read_i16;
+  cls->read_i32 = thrift_protocol_read_i32;
+  cls->read_i64 = thrift_protocol_read_i64;
+  cls->read_double = thrift_protocol_read_double;
+  cls->read_string = thrift_protocol_read_string;
+  cls->read_binary = thrift_protocol_read_binary;
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h
new file mode 100644
index 0000000..b47498b
--- /dev/null
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h
@@ -0,0 +1,338 @@
+/*
+ * 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 _THRIFT_PROTOCOL_H
+#define _THRIFT_PROTOCOL_H
+
+#include <glib-object.h>
+
+#include <thrift/c_glib/transport/thrift_transport.h>
+
+G_BEGIN_DECLS
+
+/*! \file thrift_protocol.h
+ *  \brief Abstract class for Thrift protocol implementations.
+ */
+
+/**
+ * Enumerated definition of the types that the Thrift protocol supports.
+ * Take special note of the T_END type which is used specifically to mark
+ * the end of a sequence of fields.
+ */
+typedef enum {
+  T_STOP   = 0,
+  T_VOID   = 1,
+  T_BOOL   = 2,
+  T_BYTE   = 3,
+  T_I08    = 3,
+  T_I16    = 6,
+  T_I32    = 8,
+  T_U64    = 9,
+  T_I64    = 10,
+  T_DOUBLE = 4,
+  T_STRING = 11,
+  T_UTF7   = 11,
+  T_STRUCT = 12,
+  T_MAP    = 13,
+  T_SET    = 14,
+  T_LIST   = 15,
+  T_UTF8   = 16,
+  T_UTF16  = 17
+} ThriftType;
+
+/**
+ * Enumerated definition of the message types that the Thrift protocol
+ * supports.
+ */
+typedef enum {
+  T_CALL      = 1,
+  T_REPLY     = 2,
+  T_EXCEPTION = 3,
+  T_ONEWAY    = 4
+} ThriftMessageType;
+
+/* type macros */
+#define THRIFT_TYPE_PROTOCOL (thrift_protocol_get_type ())
+#define THRIFT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_PROTOCOL, ThriftProtocol))
+#define THRIFT_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_PROTOCOL))
+#define THRIFT_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_PROTOCOL, ThriftProtocolClass))
+#define THRIFT_IS_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_PROTOCOL))
+#define THRIFT_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_PROTOCOL, ThriftProtocolClass))
+
+/*!
+ * Thrift Protocol object
+ */
+struct _ThriftProtocol
+{
+  GObject parent;
+
+  /* protected */
+  ThriftTransport *transport;
+};
+typedef struct _ThriftProtocol ThriftProtocol;
+
+/*!
+ * Thrift Protocol class
+ */
+struct _ThriftProtocolClass
+{
+  GObjectClass parent;
+
+  gint32 (*write_message_begin) (ThriftProtocol *protocol, const gchar *name,
+                                 const ThriftMessageType message_type,
+                                 const gint32 seqid, GError **error);
+  gint32 (*write_message_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_struct_begin) (ThriftProtocol *protocol, const gchar *name,
+                                GError **error);
+  gint32 (*write_struct_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_field_begin) (ThriftProtocol *protocol, const gchar *name,
+                               const ThriftType field_type,
+                               const gint16 field_id, GError **error);
+  gint32 (*write_field_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_field_stop) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_map_begin) (ThriftProtocol *protocol,
+                             const ThriftType key_type,
+                             const ThriftType value_type,
+                             const guint32 size, GError **error);
+  gint32 (*write_map_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_list_begin) (ThriftProtocol *protocol,
+                              const ThriftType element_type,
+                              const guint32 size, GError **error);
+  gint32 (*write_list_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_set_begin) (ThriftProtocol *protocol,
+                             const ThriftType element_type,
+                             const guint32 size, GError **error);
+  gint32 (*write_set_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*write_bool) (ThriftProtocol *protocol, const gboolean value,
+                        GError **error);
+  gint32 (*write_byte) (ThriftProtocol *protocol, const gint8 value,
+                        GError **error);
+  gint32 (*write_i16) (ThriftProtocol *protocol, const gint16 value,
+                       GError **error);
+  gint32 (*write_i32) (ThriftProtocol *protocol, const gint32 value,
+                       GError **error);
+  gint32 (*write_i64) (ThriftProtocol *protocol, const gint64 value,
+                       GError **error);
+  gint32 (*write_double) (ThriftProtocol *protocol, const gdouble value,
+                          GError **error);
+  gint32 (*write_string) (ThriftProtocol *protocol, const gchar *str,
+                          GError **error);
+  gint32 (*write_binary) (ThriftProtocol *protocol, const gpointer buf,
+                          const guint32 len, GError **error);
+
+  gint32 (*read_message_begin) (ThriftProtocol *thrift_protocol, gchar **name,
+                                ThriftMessageType *message_type,
+                                gint32 *seqid, GError **error);
+  gint32 (*read_message_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*read_struct_begin) (ThriftProtocol *protocol, gchar **name,
+                               GError **error);
+  gint32 (*read_struct_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*read_field_begin) (ThriftProtocol *protocol, gchar **name,
+                              ThriftType *field_type, gint16 *field_id,
+                              GError **error);
+  gint32 (*read_field_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*read_map_begin) (ThriftProtocol *protocol, ThriftType *key_type,
+                            ThriftType *value_type, guint32 *size,
+                            GError **error);
+  gint32 (*read_map_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*read_list_begin) (ThriftProtocol *protocol, ThriftType *element_type,
+                             guint32 *size, GError **error);
+  gint32 (*read_list_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*read_set_begin) (ThriftProtocol *protocol, ThriftType *element_type,
+                            guint32 *size, GError **error);
+  gint32 (*read_set_end) (ThriftProtocol *protocol, GError **error);
+  gint32 (*read_bool) (ThriftProtocol *protocol, gboolean *value,
+                       GError **error);
+  gint32 (*read_byte) (ThriftProtocol *protocol, gint8 *value, GError **error);
+  gint32 (*read_i16) (ThriftProtocol *protocol, gint16 *value, GError **error);
+  gint32 (*read_i32) (ThriftProtocol *protocol, gint32 *value, GError **error);
+  gint32 (*read_i64) (ThriftProtocol *protocol, gint64 *value, GError **error);
+  gint32 (*read_double) (ThriftProtocol *protocol, gdouble *value,
+                         GError **error);
+  gint32 (*read_string) (ThriftProtocol *protocol, gchar **str, GError **error);
+  gint32 (*read_binary) (ThriftProtocol *protocol, gpointer *buf,
+                         guint32 *len, GError **error);
+};
+typedef struct _ThriftProtocolClass ThriftProtocolClass;
+
+/* used by THRIFT_TYPE_PROTOCOL */
+GType thrift_protocol_get_type (void);
+
+/* virtual public methods */
+gint32 thrift_protocol_write_message_begin (ThriftProtocol *protocol,
+           const gchar *name, const ThriftMessageType message_type,
+           const gint32 seqid, GError **error);
+
+gint32 thrift_protocol_write_message_end (ThriftProtocol *protocol,
+                                          GError **error);
+
+gint32 thrift_protocol_write_struct_begin (ThriftProtocol *protocol,
+                                           const gchar *name,
+                                           GError **error);
+
+gint32 thrift_protocol_write_struct_end (ThriftProtocol *protocol,
+                                         GError **error);
+
+gint32 thrift_protocol_write_field_begin (ThriftProtocol *protocol,
+                                          const gchar *name,
+                                          const ThriftType field_type,
+                                          const gint16 field_id,
+                                          GError **error);
+
+gint32 thrift_protocol_write_field_end (ThriftProtocol *protocol,
+                                        GError **error);
+
+gint32 thrift_protocol_write_field_stop (ThriftProtocol *protocol,
+                                         GError **error);
+
+gint32 thrift_protocol_write_map_begin (ThriftProtocol *protocol,
+                                        const ThriftType key_type,
+                                        const ThriftType value_type,
+                                        const guint32 size, GError **error);
+
+gint32 thrift_protocol_write_map_end (ThriftProtocol *protocol, GError **error);
+
+gint32 thrift_protocol_write_list_begin (ThriftProtocol *protocol,
+                                         const ThriftType element_type,
+                                         const guint32 size, GError **error);
+
+gint32 thrift_protocol_write_list_end (ThriftProtocol *protocol,
+                                       GError **error);
+
+gint32 thrift_protocol_write_set_begin (ThriftProtocol *protocol,
+                                        const ThriftType element_type,
+                                        const guint32 size, GError **error);
+
+gint32 thrift_protocol_write_set_end (ThriftProtocol *protocol,
+                                      GError **error);
+
+gint32 thrift_protocol_write_bool (ThriftProtocol *protocol,
+                                   const gboolean value, GError **error);
+
+gint32 thrift_protocol_write_byte (ThriftProtocol *protocol, const gint8 value,
+                                   GError **error);
+
+gint32 thrift_protocol_write_i16 (ThriftProtocol *protocol, const gint16 value,
+                                  GError **error);
+
+gint32 thrift_protocol_write_i32 (ThriftProtocol *protocol, const gint32 value,
+                                  GError **error);
+
+gint32 thrift_protocol_write_i64 (ThriftProtocol *protocol, const gint64 value,
+                                  GError **error);
+
+gint32 thrift_protocol_write_double (ThriftProtocol *protocol,
+                                     const gdouble value, GError **error);
+
+gint32 thrift_protocol_write_string (ThriftProtocol *protocol,
+                                     const gchar *str, GError **error);
+
+gint32 thrift_protocol_write_binary (ThriftProtocol *protocol,
+                                     const gpointer buf,
+                                     const guint32 len, GError **error);
+
+gint32 thrift_protocol_read_message_begin (ThriftProtocol *thrift_protocol,
+                                           gchar **name,
+                                           ThriftMessageType *message_type,
+                                           gint32 *seqid, GError **error);
+
+gint32 thrift_protocol_read_message_end (ThriftProtocol *protocol,
+                                         GError **error);
+
+gint32 thrift_protocol_read_struct_begin (ThriftProtocol *protocol,
+                                          gchar **name,
+                                          GError **error);
+
+gint32 thrift_protocol_read_struct_end (ThriftProtocol *protocol,
+                                        GError **error);
+
+gint32 thrift_protocol_read_field_begin (ThriftProtocol *protocol,
+                                         gchar **name,
+                                         ThriftType *field_type,
+                                         gint16 *field_id,
+                                         GError **error);
+
+gint32 thrift_protocol_read_field_end (ThriftProtocol *protocol,
+                                       GError **error);
+
+gint32 thrift_protocol_read_map_begin (ThriftProtocol *protocol,
+                                       ThriftType *key_type,
+                                       ThriftType *value_type, guint32 *size,
+                                       GError **error);
+
+gint32 thrift_protocol_read_map_end (ThriftProtocol *protocol, GError **error);
+
+gint32 thrift_protocol_read_list_begin (ThriftProtocol *protocol,
+                                        ThriftType *element_type,
+                                        guint32 *size, GError **error);
+
+gint32 thrift_protocol_read_list_end (ThriftProtocol *protocol, GError **error);
+
+gint32 thrift_protocol_read_set_begin (ThriftProtocol *protocol,
+                                       ThriftType *element_type,
+                                       guint32 *size, GError **error);
+
+gint32 thrift_protocol_read_set_end (ThriftProtocol *protocol, GError **error);
+
+gint32 thrift_protocol_read_bool (ThriftProtocol *protocol, gboolean *value,
+                                  GError **error);
+
+gint32 thrift_protocol_read_byte (ThriftProtocol *protocol, gint8 *value,
+                                  GError **error);
+
+gint32 thrift_protocol_read_i16 (ThriftProtocol *protocol, gint16 *value,
+                                 GError **error);
+
+gint32 thrift_protocol_read_i32 (ThriftProtocol *protocol, gint32 *value,
+                                 GError **error);
+
+gint32 thrift_protocol_read_i64 (ThriftProtocol *protocol, gint64 *value,
+                                 GError **error);
+
+gint32 thrift_protocol_read_double (ThriftProtocol *protocol,
+                                    gdouble *value, GError **error);
+
+gint32 thrift_protocol_read_string (ThriftProtocol *protocol,
+                                    gchar **str, GError **error);
+
+gint32 thrift_protocol_read_binary (ThriftProtocol *protocol,
+                                    gpointer *buf, guint32 *len,
+                                    GError **error);
+
+gint32 thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type,
+                             GError **error);
+
+/* define error types */
+typedef enum
+{
+  THRIFT_PROTOCOL_ERROR_UNKNOWN,
+  THRIFT_PROTOCOL_ERROR_INVALID_DATA,
+  THRIFT_PROTOCOL_ERROR_NEGATIVE_SIZE,
+  THRIFT_PROTOCOL_ERROR_SIZE_LIMIT,
+  THRIFT_PROTOCOL_ERROR_BAD_VERSION,
+  THRIFT_PROTOCOL_ERROR_NOT_IMPLEMENTED
+} ThriftProtocolError;
+
+/* define an error domain for GError to use */
+GQuark thrift_protocol_error_quark (void);
+#define THRIFT_PROTOCOL_ERROR (thrift_protocol_error_quark ())
+
+G_END_DECLS
+
+#endif /* _THRIFT_PROTOCOL_H */