You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2018/03/02 18:48:33 UTC

[2/3] thrift git commit: THRIFT-82: Add Common Lisp support Client: cl

THRIFT-82: Add Common Lisp support
Client: cl

There's framed and buffered socket transport, binary protocol, multiplex, simple
server, cross-tests, self-tests, tutorial, CL library, CL code generator. Only
SBCL is supported for now.

This closes #1412


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

Branch: refs/heads/master
Commit: e93a90171529625966294fb35eaebf35cf4c6ba7
Parents: d907cc9
Author: Tomek Kurcz <to...@gmail.com>
Authored: Tue Sep 19 09:16:43 2017 +0200
Committer: James E. King III <jk...@apache.org>
Committed: Fri Mar 2 13:44:50 2018 -0500

----------------------------------------------------------------------
 .gitignore                                      |  11 +
 LANGUAGES.md                                    |  12 +-
 Makefile.am                                     |   2 +-
 build/docker/README.md                          |   1 +
 build/docker/ubuntu-artful/Dockerfile           |   4 +
 compiler/cpp/Makefile.am                        |   3 +-
 .../cpp/src/thrift/generate/t_cl_generator.cc   | 558 +++++++++++++++++++
 configure.ac                                    |  23 +
 lib/Makefile.am                                 |   4 +
 lib/cl/Makefile.am                              |  40 ++
 lib/cl/README.md                                | 253 +++++++++
 lib/cl/READMES/readme-cassandra.lisp            |  64 +++
 lib/cl/ensure-externals.sh                      |  16 +
 lib/cl/load-locally.lisp                        |  23 +
 lib/cl/test/make-test-binary.lisp               |  31 ++
 test/Makefile.am                                |   6 +
 test/cl/Makefile.am                             |  42 ++
 test/cl/implementation.lisp                     | 135 +++++
 test/cl/make-test-client.lisp                   |  93 ++++
 test/cl/make-test-server.lisp                   |  80 +++
 test/cl/tests.lisp                              | 240 ++++++++
 test/features/known_failures_Linux.json         |   4 +-
 test/known_failures_Linux.json                  |  31 ++
 test/tests.json                                 |  17 +
 tutorial/Makefile.am                            |   4 +
 tutorial/cl/Makefile.am                         |  47 ++
 tutorial/cl/make-tutorial-client.lisp           |  51 ++
 tutorial/cl/make-tutorial-server.lisp           |  29 +
 tutorial/cl/shared-implementation.lisp          |  25 +
 tutorial/cl/thrift-tutorial.asd                 |  17 +
 tutorial/cl/tutorial-implementation.lisp        |  41 ++
 tutorial/shared.thrift                          |   1 +
 tutorial/tutorial.thrift                        |   2 +
 33 files changed, 1906 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 03e3e9e..f1a39ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -101,6 +101,9 @@ project.lock.json
 /contrib/fb303/py/fb303/ttypes.py
 /depcomp
 /install-sh
+/lib/cl/backport-update.zip
+/lib/cl/lib
+/lib/cl/run-tests
 /lib/cpp/Debug/
 /lib/cpp/Debug-mt/
 /lib/cpp/Release/
@@ -307,6 +310,8 @@ project.lock.json
 /test/results.json
 /test/c_glib/test_client
 /test/c_glib/test_server
+/test/cl/TestServer
+/test/cl/TestClient
 /test/cpp/StressTest
 /test/cpp/StressTestNonBlocking
 /test/cpp/TestClient
@@ -348,6 +353,8 @@ project.lock.json
 /test/rs/target/
 /test/rs/*.iml
 /test/rs/**/*.iml
+/tutorial/cl/TutorialClient
+/tutorial/cl/TutorialServer
 /tutorial/cpp/TutorialClient
 /tutorial/cpp/TutorialServer
 /tutorial/c_glib/tutorial_client
@@ -395,3 +402,7 @@ project.lock.json
 /tutorial/rs/target
 /tutorial/rs/Cargo.lock
 /ylwrap
+/lib/cl/quicklisp.lisp
+/lib/cl/externals/
+/lib/cl/run-tests
+/lib/cl/quicklisp/

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/LANGUAGES.md
----------------------------------------------------------------------
diff --git a/LANGUAGES.md b/LANGUAGES.md
index 7f6194e..348b5ea 100644
--- a/LANGUAGES.md
+++ b/LANGUAGES.md
@@ -1,6 +1,6 @@
 # Apache Thrift Language Support #
 
-Last Modified: 2017-10-05<br>
+Last Modified: 2018-01-13<br>
 Version: 0.10.0+
 
 Thrift supports many programming languages and has an impressive test suite that exercises most of the languages, protocols, and transports that represents a matrix of thousands of possible combinations.  Each language typically has a minimum required version as well as support libraries - some mandatory and some optional.  All of this information is provided below to help you assess whether you can use Apache Thrift with your project.  Obviously this is a complex matrix to maintain and may not be correct in all cases - if you spot an error please inform the developers using the mailing list.
@@ -82,6 +82,16 @@ The Language/Library Levels indicate the minimum and maximum versions that are u
 <td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312398">Cocoa</a></td>
 </tr>
 <tr align=center>
+<td align=left><a href="lib/cl/README.md">Common Lisp</a></td>
+<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
+<!-- Language Levels -------><td colspan=2>unknown</td>
+<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
+<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
+<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
+<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td></td>
+<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT-82">Common Lisp</a></td>
+</tr>
+<tr align=center>
 <td align=left><a href="lib/d/README.md">D</a></td>
 <!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
 <!-- Language Levels -------><td>2.070.2</td><td>2.077.1</td>

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 3d71fd4..205ea82 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,7 +54,7 @@ empty :=
 space := $(empty) $(empty)
 comma := ,
 
-CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_D@ @MAYBE_JAVA@ @MAYBE_CSHARP@ @MAYBE_PYTHON@ @MAYBE_PY3@ @MAYBE_RUBY@ @MAYBE_HASKELL@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ @MAYBE_ERLANG@ @MAYBE_LUA@ @MAYBE_RS@ @MAYBE_DOTNETCORE@
+CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_CL@ @MAYBE_D@ @MAYBE_JAVA@ @MAYBE_CSHARP@ @MAYBE_PYTHON@ @MAYBE_PY3@ @MAYBE_RUBY@ @MAYBE_HASKELL@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ @MAYBE_ERLANG@ @MAYBE_LUA@ @MAYBE_RS@ @MAYBE_DOTNETCORE@
 CROSS_LANGS_COMMA_SEPARATED = $(subst $(space),$(comma),$(CROSS_LANGS))
 
 if WITH_PY3

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/build/docker/README.md
----------------------------------------------------------------------
diff --git a/build/docker/README.md b/build/docker/README.md
index bc6c36a..28d5b16 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -142,6 +142,7 @@ Last updated: October 1, 2017
 | C++ clang | 3.4           | 3.8           | 4.0           |       |
 | C# (mono) | 3.2.8.0       | 4.2.1.0       | 4.6.2.7       |       |
 | c_glib    | 2.40.2        | 2.48.2        | 2.54.0        |       |
+| CL (sbcl) |               |               | 1.3.14        |       |
 | cocoa     |               |               |               | Not in CI |
 | d         | 2.070.2       | 2.073.2       | 2.077.1       |       |
 | dart      | 1.20.1        | 1.22.1        | 1.24.3        |       |

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/build/docker/ubuntu-artful/Dockerfile
----------------------------------------------------------------------
diff --git a/build/docker/ubuntu-artful/Dockerfile b/build/docker/ubuntu-artful/Dockerfile
index d8e7e12..b9c30f6 100644
--- a/build/docker/ubuntu-artful/Dockerfile
+++ b/build/docker/ubuntu-artful/Dockerfile
@@ -97,6 +97,10 @@ RUN apt-get install -y --no-install-recommends \
 
 ENV D_VERSION 2.077.1-0.1
 RUN apt-get install -y --no-install-recommends \
+`# Common Lisp (sbcl) dependencies` \
+      sbcl
+
+RUN apt-get install -y --no-install-recommends \
       `# D dependencies` \
       dmd-bin=$D_VERSION \
       libphobos2-dev=$D_VERSION \

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/compiler/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index bd2ba80..0b8ef2e 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -109,7 +109,8 @@ thrift_SOURCES += src/thrift/generate/t_c_glib_generator.cc \
                   src/thrift/generate/t_gv_generator.cc \
                   src/thrift/generate/t_d_generator.cc \
                   src/thrift/generate/t_lua_generator.cc \
-                  src/thrift/generate/t_rs_generator.cc
+                  src/thrift/generate/t_rs_generator.cc \
+                  src/thrift/generate/t_cl_generator.cc
 
 thrift_CPPFLAGS = -I$(srcdir)/src
 thrift_CXXFLAGS = -Wall -Wextra -pedantic -Werror

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/compiler/cpp/src/thrift/generate/t_cl_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thrift/generate/t_cl_generator.cc b/compiler/cpp/src/thrift/generate/t_cl_generator.cc
new file mode 100644
index 0000000..f1fab25
--- /dev/null
+++ b/compiler/cpp/src/thrift/generate/t_cl_generator.cc
@@ -0,0 +1,558 @@
+/*
+ * Copyright (c) 2008- Patrick Collison <pa...@collison.ie>
+ * Copyright (c) 2006- Facebook
+ *
+ * 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>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+#include <stdlib.h>
+#include <boost/tokenizer.hpp>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sstream>
+#include <string>
+#include <algorithm>
+
+#include "thrift/platform.h"
+#include "t_oop_generator.h"
+using namespace std;
+
+
+/**
+ * Common Lisp code generator.
+ *
+ * @author Patrick Collison <pa...@collison.ie>
+ */
+class t_cl_generator : public t_oop_generator {
+ public:
+  t_cl_generator(
+      t_program* program,
+      const std::map<std::string, std::string>& parsed_options,
+      const std::string& option_string)
+    : t_oop_generator(program)
+  {
+    no_asd = false;
+    system_prefix = "thrift-gen-";
+
+    std::map<std::string, std::string>::const_iterator iter;
+    
+    for(iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
+      if(iter->first.compare("no_asd") == 0) {
+        no_asd = true;
+      } else if (iter->first.compare("sys_pref") == 0) {
+	system_prefix = iter->second;
+      } else {
+        throw "unknown option cl:" + iter->first;
+      }
+    }
+    
+    out_dir_base_ = "gen-cl";
+    copy_options_ = option_string;
+  }
+
+  void init_generator();
+  void close_generator();
+
+  void generate_typedef     (t_typedef*  ttypedef);
+  void generate_enum        (t_enum*     tenum);
+  void generate_const       (t_const*    tconst);
+  void generate_struct      (t_struct*   tstruct);
+  void generate_xception    (t_struct*   txception);
+  void generate_service     (t_service*  tservice);
+  void generate_cl_struct (std::ofstream& out, t_struct* tstruct, bool is_exception);
+  void generate_cl_struct_internal (std::ofstream& out, t_struct* tstruct, bool is_exception);
+  void generate_exception_sig(std::ofstream& out, t_function* f);
+  std::string render_const_value(t_type* type, t_const_value* value);
+
+  std::string cl_autogen_comment();
+  void asdf_def(std::ofstream &out);
+  void package_def(std::ofstream &out);
+  void package_in(std::ofstream &out);
+  std::string generated_package();
+  std::string prefix(std::string name);
+  std::string package_of(t_program* program);
+  std::string package();
+  std::string render_includes();
+
+  std::string type_name(t_type* ttype);
+  std::string typespec (t_type *t);
+  std::string function_signature(t_function* tfunction);
+  std::string argument_list(t_struct* tstruct);
+
+  std::string cl_docstring(std::string raw);
+
+ private:
+
+  int temporary_var;
+  /**
+   * Isolate the variable definitions, as they can require structure definitions
+   */
+  std::ofstream f_asd_;
+  std::ofstream f_types_;
+  std::ofstream f_vars_;
+
+  std::string copy_options_;
+  
+  bool no_asd;
+  std::string system_prefix;
+};
+
+
+void t_cl_generator::init_generator() {
+  MKDIR(get_out_dir().c_str());
+  string program_dir = get_out_dir() + "/" + program_name_;
+  MKDIR(program_dir.c_str());
+
+  temporary_var = 0;
+
+  string f_types_name = program_dir + "/" + program_name_ + "-types.lisp";
+  string f_vars_name = program_dir + "/" + program_name_ + "-vars.lisp";
+
+  f_types_.open(f_types_name.c_str());
+  f_types_ << cl_autogen_comment() << endl;
+  f_vars_.open(f_vars_name.c_str());
+  f_vars_ << cl_autogen_comment() << endl;
+
+  package_def(f_types_);
+  package_in(f_types_);
+  package_in(f_vars_);
+
+  if (!no_asd) {
+    string f_asd_name = program_dir + "/" + system_prefix + program_name_ + ".asd";
+    f_asd_.open(f_asd_name.c_str());
+    f_asd_ << cl_autogen_comment() << endl;
+    asdf_def(f_asd_);
+  }
+}
+
+/**
+ * Renders all the imports necessary for including another Thrift program
+ */
+string t_cl_generator::render_includes() {
+  const vector<t_program*>& includes = program_->get_includes();
+  string result = "";
+  result += ":depends-on (:thrift";
+  for (size_t i = 0; i < includes.size(); ++i) {
+    result += " :" + system_prefix + underscore(includes[i]->get_name());
+  }
+  result += ")\n";
+  return result;
+}
+
+string t_cl_generator::package_of(t_program* program) {
+  string prefix = program->get_namespace("cl");
+  return prefix.empty() ? "thrift-generated" : prefix;
+}
+
+string t_cl_generator::package() {
+  return package_of(program_);
+}
+
+string t_cl_generator::prefix(string symbol) {
+  return "\"" + symbol + "\"";
+}
+
+string t_cl_generator::cl_autogen_comment() {
+  return
+    std::string(";;; ") + "Autogenerated by Thrift\n" +
+    ";;; DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
+    ";;; options string: " + copy_options_ + "\n";
+}
+
+string t_cl_generator::cl_docstring(string raw) {
+  replace(raw.begin(), raw.end(), '"', '\'');
+  return raw;
+}
+
+
+void t_cl_generator::close_generator() {
+  f_asd_.close();
+  f_types_.close();
+  f_vars_.close();
+}
+
+string t_cl_generator::generated_package() {
+  return program_->get_namespace("cpp");
+}
+
+void t_cl_generator::asdf_def(std::ofstream &out) {
+  out << "(asdf:defsystem #:" << system_prefix << program_name_ << endl;
+  indent_up();
+  out << indent() << render_includes()
+      << indent() << ":serial t" << endl
+      << indent() << ":components ("
+      << "(:file \"" << program_name_ << "-types\") "
+      << "(:file \"" << program_name_ << "-vars\")))" << endl;
+  indent_down();
+}
+
+/***
+ * Generate a package definition. Add use references equivalent to the idl file's include statements.
+ */
+void t_cl_generator::package_def(std::ofstream &out) {
+  const vector<t_program*>& includes = program_->get_includes();
+
+  out << "(thrift:def-package :" << package();
+  if ( includes.size() > 0 ) {
+    out << " :use (";
+    for (size_t i = 0; i < includes.size(); ++i) {
+      out << " :" << includes[i]->get_name();
+    }
+    out << ")";
+  }
+  out << ")" << endl << endl;
+}
+
+void t_cl_generator::package_in(std::ofstream &out) {
+  out << "(cl:in-package :" << package() << ")" << endl << endl;
+}
+
+/**
+ * Generates a typedef. This is not done in Common Lisp, types are all implicit.
+ *
+ * @param ttypedef The type definition
+ */
+void t_cl_generator::generate_typedef(t_typedef* ttypedef) {
+  (void)ttypedef;
+}
+
+void t_cl_generator::generate_enum(t_enum* tenum) {
+  f_types_ << "(thrift:def-enum " << prefix(tenum->get_name()) << endl;
+
+  vector<t_enum_value*> constants = tenum->get_constants();
+  vector<t_enum_value*>::iterator c_iter;
+  int value = -1;
+
+  indent_up();
+  f_types_ << indent() << "(";
+  for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
+    value = (*c_iter)->get_value();
+
+    if(c_iter != constants.begin()) f_types_ << endl << indent() << " ";
+
+    f_types_ << "(\"" << (*c_iter)->get_name() << "\" . " << value << ")";
+  }
+  indent_down();
+  f_types_ << "))" << endl << endl;
+}
+
+/**
+ * Generate a constant value
+ */
+void t_cl_generator::generate_const(t_const* tconst) {
+  t_type* type = tconst->get_type();
+  string name = tconst->get_name();
+  t_const_value* value = tconst->get_value();
+
+  f_vars_ << "(thrift:def-constant " << prefix(name) << " " << render_const_value(type, value) << ")"
+          << endl << endl;
+}
+
+/**
+ * Prints the value of a constant with the given type. Note that type checking
+ * is NOT performed in this function as it is always run beforehand using the
+ * validate_types method in main.cc
+ */
+string t_cl_generator::render_const_value(t_type* type, t_const_value* value) {
+  type = get_true_type(type);
+  std::ostringstream out;
+  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:
+      out << "\"" << value->get_string() << "\"";
+      break;
+    case t_base_type::TYPE_BOOL:
+      out << (value->get_integer() > 0 ? "t" : "nil");
+      break;
+    case t_base_type::TYPE_I8:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+      out << value->get_integer();
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        out << value->get_integer();
+      } else {
+        out << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+    }
+  } else if (type->is_enum()) {
+    indent(out) << value->get_integer();
+  } else if (type->is_struct() || type->is_xception()) {
+    out << (type->is_struct() ? "(make-instance '" : "(make-exception '") <<
+           lowercase(type->get_name()) << " " << endl;
+    indent_up();
+
+    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) {
+      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();
+      }
+
+      out << indent() << ":" << v_iter->first->get_string() << " " <<
+        render_const_value(field_type, v_iter->second) << endl;
+    }
+    out << indent() << ")";
+
+    indent_down();
+  } else if (type->is_map()) {
+    // emit an hash form with both keys and values to be evaluated
+    t_type* ktype = ((t_map*)type)->get_key_type();
+    t_type* vtype = ((t_map*)type)->get_val_type();
+    out << "(thrift:map ";
+    indent_up();
+    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) {
+      out << endl << indent()
+          << "(cl:cons " << render_const_value(ktype, v_iter->first) << " "
+          << render_const_value(vtype, v_iter->second) << ")";
+    }
+    indent_down();
+    out << indent() << ")";
+  } else if (type->is_list() || type->is_set()) {
+    t_type* etype;
+    if (type->is_list()) {
+      etype = ((t_list*)type)->get_elem_type();
+    } else {
+      etype = ((t_set*)type)->get_elem_type();
+    }
+    if (type->is_set()) {
+      out << "(thrift:set" << endl;
+    } else {
+      out << "(thrift:list" << endl;
+    }
+    indent_up();
+    indent_up();
+    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) {
+      out << indent() << render_const_value(etype, *v_iter) << endl;
+    }
+    out << indent() << ")";
+    indent_down();
+    indent_down();
+  } else {
+    throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
+  }
+  return out.str();
+}
+
+void t_cl_generator::generate_struct(t_struct* tstruct) {
+  generate_cl_struct(f_types_, tstruct, false);
+}
+
+void t_cl_generator::generate_xception(t_struct* txception) {
+  generate_cl_struct(f_types_, txception, true);
+}
+
+void t_cl_generator::generate_cl_struct_internal(std::ofstream& out, t_struct* tstruct, bool is_exception) {
+  (void)is_exception;
+  const vector<t_field*>& members = tstruct->get_members();
+  vector<t_field*>::const_iterator m_iter;
+
+  out << "(";
+
+  for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
+    t_const_value* value = (*m_iter)->get_value();
+    t_type* type = (*m_iter)->get_type();
+
+    if (m_iter != members.begin()) {
+      out << endl << indent() << " ";
+    }
+    out << "(" << prefix((*m_iter)->get_name()) << " " <<
+        ( (NULL != value) ? render_const_value(type, value) : "nil" ) <<
+        " :id " << (*m_iter)->get_key();
+    if ( type->is_base_type() && "string" == typespec(type) )
+      if ( ((t_base_type*)type)->is_binary() )
+        out << " :type binary";
+      else
+        out << " :type string";
+    else
+      out << " :type " << typespec(type);
+    if ( (*m_iter)->get_req() == t_field::T_OPTIONAL ) {
+      out << " :optional t";
+    }
+    if ( (*m_iter)->has_doc()) {
+      out << " :documentation \"" << cl_docstring((*m_iter)->get_doc()) << "\"";
+    }
+    out <<")";
+  }
+
+  out << ")";
+}
+
+void t_cl_generator::generate_cl_struct(std::ofstream& out, t_struct* tstruct, bool is_exception = false) {
+  std::string name = type_name(tstruct);
+  out << (is_exception ? "(thrift:def-exception " : "(thrift:def-struct ") <<
+      prefix(name) << endl;
+  indent_up();
+  if ( tstruct->has_doc() ) {
+    out << indent() ;
+    out << "\"" << cl_docstring(tstruct->get_doc()) << "\"" << endl;
+  }
+  out << indent() ;
+  generate_cl_struct_internal(out, tstruct, is_exception);
+  indent_down();
+  out << ")" << endl << endl;
+}
+
+void t_cl_generator::generate_exception_sig(std::ofstream& out, t_function* f) {
+  generate_cl_struct_internal(out, f->get_xceptions(), true);
+}
+
+void t_cl_generator::generate_service(t_service* tservice) {
+  string extends_client;
+  vector<t_function*> functions = tservice->get_functions();
+  vector<t_function*>::iterator f_iter;
+
+  if (tservice->get_extends() != NULL) {
+    extends_client = type_name(tservice->get_extends());
+  }
+
+  extends_client = extends_client.empty() ? "nil" : prefix(extends_client);
+
+  f_types_ << "(thrift:def-service " << prefix(service_name_) << " "
+           << extends_client;
+
+  indent_up();
+
+  if ( tservice->has_doc()) {
+      f_types_ << endl << indent()
+               << "(:documentation \"" << cl_docstring(tservice->get_doc()) << "\")";
+    }
+
+  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
+    t_function* function = *f_iter;
+    string fname = function->get_name();
+    string signature = function_signature(function);
+    t_struct* exceptions = function->get_xceptions();
+    const vector<t_field*>& xmembers = exceptions->get_members();
+
+    f_types_ << endl << indent() << "(:method " << prefix(fname);
+    f_types_ << " (" << signature << " "  << typespec((*f_iter)->get_returntype()) << ")";
+    if (xmembers.size() > 0) {
+      f_types_ << endl << indent() << " :exceptions " ;
+      generate_exception_sig(f_types_, function);
+    }
+    if ( (*f_iter)->is_oneway() ) {
+      f_types_ << endl << indent() << " :oneway t";
+    }
+    if ( (*f_iter)->has_doc() ) {
+      f_types_ << endl << indent() << " :documentation \""
+               << cl_docstring((*f_iter)->get_doc()) << "\"";
+  }
+    f_types_ << ")";
+  }
+
+  f_types_ << ")" << endl << endl;
+
+  indent_down();
+}
+
+string t_cl_generator::typespec(t_type *t) {
+  t = get_true_type(t);
+
+  if (t -> is_binary()){
+    return "binary";
+  } else if (t->is_base_type()) {
+    return type_name(t);
+  } else if (t->is_map()) {
+    t_map *m = (t_map*) t;
+    return "(thrift:map " + typespec(m->get_key_type()) + " " + 
+      typespec(m->get_val_type()) + ")";
+  } else if (t->is_struct() || t->is_xception()) {
+    return "(struct " + prefix(type_name(t)) + ")";
+  } else if (t->is_list()) {
+    return "(thrift:list " + typespec(((t_list*) t)->get_elem_type()) + ")";
+  } else if (t->is_set()) {
+    return "(thrift:set " + typespec(((t_set*) t)->get_elem_type()) + ")";
+  } else if (t->is_enum()) {
+    return "(enum \"" + ((t_enum*) t)->get_name() + "\")";
+  } else {
+    throw "Sorry, I don't know how to generate this: " + type_name(t);
+  }
+}
+
+string t_cl_generator::function_signature(t_function* tfunction) {
+  return argument_list(tfunction->get_arglist());
+}
+
+string t_cl_generator::argument_list(t_struct* tstruct) {
+  stringstream res;
+  res << "(";
+
+  const vector<t_field*>& fields = tstruct->get_members();
+  vector<t_field*>::const_iterator f_iter;
+  bool first = true;
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    if (first) {
+      first = false;
+    } else {
+      res << " ";
+    }
+    res << "(" + prefix((*f_iter)->get_name()) << " " <<
+      typespec((*f_iter)->get_type()) << " " <<
+      (*f_iter)->get_key() <<  ")";
+
+    
+  }
+  res << ")";
+  return res.str();
+}
+
+string t_cl_generator::type_name(t_type* ttype) {
+  string prefix = "";
+  t_program* program = ttype->get_program();
+
+  if (program != NULL && program != program_)
+    prefix = package_of(program) == package() ? "" : package_of(program) + ":";
+
+  string name = ttype->get_name();
+
+  if (ttype->is_struct() || ttype->is_xception())
+    name = lowercase(ttype->get_name());
+
+  return prefix + name;
+}
+
+THRIFT_REGISTER_GENERATOR(
+    cl,
+    "Common Lisp",
+    "    no_asd:          Do not define ASDF systems for each generated Thrift program.\n"
+    "    sys_pref=        The prefix to give ASDF system names. Default: thrift-gen-\n")

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index b20312f..7634823 100755
--- a/configure.ac
+++ b/configure.ac
@@ -119,6 +119,7 @@ if test "$enable_libs" = "no"; then
   have_libs="no"
   with_cpp="no"
   with_c_glib="no"
+  with_cl="no"
   with_java="no"
   with_csharp="no"
   with_python="no"
@@ -453,6 +454,16 @@ if test "$with_rs" = "yes";  then
 fi
 AM_CONDITIONAL(WITH_RS, [test "$have_rs" = "yes"])
 
+AX_THRIFT_LIB(cl, [Common Lisp], yes)
+have_cl="no"
+if test "$with_cl" = "yes";  then
+  AC_PATH_PROG([SBCL], [sbcl])
+  if test "x$SBCL" != "x"; then
+    have_cl="yes"
+  fi
+fi
+AM_CONDITIONAL(WITH_CL, [test "$have_cl" = "yes"])
+
 AX_THRIFT_LIB(haxe, [Haxe], yes)
 if test "$with_haxe" = "yes";  then
   AC_PATH_PROG([HAXE], [haxe])
@@ -784,6 +795,7 @@ AC_CONFIG_FILES([
   compiler/cpp/test/Makefile
   compiler/cpp/src/thrift/version.h
   lib/Makefile
+  lib/cl/Makefile
   lib/cpp/Makefile
   lib/cpp/test/Makefile
   lib/cpp/thrift-nb.pc
@@ -825,6 +837,7 @@ AC_CONFIG_FILES([
   test/Makefile
   test/features/Makefile
   test/c_glib/Makefile
+  test/cl/Makefile
   test/cpp/Makefile
   test/csharp/Makefile
   test/erl/Makefile
@@ -843,6 +856,7 @@ AC_CONFIG_FILES([
   test/rs/Makefile
   tutorial/Makefile
   tutorial/c_glib/Makefile
+  tutorial/cl/Makefile
   tutorial/cpp/Makefile
   tutorial/d/Makefile
   tutorial/go/Makefile
@@ -896,6 +910,8 @@ if test "$have_rs" = "yes" ; then MAYBE_RS="rs" ; else MAYBE_RS="" ; fi
 AC_SUBST([MAYBE_RS])
 if test "$have_dotnetcore" = "yes" ; then MAYBE_DOTNETCORE="netcore" ; else MAYBE_DOTNETCORE="" ; fi
 AC_SUBST([MAYBE_DOTNETCORE])
+if test "$have_cl" = "yes" ; then MAYBE_CL="cl" ; else MAYBE_CL="" ; fi
+AC_SUBST([MAYBE_CL])
 
 AC_OUTPUT
 
@@ -906,6 +922,7 @@ echo
 echo "Building C (GLib) Library .... : $have_c_glib"
 echo "Building C# (Mono) Library ... : $have_csharp"
 echo "Building C++ Library ......... : $have_cpp"
+echo "Building Common Lisp Library.. : $have_cl"
 echo "Building D Library ........... : $have_d"
 echo "Building Dart Library ........ : $have_dart"
 echo "Building dotnetcore Library .. : $have_dotnetcore"
@@ -940,6 +957,12 @@ if test "$have_cpp" = "yes" ; then
   echo "   Build TQTcpServer (Qt5) ... : $have_qt5"
   echo "   C++ compiler version ...... : $($CXX --version | head -1)"
 fi
+if test "$have_cl" = "yes" ; then
+  echo
+  echo "Common Lisp Library:"
+  echo "   Using Common Lisp ......... : $SBCL"
+  echo "   Using Common Lisp version . : $($SBCL --version)"
+fi
 if test "$have_d" = "yes" ; then
   echo
   echo "D Library:"

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 636f42c..0401c99 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -97,6 +97,10 @@ if WITH_RS
 SUBDIRS += rs
 endif
 
+if WITH_CL
+SUBDIRS += cl
+endif
+
 # All of the libs that don't use Automake need to go in here
 # so they will end up in our release tarballs.
 EXTRA_DIST = \

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/cl/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/cl/Makefile.am b/lib/cl/Makefile.am
new file mode 100644
index 0000000..34b3886
--- /dev/null
+++ b/lib/cl/Makefile.am
@@ -0,0 +1,40 @@
+#
+# 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 = $(top_builddir)/compiler/cpp/thrift
+
+all-local:
+	bash ensure-externals.sh
+
+run-tests: test/make-test-binary.lisp
+	$(SBCL) --script test/make-test-binary.lisp
+
+check-local: run-tests
+	./run-tests
+
+clean-local:
+	$(RM) run-tests quicklisp.lisp backport-update.zip
+	$(RM) -rf lib externals quicklisp
+
+EXTRA_DIST = \
+	README.md \
+	READMES \
+	load-locally.lisp \
+	test \
+	ensure-externals.sh

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/cl/README.md
----------------------------------------------------------------------
diff --git a/lib/cl/README.md b/lib/cl/README.md
new file mode 100644
index 0000000..1d6eafb
--- /dev/null
+++ b/lib/cl/README.md
@@ -0,0 +1,253 @@
+Thrift Common Lisp Library
+
+License
+=======
+
+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.
+
+
+
+Using Thrift with Common Lisp
+============================
+
+ Thrift is a protocol and library for language-independent communication between cooperating
+ processes. The communication takes the form of request and response messages, of which the forms
+ are specified in advance throufh a shared interface definition. A Thrift definition file is translated
+ into Lisp source files, which comprise several definitions:
+
+  * Three packages, one for the namespace of the implementation operators, and one each for request and
+  response operators.
+  * Various type definitions as implementations for Thrift typedef and enum definitions.
+  * DEF-STRUCT and DEF-EXCEPTION forms for Thrift struct and exception definitions.
+  * DEF-SERVICE forms for thrift service definitions.
+
+ Each service definition expands in a collection of generic function definitions. For each `op`
+ in the service definition, two functions are defined
+
+  * `op`-request is defined for use by a client. It accepts an additional initial `protocol` argument,
+    to act as the client proxy for the operation and mediate the interaction with a remote process
+    through a Thrift-encoded transport stream.
+  * `op`-response is defined for use by a server. It accepts a single `protocol` argument. A server
+    uses it to decode the request message, invoke the base `op` function with the message arguments,
+    encode and send the the result as a response, and handles exceptions.
+
+ The client interface is one operator
+
+  * `with-client (variable location) . body` : creates a connection in a dynamic context and closes it
+    upon exit. The variable is bound to a client proxy stream/protocol instance, which wraps the
+    base i/o stream - socket, file, etc, with an operators which implement the Thrift protocol
+    and transport mechanisms.
+
+ The server interface combines server and service objects
+
+  * `serve (location service)` : accepts connections on the designated port and responds to
+    requests of the service's operations.
+
+
+Building 
+--------
+
+The Thrift Common Lisp library is packaged as the ASDF[[1]] system `thrift`.
+It depends on the systems
+
+* puri[[2]] : for the thrift uri class
+* closer-mop[[3]] : for class metadata
+* trivial-utf-8[[4]] : for string codecs
+* usocket[[5]] : for the socket transport
+* ieee-floats[[6]] : for conversion between ints and floats
+* trivial-gray-streams[[7]] : an abstraction layer for gray streams
+* alexandria[[8]] : handy utilities
+
+The dependencies are bundled for local builds of tests and tutorial binaries - 
+it is possible to use those bundles to load the library, too.
+
+In order to build it, register those systems with ASDF and evaluate:
+
+    (asdf:load-system :thrift)
+
+This will compile and load the Lisp compiler for Thrift definition files, the
+transport and protocol implementations, and the client and server interface
+functions. In order to use Thrift in an application, one must also author and/or
+load the interface definitions for the remote service.[[9]] If one is implementing a service,
+one must also define the actual functions to which Thrift is to act as the proxy
+interface. The remainder of this document follows the Thrift tutorial to illustrate how
+to perform the steps
+
+  * implement the service
+  * translate the Thrift IDL
+  * load the Lisp service interfaces
+  * run a server for the service
+  * use a client to access the service remotely
+
+Note that, if one is to implement a new service, one will also need to author the
+IDL files, as there is no facility to generate them from a service implementation.
+
+
+Implement the Service
+---------------------
+
+The tutorial comprises serveral functions: `add`, `ping`, `zip`, and `calculate`.
+Each translated IDL file generates three packages for every service. In the case of
+the tutorial file, the relevant packages are:
+
+  * tutorial.calculator
+  * tutorial.calculator-implementation
+  * tutorial.calculator-response
+  
+This is to separate the request (generated), response (generated) and implementation
+(meant to be implemented by the programmer) functions for defined Thrift methods.
+
+It is suggested to work in the `tutorial-implementation` package while implementing
+the services - it imports the `common-lisp` package, while the service-specific ones
+don't (to avoid conflicts between Thrift method names and function names in `common-lisp`).
+
+    ;; define the base operations
+    
+    (in-package :tutorial-implementation)
+    
+    (defun tutorial.calculator-implementation:add (num1 num2)
+      (format t "~&Asked to add ~A and ~A." num1 num2)
+      (+ num1 num2))
+    
+    (defun tutorial.calculator-implementation:ping ()
+      (print :ping))
+    
+    (defun tutorial.calculator-implementation:zip ()
+      (print :zip))
+    
+    (defun tutorial.calculator-implementation:calculate (logid task)
+      (calculate-op (work-op task) (work-num1 task) (work-num2 task)))
+    
+    (defgeneric calculate-op (op arg1 arg2)
+      (:method :around (op arg1 arg2)
+        (let ((result (call-next-method)))
+          (format t "~&Asked to calculate: ~d on  ~A and ~A = ~d." op arg1 arg2 result)
+          result))
+    
+      (:method ((op (eql operation.add)) arg1 arg2)
+        (+ arg1 arg2))
+      (:method ((op (eql operation.subtract)) arg1 arg2)
+        (- arg1 arg2))
+      (:method ((op (eql operation.multiply)) arg1 arg2)
+        (* arg1 arg2))
+      (:method ((op (eql operation.divide)) arg1 arg2)
+        (/ arg1 arg2)))
+    
+    (defun zip () (print 'zip))
+
+
+Translate the Thrift IDL
+------------------------
+
+IDL files employ the file extension `thrift`. In this case, there are two files to translate
+  * `tutorial.thrift`
+  * `shared.thrift`
+As the former includes the latter, one uses it to generate the interfaces:
+
+    $THRIFT/bin/thrift -r --gen cl $THRIFT/tutorial/tutorial.thrift
+    
+`-r` stands for recursion, while `--gen` lets one choose the language to translate to.
+
+
+Load the Lisp translated service interfaces
+-------------------------------------------
+
+The translator generates three files for each IDL file. For example `tutorial-types.lisp`,
+`tutorial-vars.lisp` and an `.asd` file that can be used to load them both and pull in
+other includes (like `shared` within the tutorial) as dependencies.
+
+
+Run a Server for the Service
+----------------------------
+
+The actual service name, as specified in the `def-service` form in `tutorial.lisp`, is `calculator`. 
+Each service definition defines a global variable with the service name and binds it to a
+service instance whch describes the operations.
+
+In order to start a service, specify a location and the service instance. 
+
+    (in-package :tutorial)
+    (serve #u"thrift://127.0.0.1:9091" calculator)
+
+
+Use a Client to Access the Service Remotely
+-------------------------------------------
+
+
+[in some other process] run the client
+
+    (in-package :cl-user)
+
+    (macrolet ((show (form)
+                 `(format *trace-output* "~%~s =>~{ ~s~}"
+                          ',form
+                          (multiple-value-list (ignore-errors ,form)))))
+      (with-client (protocol #u"thrift://127.0.0.1:9091")
+        (show (tutorial.calculator:ping protocol))
+        (show (tutorial.calculator:add protocol 1 2))
+        (show (tutorial.calculator:add protocol 1 4))
+    
+        (let ((task (make-instance 'tutorial:work
+                      :op operation.subtract :num1 15 :num2 10)))
+          (show (tutorial.calculator:calculate protocol 1 task))
+        
+          (setf (tutorial:work-op task) operation.divide
+                (tutorial:work-num1 task) 1
+                (tutorial:work-num2 task) 0)
+          (show (tutorial.calculator:calculate protocol 1 task)))
+        
+        (show (shared.shared-service:get-struct protocol 1))
+    
+        (show (zip protocol))))
+
+Issues
+------
+
+### optional fields 
+ Where the IDL declares a field options, the def-struct form includes no
+ initform for the slot and the encoding operator skips an unbound slot. This leave some ambiguity
+ with bool fields.
+
+### instantiation protocol :
+ struct classes are standard classes and exception classes are
+ whatever the implementation prescribes. decoders apply make-struct to an initargs list.
+ particularly at the service end, there are advantages to resourcing structs and decoding
+ with direct side-effects on slot-values
+
+### maps:
+ Maps are now represented as hash tables. As data through the call/reply interface is all statically
+ typed, it is not necessary for the objects to themselves indicate the coding form. Association lists
+ would be sufficient. As the key type is arbitrary, property lists offer no additional convenience:
+ as `getf` operates with `eq` a new access interface would be necessary and they would not be
+ available for function application.
+
+
+ [1]: www.common-lisp.net/asdf
+ [2]: http://github.com/lisp/com.b9.puri.ppcre
+ [3]: www.common-lisp.net/closer-mop
+ [4]: trivial-utf-8
+ [5]: https://github.com/usocket/usocket
+ [6]: https://github.com/marijnh/ieee-floats
+ [7]: https://github.com/trivial-gray-streams/trivial-gray-streams
+ [8]: https://gitlab.common-lisp.net/alexandria/alexandria
+ [9]: http://wiki.apache.org/thrift/ThriftGeneration
+
+* usocket[[5]] : for the socket transport
+* ieee-floats[[6]] : for conversion between ints and floats
+* trivial-gray-streams[[7]] : an abstraction layer for gray streams
+* alexandria[[8]] : handy utilities

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/cl/READMES/readme-cassandra.lisp
----------------------------------------------------------------------
diff --git a/lib/cl/READMES/readme-cassandra.lisp b/lib/cl/READMES/readme-cassandra.lisp
new file mode 100644
index 0000000..72744ea
--- /dev/null
+++ b/lib/cl/READMES/readme-cassandra.lisp
@@ -0,0 +1,64 @@
+(in-package :cl-user)
+
+#+(or ccl sbcl) /development/source/library/
+(load "build-init.lisp")
+
+;;; ! first, select the api version in the cassandra system definition
+;;; as only one should be loaded at a time.
+(asdf:load-system :de.setf.cassandra)
+
+(in-package :de.setf.cassandra)
+
+(defparameter *c-location*
+  ;; remote
+  ;; #u"thrift://ec2-174-129-66-148.compute-1.amazonaws.com:9160"
+  ;; local
+  #u"thrift://127.0.0.1:9160"
+  "A cassandra service location - either the local one or a remote service 
+ - always a 'thrift' uri.")
+
+(defparameter *c* (thrift:client *c-location*))
+
+
+(cassandra:describe-keyspaces *c*)
+;; => ("Keyspace1" "system")
+
+(cassandra:describe-cluster-name *c*)
+;; =>"Test Cluster"
+
+(cassandra:describe-version *c*)
+;; => "2.1.0"
+
+(loop for space in (cassandra:describe-keyspaces *c*)
+      collect (loop for key being each hash-key of (cassandra:describe-keyspace *c* space)
+                    using (hash-value value)
+                    collect (cons key
+                                  (loop for key being each hash-key of value
+                                        using (hash-value value)
+                                        collect (cons key value)))))
+
+
+(close *c*)
+
+(defun describe-cassandra (location &optional (stream *standard-output*))
+  "Print the first-order store metadata for a cassandra LOCATION."
+
+  (thrift:with-client (cassandra location)
+    (let* ((keyspace-names (cassandra:describe-keyspaces cassandra))
+           (cluster (cassandra:describe-cluster-name cassandra))
+           (version (cassandra:describe-version cassandra))
+           (keyspace-descriptions (loop for space in keyspace-names
+                                        collect (cons space
+                                                      (loop for key being each hash-key
+                                                            of (cassandra:describe-keyspace cassandra space)
+                                                            using (hash-value value)
+                                                            collect (cons key
+                                                                          (loop for key being each hash-key of value
+                                                                                using (hash-value value)
+                                                                                collect (cons key value))))))))
+      (format stream "~&connection to : ~a" cassandra)
+      (format stream "~&version : ~a" version)
+      (format stream "~&cluster : ~a" cluster)
+      (format stream "~&keyspaces~{~{~%~%space: ~a~@{~%  ~{~a :~@{~20t~:w~^~%~}~}~}~}~}" keyspace-descriptions))))
+
+;;; (describe-cassandra *c-location*)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/cl/ensure-externals.sh
----------------------------------------------------------------------
diff --git a/lib/cl/ensure-externals.sh b/lib/cl/ensure-externals.sh
new file mode 100755
index 0000000..0495f03
--- /dev/null
+++ b/lib/cl/ensure-externals.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -e
+
+if [[ ! -e quicklisp.lisp ]]; then curl -O https://beta.quicklisp.org/quicklisp.lisp; fi
+sbcl --load quicklisp.lisp \
+     --eval "(ignore-errors (quicklisp-quickstart:install :path \"quicklisp/\"))" \
+     --eval "(load \"quicklisp/setup.lisp\")" \
+     --eval "(quicklisp:bundle-systems '(#:puri #:usocket #:closer-mop #:trivial-utf-8 #:ieee-floats #:trivial-gray-streams #:alexandria #:bordeaux-threads #:cl-ppcre #:fiasco #:net.didierverna.clon) :to \"externals/\")" \
+     --eval "(quit)" \
+     --no-userinit
+if [[ ! -e backport-update.zip ]]; then
+    curl -O -L https://github.com/TurtleWarePL/de.setf.thrift/archive/backport-update.zip;
+fi
+mkdir -p lib
+unzip -u backport-update.zip -d lib

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/cl/load-locally.lisp
----------------------------------------------------------------------
diff --git a/lib/cl/load-locally.lisp b/lib/cl/load-locally.lisp
new file mode 100644
index 0000000..d12c704
--- /dev/null
+++ b/lib/cl/load-locally.lisp
@@ -0,0 +1,23 @@
+(in-package #:cl-user)
+
+;;;; Licensed 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.
+
+;;;; Just a script for loading the library itself, using bundled dependencies.
+;;;; This is here for when we want to build the self-test and cross-test
+;;;; binaries.
+
+(require "asdf")
+
+(load (merge-pathnames "externals/bundle.lisp" *load-truename*))
+(asdf:load-asd (merge-pathnames "lib/de.setf.thrift-backport-update/thrift.asd" *load-truename*))
+(asdf:load-system :thrift)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/lib/cl/test/make-test-binary.lisp
----------------------------------------------------------------------
diff --git a/lib/cl/test/make-test-binary.lisp b/lib/cl/test/make-test-binary.lisp
new file mode 100644
index 0000000..4e7a58c
--- /dev/null
+++ b/lib/cl/test/make-test-binary.lisp
@@ -0,0 +1,31 @@
+;;;; Licensed 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.
+
+;;;; This file is used to build the binary that runs all self-tests. The
+;;;; binary is then meant to be hooked up to Thrift's `make check` facility,
+;;;; but can easily be run on its own as well.
+
+(in-package #:cl-user)
+
+(require "asdf")
+(load (merge-pathnames "../load-locally.lisp" *load-truename*))
+(asdf:load-asd (merge-pathnames "../lib/de.setf.thrift-backport-update/test/thrift-test.asd" *load-truename*))
+(asdf:load-system :thrift-test)
+(asdf:load-system :net.didierverna.clon)
+
+(net.didierverna.clon:nickname-package)
+
+(defun main ()
+  (let ((result (if (fiasco:run-tests 'thrift-test) 0 -1)))
+    (clon:exit result)))
+
+(clon:dump "run-tests" main)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/Makefile.am
----------------------------------------------------------------------
diff --git a/test/Makefile.am b/test/Makefile.am
index 335bae6..cb3d9aa 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,6 +25,11 @@ SUBDIRS += c_glib
 PRECROSS_TARGET += precross-c_glib
 endif
 
+if WITH_CL
+SUBDIRS += cl
+PRECROSS_TARGET += precross-cl
+endif
+
 if WITH_MONO
 SUBDIRS += csharp
 PRECROSS_TARGET += precross-csharp
@@ -110,6 +115,7 @@ EXTRA_DIST = \
 	crossrunner \
 	keys \
 	c_glib \
+	cl \
 	cpp \
 	dart \
 	erl \

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/cl/Makefile.am
----------------------------------------------------------------------
diff --git a/test/cl/Makefile.am b/test/cl/Makefile.am
new file mode 100755
index 0000000..b5e72bc
--- /dev/null
+++ b/test/cl/Makefile.am
@@ -0,0 +1,42 @@
+#
+# 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 = $(top_builddir)/compiler/cpp/thrift
+
+stubs: ../ThriftTest.thrift
+	$(THRIFT) --gen cl ../ThriftTest.thrift
+
+TestServer: make-test-server.lisp
+	$(SBCL) --script make-test-server.lisp
+
+TestClient: make-test-client.lisp
+	$(SBCL) --script make-test-client.lisp
+
+precross: stubs TestServer TestClient
+
+clean-local:
+	$(RM) -r gen-cl
+	$(RM) TestServer
+	$(RM) TestClient
+
+EXTRA_DIST = \
+	implementation.lisp \
+	make-test-client.lisp \
+	make-test-server.lisp \
+	tests.lisp

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/cl/implementation.lisp
----------------------------------------------------------------------
diff --git a/test/cl/implementation.lisp b/test/cl/implementation.lisp
new file mode 100644
index 0000000..65a79b5
--- /dev/null
+++ b/test/cl/implementation.lisp
@@ -0,0 +1,135 @@
+(in-package #:thrift.test-implementation)
+
+;;;; Licensed 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.
+
+(defun thrift.test.thrift-test-implementation:test-void ()
+  (format t "testVoid()~%"))
+
+(defun thrift.test.thrift-test-implementation:test-string (thing)
+  (format t "testString(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-bool (thing)
+  (format t "testBool(~a)~%" (if thing "true" "false"))
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-byte (thing)
+  (format t "testByte(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-i32 (thing)
+  (format t "testI32(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-i64 (thing)
+  (format t "testI64(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-double (thing)
+  (format t "testDouble(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-binary (thing)
+  (format t "testBinary(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-struct (thing)
+  (format t "testStruct(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-nest (thing)
+  (format t "testNest(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-map (thing)
+  (format t "testMap(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-string-map (thing)
+  (format t "testStringMap(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-set (thing)
+  (format t "testSet(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-list (thing)
+  (format t "testList(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-enum (thing)
+  (format t "testEnum(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-typedef (thing)
+  (format t "testTypedef(~a)~%" thing)
+  thing)
+
+(defun thrift.test.thrift-test-implementation:test-map-map (hello)
+  (format t "testMapMap(~a)~%" hello)
+  '((-4 . ((-4 . -4) (-3 . -3) (-2 . -2) (-1 . -1))) (4 . ((1 . 1) (2 . 2) (3 . 3) (4 . 4)))))
+
+(defun thrift.test.thrift-test-implementation:test-insanity (argument)
+  (let ((result `((1 . ((2 . ,argument) (3 . ,argument)))
+                  (2 . ((6 . ,(thrift.test::make-insanity :user-map nil :xtructs nil)))))))
+    (format t "~a~%" result)
+    result))
+
+(defun thrift.test.thrift-test-implementation:test-multi (arg0 arg1 arg2 arg3 arg4 arg5)
+  (declare (ignorable arg3 arg4 arg5))
+  (format t "testMulti()~%")
+  (thrift.test:make-xtruct :string-thing "Hello2"
+                           :byte-thing arg0
+                           :i32-thing arg1
+                           :i64-thing arg2))
+
+(defun thrift.test.thrift-test-implementation:test-exception (arg)
+  (format t "testException(~a)~%" arg)
+  (cond
+    ((string= arg "Xception") (error 'thrift.test:xception
+                                     :error-code 1001
+                                     :message arg))
+    ((string= arg "TException") (error 'thrift.test:xception
+                                       :error-code 0
+                                       :message "Stuff!"))))
+
+(defun thrift.test.thrift-test-implementation:test-multi-exception (arg0 arg1)
+  (format t "testMultiException(~a, ~a)~%" arg0 arg1)
+  (cond
+    ((string= arg0 "Xception") (error 'thrift.test:xception
+                                     :error-code 1001
+                                     :message "This is an Xception"))
+    ((string= arg0 "Xception2") (error 'thrift.test:xception2
+                                     :error-code 2002
+                                     :struct-thing (thrift.test:make-xtruct :string-thing "This is an Xception2"
+                                                                            :byte-thing 0
+                                                                            :i32-thing 0
+                                                                            :i64-thing 0))))
+  (thrift.test:make-xtruct :string-thing arg1
+                           :byte-thing 0
+                           :i32-thing 0
+                           :i64-thing 0))
+
+(defun thrift.test.thrift-test-implementation:test-oneway (seconds)
+  (format t "testOneway(~a): Sleeping...~%" seconds)
+  (sleep seconds)
+  (format t "testOneway(~a): done sleeping!~%" seconds))
+
+;;; Removed from the IDL definition.
+#+(or)
+(defun thrift.test.second-service-implementation:blah-blah ()
+  (format t "blahBlah()~%"))
+
+(defun thrift.test.second-service-implementation:secondtest-string (thing)
+  (format t "secondtestString(~a)~%" thing)
+  thing)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/cl/make-test-client.lisp
----------------------------------------------------------------------
diff --git a/test/cl/make-test-client.lisp b/test/cl/make-test-client.lisp
new file mode 100644
index 0000000..509669d
--- /dev/null
+++ b/test/cl/make-test-client.lisp
@@ -0,0 +1,93 @@
+(in-package #:cl-user)
+
+;;;; Licensed 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.
+
+#+(or) (when (not (boundp 'sb-impl::default-external-format)
+                 (setf sb-impl::default-external-format :UTF-8)))
+
+(require "asdf")
+(load (merge-pathnames "../../lib/cl/load-locally.lisp" *load-truename*))
+(asdf:load-system :net.didierverna.clon)
+(asdf:load-system :fiasco)
+(asdf:load-asd (merge-pathnames "gen-cl/ThriftTest/thrift-gen-ThriftTest.asd" *load-truename*))
+(asdf:load-system :thrift-gen-thrifttest)
+
+(net.didierverna.clon:nickname-package)
+
+(defpackage #:thrift-cross
+  (:use #:common-lisp #:fiasco)
+  (:export #:cross-test))
+
+(in-package #:thrift-cross)
+
+(defparameter *prot* nil)
+
+(load (merge-pathnames "tests.lisp" *load-truename*) :external-format :UTF-8)
+
+(clon:defsynopsis ()
+  (text :contents "The Common Lisp client for Thrift's cross-language test suite.")
+  (group (:header "Allowed options:")
+    (flag :short-name "h" :long-name "help"
+          :description "Print this help and exit.")
+    (stropt :long-name "host"
+            :description "The host to connect to."
+            :default-value "localhost"
+            :argument-name "ARG")
+    (stropt :long-name "port"
+            :description "Number of the port to listen for connections on."
+            :default-value "9090"
+            :argument-name "ARG"
+            :argument-type :optional)
+    (stropt :long-name "transport"
+            :description "Transport: transport to use (\"buffered\", \"framed\")"
+            :default-value "buffered"
+            :argument-name "ARG")
+    (stropt :long-name "protocol"
+            :description "Protocol: protocol to use (\"binary\", \"multi\")"
+            :default-value "binary"
+            :argument-name "ARG")))
+
+(defun main ()
+  "Entry point for our standalone application."
+  (clon:make-context)
+  (when (clon:getopt :short-name "h")
+    (clon:help)
+    (clon:exit))
+  (let ((port "9090")
+        (host "localhost")
+        (framed nil)
+        (multiplexed nil))
+    (clon:do-cmdline-options (option name value source)
+      (print (list option name value source))
+      (if (string= name "host")
+          (setf host value))
+      (if (string= name "port")
+          (setf port value))
+      (if (string= name "transport")
+          (cond ((string= value "buffered") (setf framed nil))
+                ((string= value "framed") (setf framed t))
+                (t (error "Unsupported transport."))))
+      (if (string= name "protocol")
+          (cond ((string= value "binary") (setf multiplexed nil))
+                ((string= value "multi") (setf multiplexed t))
+                (t (error "Unsupported protocol.")))))
+    (terpri)
+    (setf *prot* (thrift.implementation::client (puri:parse-uri
+                                                 (concatenate 'string "thrift://" host ":" port))
+                                                :framed framed
+                                                :multiplexed multiplexed))
+    (let ((result (cross-test :multiplexed multiplexed)))
+      (thrift.implementation::close *prot*)
+      (clon:exit result))))
+
+(clon:dump "TestClient" main)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/cl/make-test-server.lisp
----------------------------------------------------------------------
diff --git a/test/cl/make-test-server.lisp b/test/cl/make-test-server.lisp
new file mode 100644
index 0000000..293c879
--- /dev/null
+++ b/test/cl/make-test-server.lisp
@@ -0,0 +1,80 @@
+(in-package #:cl-user)
+
+;;;; Licensed 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.
+
+(require "asdf")
+(load (merge-pathnames "../../lib/cl/load-locally.lisp" *load-truename*))
+(asdf:load-system :net.didierverna.clon)
+(asdf:load-asd (merge-pathnames "gen-cl/ThriftTest/thrift-gen-ThriftTest.asd" *load-truename*))
+(asdf:load-system :thrift-gen-thrifttest)
+(load (merge-pathnames "implementation.lisp" *load-truename*))
+
+(net.didierverna.clon:nickname-package)
+
+(clon:defsynopsis ()
+  (text :contents "The Common Lisp server for Thrift's cross-language test suite.")
+  (group (:header "Allowed options:")
+    (flag :short-name "h" :long-name "help"
+          :description "Print this help and exit.")
+    (stropt :long-name "port"
+            :description "Number of the port to listen for connections on."
+            :default-value "9090"
+            :argument-name "ARG"
+            :argument-type :optional)
+    (stropt :long-name "server-type"
+            :description "The type of server, currently only \"simple\" is available."
+            :default-value "simple"
+            :argument-name "ARG")
+    (stropt :long-name "transport"
+            :description "Transport: transport to use (\"buffered\" or \"framed\")"
+            :default-value "buffered"
+            :argument-name "ARG")
+    (stropt :long-name "protocol"
+            :description "Protocol: protocol to use (\"binary\" or \"multi\")"
+            :default-value "binary"
+            :argument-name "ARG")))
+
+(defun main ()
+  "Entry point for our standalone application."
+  (clon:make-context)
+  (when (clon:getopt :short-name "h")
+    (clon:help)
+    (clon:exit))
+  (let ((port "9090")
+        (framed nil)
+        (multiplexed nil))
+    (clon:do-cmdline-options (option name value source)
+      (print (list option name value source))
+      (if (string= name "port")
+          (setf port value))
+      (if (string= name "transport")
+          (cond ((string= value "buffered") (setf framed nil))
+                ((string= value "framed") (setf framed t))
+                (t (error "Unsupported transport."))))
+      (if (string= name "protocol")
+          (cond ((string= value "binary") (setf multiplexed nil))
+                ((string= value "multi") (setf multiplexed t))
+                (t (error "Unsupported protocol.")))))
+    (terpri)
+    (let ((services (if multiplexed
+                        (list thrift.test:thrift-test thrift.test:second-service)
+                        thrift.test:thrift-test)))
+      (thrift:serve (puri:parse-uri (concatenate 'string
+                                                 "thrift://127.0.0.1:"
+                                                 port))
+                    services
+                    :framed framed
+                    :multiplexed multiplexed)))
+  (clon:exit))
+
+(clon:dump "TestServer" main)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/cl/tests.lisp
----------------------------------------------------------------------
diff --git a/test/cl/tests.lisp b/test/cl/tests.lisp
new file mode 100644
index 0000000..c5035fd
--- /dev/null
+++ b/test/cl/tests.lisp
@@ -0,0 +1,240 @@
+(in-package #:thrift-cross)
+
+;;;; Licensed 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.
+
+;;;; The tests here only make sense in the context of a TestServer
+;;;; running and the dynamic variable thrift-cross::*prot*
+;;;; being set with a client connection to the TestServer. Normally,
+;;;; this is handled in make-test-client.lisp.
+
+
+;;; Standard Thrift cross-test error codes
+(defparameter *test_basetypes* 1)
+(defparameter *test_structs* 2)
+(defparameter *test_containers* 4)
+(defparameter *test_exceptions* 8)
+(defparameter *test_unknown* 64)
+(defparameter *test_timeout* 128)
+
+(defun cross-test (&key (multiplexed nil))
+  "The main cross-test runner."
+  (let ((result nil))
+    (handler-case
+        (progn
+          (unless (run-package-tests :package :base-types)
+            (pushnew *test_basetypes* result))
+          (unless (run-package-tests :package :structs)
+            (pushnew *test_structs* result))
+          (unless (run-package-tests :package :containers)
+            (pushnew *test_containers* result))
+          (unless (run-package-tests :package :exceptions)
+            (pushnew *test_exceptions* result))
+          (unless (run-package-tests :package :misc)
+            (pushnew *test_unknown* result))
+
+          ;; It doesn't seem like anyone actually uses
+          ;; the second test service when testing multiplexing,
+          ;; so this would fail against servers in other
+          ;; languages. For now, anyway.
+          #+(or)
+          (when multiplexed
+            (unless (run-package-tests :package :multiplex)
+              (pushnew *test_unknown* result))))
+      (error (e) (pushnew *test_unknown* result)))
+    (apply #'+ result)))
+
+(fiasco:define-test-package #:base-types)
+
+(in-package #:base-types)
+
+(defconstant *lang-string* "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, 
 Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws,
  中文, Bân-lâm-gú, 粵語")
+
+(defparameter *trick-string* (format nil "quote: \" backslash: \\ newline: ~% backspace: ~C ~
+                                          tab: ~T junk: !@#$%&()(&%$#{}{}<><><" #\backspace))
+
+(defconstant *binary-sequence* #(128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127))
+
+(deftest void-test ()
+  (is (null (thrift.test.thrift-test:test-void thrift-cross::*prot*))))
+
+(deftest boolean-test ()
+  (is (thrift.test.thrift-test:test-bool thrift-cross::*prot* t))
+  (is (not (thrift.test.thrift-test:test-bool thrift-cross::*prot* nil))))
+
+(deftest integer-test ()
+  (is (= (thrift.test.thrift-test:test-byte thrift-cross::*prot* 127) 127))
+  (is (= (thrift.test.thrift-test:test-byte thrift-cross::*prot* -128) -128))
+  (is (= (thrift.test.thrift-test:test-byte thrift-cross::*prot* 42) 42))
+  (is (= (thrift.test.thrift-test:test-byte thrift-cross::*prot* 0) 0))
+  (is (= (thrift.test.thrift-test:test-i32 thrift-cross::*prot* 0) 0))
+  (is (= (thrift.test.thrift-test:test-i32 thrift-cross::*prot* 2147483647) 2147483647))
+  (is (= (thrift.test.thrift-test:test-i32 thrift-cross::*prot* -2147483648) -2147483648))
+  (is (= (thrift.test.thrift-test:test-i64 thrift-cross::*prot* 0) 0))
+  (is (= (thrift.test.thrift-test:test-i64 thrift-cross::*prot* 9223372036854775807) 9223372036854775807))
+  (is (= (thrift.test.thrift-test:test-i64 thrift-cross::*prot* -9223372036854775808) -9223372036854775808)))
+
+(deftest double-test ()
+  (is (= (thrift.test.thrift-test:test-double thrift-cross::*prot* 0.0) 0))
+  (is (= (thrift.test.thrift-test:test-double thrift-cross::*prot* 42.0) 42))
+  (is (= (thrift.test.thrift-test:test-double thrift-cross::*prot* -555.0) -555))
+  (is (= (thrift.test.thrift-test:test-double thrift-cross::*prot* -52.3678) -52.3678)))
+
+(deftest string-test ()
+  (is (string= (thrift.test.thrift-test:test-string thrift-cross::*prot* "") ""))
+  (is (string= (thrift.test.thrift-test:test-string thrift-cross::*prot* "(defun botsbuildbots () (botsbuilsbots))")
+               "(defun botsbuildbots () (botsbuilsbots))"))
+  (is (string= (thrift.test.thrift-test:test-string thrift-cross::*prot* *lang-string*) *lang-string*))
+  (is (string= (thrift.test.thrift-test:test-string thrift-cross::*prot* *trick-string*) *trick-string*)))
+
+(deftest binary-test ()
+  (is (equalp (thrift.test.thrift-test:test-binary thrift-cross::*prot* #()) #()))
+  (is (equalp (thrift.test.thrift-test:test-binary thrift-cross::*prot* *binary-sequence*) *binary-sequence*)))
+
+(deftest enum-test ()
+  (is (= (thrift.test.thrift-test:test-enum thrift-cross::*prot* thrift.test:numberz.five) thrift.test:numberz.five))
+  (is (= (thrift.test.thrift-test:test-enum thrift-cross::*prot* thrift.test:numberz.eight) thrift.test:numberz.eight))
+  (is (= (thrift.test.thrift-test:test-enum thrift-cross::*prot* thrift.test:numberz.one) thrift.test:numberz.one)))
+
+(deftest typedef-test ()
+  (is (= (thrift.test.thrift-test:test-typedef thrift-cross::*prot* 309858235082523) 309858235082523)))
+
+(fiasco:define-test-package #:structs)
+
+(in-package #:structs)
+
+(defparameter *test-struct* (thrift.test:make-xtruct :string-thing "Hell is empty."
+                                                     :byte-thing -2
+                                                     :i32-thing 42
+                                                     :i64-thing 42424242))
+
+(defparameter *test-nest* (thrift.test:make-xtruct2 :byte-thing 42
+                                                    :struct-thing *test-struct*
+                                                    :i32-thing -42))
+
+(deftest struct-test ()
+  (let ((rec-struct (thrift.test.thrift-test:test-struct thrift-cross::*prot* *test-struct*)))
+    (is (string= (thrift.test:xtruct-string-thing *test-struct*)
+                 (thrift.test:xtruct-string-thing rec-struct)))
+    (is (= (thrift.test:xtruct-byte-thing *test-struct*)
+           (thrift.test:xtruct-byte-thing rec-struct)))
+    (is (= (thrift.test:xtruct-i32-thing *test-struct*)
+           (thrift.test:xtruct-i32-thing rec-struct)))
+    (is (= (thrift.test:xtruct-i64-thing *test-struct*)
+           (thrift.test:xtruct-i64-thing rec-struct)))))
+
+(deftest nest-test ()
+  (let* ((rec-nest (thrift.test.thrift-test:test-nest thrift-cross::*prot* *test-nest*))
+         (rec-struct (thrift.test:xtruct2-struct-thing rec-nest)))
+    (is (string= (thrift.test:xtruct-string-thing *test-struct*)
+                 (thrift.test:xtruct-string-thing rec-struct)))
+    (is (= (thrift.test:xtruct-byte-thing *test-struct*)
+           (thrift.test:xtruct-byte-thing rec-struct)))
+    (is (= (thrift.test:xtruct-i32-thing *test-struct*)
+           (thrift.test:xtruct-i32-thing rec-struct)))
+    (is (= (thrift.test:xtruct-i64-thing *test-struct*)
+           (thrift.test:xtruct-i64-thing rec-struct)))
+    (is (= (thrift.test:xtruct2-byte-thing *test-nest*)
+           (thrift.test:xtruct2-byte-thing rec-nest)))
+    (is (= (thrift.test:xtruct2-i32-thing *test-nest*)
+           (thrift.test:xtruct2-i32-thing rec-nest)))))
+
+(fiasco:define-test-package #:containers)
+
+(in-package #:containers)
+
+(deftest list-test ()
+  (is (null (thrift.test.thrift-test:test-list thrift-cross::*prot* nil)))
+  (is (equal (thrift.test.thrift-test:test-list thrift-cross::*prot* '(42 -42 0 5)) '(42 -42 0 5))))
+
+(deftest set-test ()
+  (is (null (thrift.test.thrift-test:test-set thrift-cross::*prot* nil)))
+  (is (equal (sort (thrift.test.thrift-test:test-set thrift-cross::*prot* (list 42 -42 0 5)) #'<)
+             '(-42 0 5 42))))
+
+(defun map= (map1 map2 &key (car-predicate #'equal) (cdr-predicate #'equal))
+  "Compare two assoc maps according to the predicates given."
+  (not (set-exclusive-or map1 map2 :test (lambda (el1 el2)
+                                           (and (funcall car-predicate
+                                                         (car el1)
+                                                         (car el2))
+                                                (funcall cdr-predicate
+                                                         (cdr el1)
+                                                         (cdr el2)))))))
+
+(deftest map-test ()
+  (is (null (thrift.test.thrift-test:test-map thrift-cross::*prot* nil)))
+  (is (map= (thrift.test.thrift-test:test-map thrift-cross::*prot* '((0 . 1) (42 . -42) (5 . 5)))
+            '((0 . 1) (42 . -42) (5 . 5))))
+  (is (map= (thrift.test.thrift-test:test-map-map thrift-cross::*prot* 42)
+            '((-4 . ((-4 . -4) (-3 . -3) (-2 . -2) (-1 . -1)))
+              (4 . ((1 . 1) (2 . 2) (3 . 3) (4 . 4))))
+            :cdr-predicate #'map=)))
+
+(fiasco:define-test-package #:exceptions)
+
+(in-package #:exceptions)
+
+(defun test-xception (expected-code expected-message function &rest args)
+  "A helper function to test whether xception is signalled, and whether its fields have the expected values."
+  (handler-case (progn (apply function args)
+                       nil)
+    (thrift.test:xception (ex) (and (= (thrift.test::xception-error-code ex) expected-code)
+                                    (string= (thrift.test::xception-message ex) expected-message)))))
+
+(defun test-xception2 (expected-code expected-message function &rest args)
+  "A helper function to test whether xception2 is signalled, and whether its fields have the expected values."
+  (handler-case (progn (apply function args)
+                       nil)
+    (thrift.test:xception2 (ex) (and (= (thrift.test::xception2-error-code ex) expected-code)
+                                     (string= (thrift.test::xtruct-string-thing
+                                               (thrift.test::xception2-struct-thing ex))
+                                              expected-message)))))
+
+(deftest exception-test ()
+  (is (test-xception 1001 "Xception" #'thrift.test.thrift-test:test-exception thrift-cross::*prot* "Xception"))
+  (signals thrift:application-error (thrift.test.thrift-test:test-exception thrift-cross::*prot* "TException"))
+  (finishes (thrift.test.thrift-test:test-exception thrift-cross::*prot* "success")))
+
+(deftest multi-exception-test ()
+  (is (test-xception 1001
+                     "This is an Xception"
+                     #'thrift.test.thrift-test:test-multi-exception
+                     thrift-cross::*prot*
+                     "Xception"
+                     "meaningless"))
+  (is (test-xception2 2002
+                      "This is an Xception2"
+                      #'thrift.test.thrift-test:test-multi-exception
+                      thrift-cross::*prot*
+                      "Xception2"
+                      "meaningless too!"))
+  (is (string= "foobar" (thrift.test:xtruct-string-thing
+                         (thrift.test.thrift-test:test-multi-exception thrift-cross::*prot*
+                                                           "success!"
+                                                           "foobar")))))
+
+(fiasco:define-test-package #:misc)
+
+(in-package #:misc)
+
+(deftest oneway-test ()
+  (is (null (thrift.test.thrift-test:test-oneway thrift-cross::*prot* 1))))
+
+(fiasco:define-test-package #:multiplex)
+
+(in-package #:multiplex)
+
+(deftest multiplex-test ()
+  ;; Removed from the IDL definition.
+  ;; (finishes (thrift.test.second-service:blah-blah thrift-cross::*prot*))
+  (is (string= "asd" (thrift.test.second-service:secondtest-string thrift-cross::*prot* "asd"))))

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/features/known_failures_Linux.json
----------------------------------------------------------------------
diff --git a/test/features/known_failures_Linux.json b/test/features/known_failures_Linux.json
index 6d1ed1f..8376968 100644
--- a/test/features/known_failures_Linux.json
+++ b/test/features/known_failures_Linux.json
@@ -1,6 +1,8 @@
 [
     "c_glib-limit_container_length_binary_buffered-ip",
     "c_glib-limit_string_length_binary_buffered-ip",
+    "cl-limit_string_length_binary_buffered-ip",
+    "cl-limit_container_length_binary_buffered-ip",
     "cpp-theader_framed_binary_multih-header_buffered-ip",
     "cpp-theader_framed_compact_multih-header_buffered-ip",
     "cpp-theader_unframed_binary_multih-header_buffered-ip",
@@ -45,4 +47,4 @@
     "rs-limit_string_length_multic-compact_buffered-ip",
     "netcore-limit_string_length_compact_buffered-ip",
     "netcore-limit_container_length_compact_buffered-ip"
-]
\ No newline at end of file
+]

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/known_failures_Linux.json
----------------------------------------------------------------------
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index a142796..082496d 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -11,6 +11,31 @@
   "c_glib-rs_multi_framed-ip",
   "c_glib-rs_multic_buffered-ip",
   "c_glib-rs_multic_framed-ip",
+  "cl-c_glib_binary_buffered-ip",
+  "cl-c_glib_binary_framed-ip",
+  "cl-c_glib_multi_buffered-ip",
+  "cl-c_glib_multi_framed-ip",
+  "cl-c_glib_multi-binary_buffered-ip",
+  "cl-c_glib_multi-binary_framed-ip",
+  "cl-csharp_multi_buffered-ip",
+  "cl-csharp_multi_framed-ip",
+  "cl-go_binary_buffered-ip",
+  "cl-go_binary_framed-ip",
+  "cl-java_multi_buffered-ip",
+  "cl-java_multi_framed-ip",
+  "cl-java_multi_framed-fastframed-ip",
+  "cl-perl_multi_buffered-ip",
+  "cl-perl_multi_framed-ip",
+  "cl-rb_binary_buffered-ip",
+  "cl-rb_binary_framed-ip",
+  "cl-rb_binary-accel_buffered-ip",
+  "cl-rb_binary-accel_framed-ip",
+  "cl-rs_binary_buffered-ip",
+  "cl-rs_binary_framed-ip",
+  "cl-rs_multi_buffered-ip",
+  "cl-rs_multi_framed-ip",
+  "cl-rs_multi-binary_buffered-ip",
+  "cl-rs_multi-binary_framed-ip",
   "cpp-dart_binary_http-ip",
   "cpp-dart_compact_http-ip",
   "cpp-dart_json_http-ip",
@@ -301,11 +326,17 @@
   "rs-cpp_multic-compact_framed-ip",
   "rs-cpp_multic_buffered-ip",
   "rs-cpp_multic_framed-ip",
+  "rs-csharp_binary_buffered-ip",
   "rs-csharp_binary_framed-ip",
+  "rs-csharp_compact_buffered-ip",
   "rs-csharp_compact_framed-ip",
+  "rs-csharp_multi-binary_buffered-ip",
   "rs-csharp_multi-binary_framed-ip",
+  "rs-csharp_multi_buffered-ip",
   "rs-csharp_multi_framed-ip",
+  "rs-csharp_multic-compact_buffered-ip",
   "rs-csharp_multic-compact_framed-ip",
+  "rs-csharp_multic_buffered-ip",
   "rs-csharp_multic_framed-ip",
   "rs-dart_binary_framed-ip",
   "rs-dart_compact_framed-ip",

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/test/tests.json
----------------------------------------------------------------------
diff --git a/test/tests.json b/test/tests.json
index 1640eac..671c667 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -43,6 +43,23 @@
     "workdir": "c_glib"
   },
   {
+    "name": "cl",
+    "server": {
+      "command": ["TestServer"],
+      "workdir": "cl",
+      "protocols": ["binary", "multi"],
+      "transports": ["buffered", "framed"],
+      "sockets": ["ip"]
+    },
+    "client": {
+      "command": ["TestClient"],
+      "workdir": "cl",
+      "protocols": ["binary", "multi"],
+      "transports": ["buffered", "framed"],
+      "sockets": ["ip"]
+    }
+  },
+  {
     "name": "d",
     "server": {
       "command": [

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/tutorial/Makefile.am
----------------------------------------------------------------------
diff --git a/tutorial/Makefile.am b/tutorial/Makefile.am
index d8ad09c..0499460 100755
--- a/tutorial/Makefile.am
+++ b/tutorial/Makefile.am
@@ -78,6 +78,10 @@ if WITH_RS
 SUBDIRS += rs
 endif
 
+if WITH_CL
+SUBDIRS += cl
+endif
+
 #
 # generate html for ThriftTest.thrift
 #

http://git-wip-us.apache.org/repos/asf/thrift/blob/e93a9017/tutorial/cl/Makefile.am
----------------------------------------------------------------------
diff --git a/tutorial/cl/Makefile.am b/tutorial/cl/Makefile.am
new file mode 100755
index 0000000..fb6e83a
--- /dev/null
+++ b/tutorial/cl/Makefile.am
@@ -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.
+#
+
+gen-cl: $(top_srcdir)/tutorial/tutorial.thrift
+	$(THRIFT) --gen cl -r $<
+
+TutorialServer: make-tutorial-server.lisp
+	$(SBCL) --script make-tutorial-server.lisp
+
+TutorialClient: make-tutorial-client.lisp
+	$(SBCL) --script make-tutorial-client.lisp
+
+all-local: gen-cl TutorialClient TutorialServer
+
+tutorialserver: all
+	./TutorialServer
+
+tutorialclient: all
+	./TutorialClient
+
+clean-local:
+	$(RM) -r gen-*
+	$(RM) TutorialServer
+	$(RM) TutorialClient
+
+EXTRA_DIST = \
+	tutorial-implementation.lisp \
+	shared-implementation.lisp \
+	thrift-tutorial.asd \
+	make-tutorial-server.lisp \
+	make-tutorial-client.lisp