THRIFT-5501 Remove Common Lisp support

Client: cl
Patch: Jens Geyer
This commit is contained in:
Jens Geyer 2022-03-05 18:15:38 +01:00 committed by Jens Geyer
parent 66ac7b46fa
commit d88d4f93b3
33 changed files with 1 additions and 1913 deletions

View File

@ -78,7 +78,7 @@ empty :=
space := $(empty) $(empty)
comma := ,
CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_CL@ @MAYBE_D@ @MAYBE_JAVA@ @MAYBE_PYTHON@ @MAYBE_PY3@ @MAYBE_RUBY@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ @MAYBE_ERLANG@ @MAYBE_LUA@ @MAYBE_RS@ @MAYBE_NETSTD@ @MAYBE_NODETS@
CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_D@ @MAYBE_JAVA@ @MAYBE_PYTHON@ @MAYBE_PY3@ @MAYBE_RUBY@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ @MAYBE_ERLANG@ @MAYBE_LUA@ @MAYBE_RS@ @MAYBE_NETSTD@ @MAYBE_NODETS@
CROSS_LANGS_COMMA_SEPARATED = $(subst $(space),$(comma),$(CROSS_LANGS))
if WITH_PY3

View File

@ -173,7 +173,6 @@ Last updated: October 1, 2017
| C++ clang | 3.8 | 6.0 | |
| C# (mono) | 4.2.1.0 | 4.6.2.7 | |
| c_glib | 2.48.2 | 2.56.4 | |
| cl (sbcl) | | 1.5.3 | |
| d | 2.087.0 | 2.087.0 | |
| dart | 2.0.0 | 2.4.0 | |
| delphi | | | Not in CI |

View File

@ -85,17 +85,6 @@ RUN apt-get install -y --no-install-recommends \
qtbase5-dev \
qtbase5-dev-tools
ENV SBCL_VERSION 1.4.5
RUN \
`# Common Lisp (sbcl) dependencies` \
curl --version && \
curl -O -J -L https://kent.dl.sourceforge.net/project/sbcl/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \
tar xjf sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \
cd sbcl-${SBCL_VERSION}-x86-64-linux && \
./install.sh && \
sbcl --version && \
rm -rf sbcl*
ENV D_VERSION 2.080.0
ENV DMD_DEB dmd_2.080.0-0_amd64.deb
RUN \

View File

@ -89,18 +89,6 @@ RUN apt-get install -y --no-install-recommends \
qtbase5-dev \
qtbase5-dev-tools
ENV SBCL_VERSION 1.5.3
RUN \
`# Common Lisp (sbcl) dependencies` \
curl --version && \
curl -o sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 -J -L https://sourceforge.net/projects/sbcl/files/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2/download?use_mirror=managedway# && \
tar xjf sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \
cd sbcl-${SBCL_VERSION}-x86-64-linux && \
./install.sh && \
sbcl --version && \
cd .. && \
rm -rf sbcl*
ENV D_VERSION 2.087.0
ENV DMD_DEB dmd_2.087.0-0_amd64.deb
RUN \

View File

@ -89,18 +89,6 @@ RUN apt-get install -y --no-install-recommends \
qtbase5-dev \
qtbase5-dev-tools
ENV SBCL_VERSION 1.5.3
RUN \
`# Common Lisp (sbcl) dependencies` \
curl --version && \
curl -o sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 -J -L https://sourceforge.net/projects/sbcl/files/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2/download?use_mirror=managedway# && \
tar xjf sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \
cd sbcl-${SBCL_VERSION}-x86-64-linux && \
./install.sh && \
sbcl --version && \
cd .. && \
rm -rf sbcl*
ENV D_VERSION 2.087.0
ENV DMD_DEB dmd_2.087.0-0_amd64.deb
RUN \

View File

@ -73,7 +73,6 @@ endmacro()
# The following compiler can be enabled or disabled
THRIFT_ADD_COMPILER(c_glib "Enable compiler for C with Glib" ON)
THRIFT_ADD_COMPILER(cl "Enable compiler for Common LISP" ON)
THRIFT_ADD_COMPILER(cpp "Enable compiler for C++" ON)
THRIFT_ADD_COMPILER(d "Enable compiler for D" ON)
THRIFT_ADD_COMPILER(dart "Enable compiler for Dart" ON)

View File

@ -70,7 +70,6 @@ thrift_SOURCES = src/thrift/audit/t_audit.cpp \
# Specific client generator source
thrift_SOURCES += src/thrift/generate/t_c_glib_generator.cc \
src/thrift/generate/t_cl_generator.cc \
src/thrift/generate/t_cpp_generator.cc \
src/thrift/generate/t_d_generator.cc \
src/thrift/generate/t_dart_generator.cc \

View File

@ -54,7 +54,6 @@
<ClCompile Include="src\thrift\audit\t_audit.cpp" />
<ClCompile Include="src\thrift\common.cc" />
<ClCompile Include="src\thrift\generate\t_c_glib_generator.cc" />
<ClCompile Include="src\thrift\generate\t_cl_generator.cc" />
<ClCompile Include="src\thrift\generate\t_cpp_generator.cc" />
<ClCompile Include="src\thrift\generate\t_d_generator.cc" />
<ClCompile Include="src\thrift\generate\t_dart_generator.cc" />

View File

@ -1,558 +0,0 @@
/*
* Copyright (c) 2008- Patrick Collison <patrick@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 <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 <patrick@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() override;
void close_generator() override;
void generate_typedef (t_typedef* ttypedef) override;
void generate_enum (t_enum* tenum) override;
void generate_const (t_const* tconst) override;
void generate_struct (t_struct* tstruct) override;
void generate_xception (t_struct* txception) override;
void generate_service (t_service* tservice) override;
void generate_cl_struct (std::ostream& out, t_struct* tstruct, bool is_exception);
void generate_cl_struct_internal (std::ostream& out, t_struct* tstruct, bool is_exception);
void generate_exception_sig(std::ostream& 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::ostream &out);
void package_def(std::ostream &out);
void package_in(std::ostream &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
*/
ofstream_with_content_based_conditional_update f_asd_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update 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);
f_types_ << cl_autogen_comment() << endl;
f_vars_.open(f_vars_name);
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);
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 (auto include : includes) {
result += " :" + system_prefix + underscore(include->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::ostream &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::ostream &out) {
const vector<t_program*>& includes = program_->get_includes();
out << "(thrift:def-package :" << package();
if ( includes.size() > 0 ) {
out << " :use (";
for (auto include : includes) {
out << " :" << include->get_name();
}
out << ")";
}
out << ")" << endl << endl;
}
void t_cl_generator::package_in(std::ostream &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*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = nullptr;
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 == nullptr) {
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*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::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::ostream& 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()) << " " <<
( (nullptr != 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::ostream& 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::ostream& 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() != nullptr) {
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 != nullptr && 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")

View File

@ -237,9 +237,6 @@ t_generator* t_generator_registry::get_generator(t_program* program,
if ((language == "csharp") || (language == "netcore")) {
failure("The '%s' target is no longer available. Use 'netstd' instead.", language.c_str());
}
if (language == "cl") {
pwarning(1, "The '%s' target is deprecated and will be removed in future versions.", language.c_str());
}
if (iter == the_map.end()) {
return nullptr;

View File

@ -98,7 +98,6 @@ endmacro()
# The following compiler with unit tests can be enabled or disabled
THRIFT_ADD_COMPILER(c_glib "Enable compiler for C with Glib" OFF)
THRIFT_ADD_COMPILER(cl "Enable compiler for Common LISP" OFF)
THRIFT_ADD_COMPILER(cpp "Enable compiler for C++" OFF)
THRIFT_ADD_COMPILER(d "Enable compiler for D" OFF)
THRIFT_ADD_COMPILER(dart "Enable compiler for Dart" OFF)

View File

@ -112,7 +112,6 @@ if test "$enable_libs" = "no"; then
have_libs="no"
with_cpp="no"
with_c_glib="no"
with_cl="no"
with_java="no"
with_python="no"
with_py3="no"
@ -422,16 +421,6 @@ 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])
@ -732,7 +721,6 @@ AC_CONFIG_FILES([
compiler/cpp/src/Makefile
compiler/cpp/test/Makefile
lib/Makefile
lib/cl/Makefile
lib/cpp/Makefile
lib/cpp/test/Makefile
lib/cpp/thrift-nb.pc
@ -780,7 +768,6 @@ AC_CONFIG_FILES([
test/Makefile
test/features/Makefile
test/c_glib/Makefile
test/cl/Makefile
test/cpp/Makefile
test/erl/Makefile
test/go/Makefile
@ -797,7 +784,6 @@ AC_CONFIG_FILES([
test/rs/Makefile
tutorial/Makefile
tutorial/c_glib/Makefile
tutorial/cl/Makefile
tutorial/cpp/Makefile
tutorial/d/Makefile
tutorial/go/Makefile
@ -852,8 +838,6 @@ if test "$have_swift" = "yes" ; then MAYBE_SWIFT="swift" ; else MAYBE_SWIFT="" ;
AC_SUBST([MAYBE_SWIFT])
if test "$have_netstd" = "yes" ; then MAYBE_NETSTD="netstd" ; else MAYBE_NETSTD="" ; fi
AC_SUBST([MAYBE_NETSTD])
if test "$have_cl" = "yes" ; then MAYBE_CL="cl" ; else MAYBE_CL="" ; fi
AC_SUBST([MAYBE_CL])
AC_OUTPUT
@ -863,7 +847,6 @@ echo "$PACKAGE $VERSION"
echo
echo "Building C (GLib) Library .... : $have_c_glib"
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 .NET Standard Library : $have_netstd"
@ -895,12 +878,6 @@ 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:"

View File

@ -87,10 +87,6 @@ if WITH_RS
SUBDIRS += rs
endif
if WITH_CL
SUBDIRS += cl
endif
if WITH_SWIFT
SUBDIRS += swift
endif

View File

@ -1,42 +0,0 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
all-local:
bash ensure-externals.sh
run-tests: test/make-test-binary.lisp
@echo 'cl tests broken, commented out due to deprecation'
## $(SBCL) --script test/make-test-binary.lisp
check-local: run-tests
@echo 'cl tests broken, commented out due to deprecation'
## ./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

View File

@ -1,253 +0,0 @@
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

View File

@ -1,64 +0,0 @@
(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*)

View File

@ -1,16 +0,0 @@
#!/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

View File

@ -1,23 +0,0 @@
(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)

View File

@ -1,31 +0,0 @@
;;;; 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)

View File

@ -25,11 +25,6 @@ SUBDIRS += c_glib
PRECROSS_TARGET += precross-c_glib
endif
if WITH_CL
SUBDIRS += cl
PRECROSS_TARGET += precross-cl
endif
if WITH_CPP
SUBDIRS += cpp
PRECROSS_TARGET += precross-cpp
@ -118,7 +113,6 @@ dist-hook:
EXTRA_DIST = \
audit \
c_glib \
cl \
cpp \
crossrunner \
dart \

View File

@ -1,44 +0,0 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
stubs: ../ThriftTest.thrift
$(THRIFT) --gen cl ../ThriftTest.thrift
TestServer: make-test-server.lisp
@echo 'cl broken, commented out due to deprecation'
## $(SBCL) --script make-test-server.lisp
TestClient: make-test-client.lisp
@echo 'cl broken, commented out due to deprecation'
## $(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

View File

@ -1,136 +0,0 @@
(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)
(concatenate 'string "testString(\"" thing "\")"))

View File

@ -1,93 +0,0 @@
(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)

View File

@ -1,80 +0,0 @@
(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)

View File

@ -1,240 +0,0 @@
(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"))))

View File

@ -74,10 +74,6 @@ if WITH_RS
SUBDIRS += rs
endif
if WITH_CL
SUBDIRS += cl
endif
if WITH_PERL
SUBDIRS += perl
endif

View File

@ -1,67 +0,0 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
setup-local-lisp-env: ../../lib/cl/ensure-externals.sh
bash ../../lib/cl/ensure-externals.sh
gen-cl: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen cl -r $<
ALL_FILE_PREREQS = \
load-locally.lisp \
make-tutorial-server.lisp \
make-tutorial-client.lisp \
shared-implementation.lisp \
thrift-tutorial.asd \
tutorial-implementation.lisp
# NOTE: the server and client cannot be built in parallel
# because on loading the make-tutorial-* scripts SBCL will
# attempt to compile their dependencies. Unfortunately,
# because their dependencies are shared, parallel jobs can
# end up overwriting or corrupting the compiled files
all-local: gen-cl setup-local-lisp-env $(ALL_FILE_PREREQS)
@echo 'cl broken, commented out due to deprecation'
## $(SBCL) --script make-tutorial-server.lisp
## $(SBCL) --script make-tutorial-client.lisp
tutorialserver: all
./TutorialServer
tutorialclient: all
./TutorialClient
clean-local:
-$(RM) -r gen-*
-$(RM) -r externals
-$(RM) -r quicklisp
-$(RM) -r lib
-$(RM) quicklisp.lisp
-$(RM) backport-update.zip
-$(RM) shared-implementation.fasl
-$(RM) tutorial-implementation.fasl
-$(RM) TutorialServer
-$(RM) TutorialClient
EXTRA_DIST = \
tutorial-implementation.lisp \
shared-implementation.lisp \
thrift-tutorial.asd \
make-tutorial-server.lisp \
make-tutorial-client.lisp \
load-locally.lisp

View File

@ -1,22 +0,0 @@
(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 an identical copy of the file in lib/cl.
(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)

View File

@ -1,51 +0,0 @@
(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 "load-locally.lisp" *load-truename*))
(asdf:load-system :net.didierverna.clon)
(asdf:load-asd (merge-pathnames "gen-cl/shared/thrift-gen-shared.asd" *load-truename*))
(asdf:load-asd (merge-pathnames "gen-cl/tutorial/thrift-gen-tutorial.asd" *load-truename*))
(asdf:load-asd (merge-pathnames "thrift-tutorial.asd" *load-truename*))
(asdf:load-system :thrift-tutorial)
(net.didierverna.clon:nickname-package)
(defun main ()
"Entry point for the binary."
(thrift:with-client (prot #u"thrift://127.0.0.1:9090")
(tutorial.calculator:ping prot)
(format t "ping()~%")
(format t "1 + 1 = ~a~%" (tutorial.calculator:add prot 1 1))
(let ((work-instance (tutorial:make-work :num1 5
:num2 0
:op tutorial:operation.divide
:comment "Booya!")))
(handler-case (format t
"5 / 0 = ~a - Oh, really? An exception should have been thrown here.~%"
(tutorial.calculator:calculate prot 1 work-instance))
(tutorial:invalidoperation (e)
(format t "---~%(Expected) Invalid Operation caught: ~%~a~%---~%" e))))
(let ((work-instance (tutorial:make-work :num1 15
:num2 10
:op tutorial:operation.subtract
:comment "Playing nice this time.")))
(handler-case (format t
"15 - 10 = ~a~%"
(tutorial.calculator:calculate prot 1 work-instance))
(tutorial:invalidoperation (e)
(format t "---~%(Unexpected) Invalid Operation caught: ~%~a~%---~%" e))))
(format t "Check log: ~a~%" (shared.shared-service:get-struct prot 1))))
(clon:dump "TutorialClient" main)

View File

@ -1,29 +0,0 @@
(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 "load-locally.lisp" *load-truename*))
(asdf:load-system :net.didierverna.clon)
(asdf:load-asd (merge-pathnames "gen-cl/shared/thrift-gen-shared.asd" *load-truename*))
(asdf:load-asd (merge-pathnames "gen-cl/tutorial/thrift-gen-tutorial.asd" *load-truename*))
(asdf:load-asd (merge-pathnames "thrift-tutorial.asd" *load-truename*))
(asdf:load-system :thrift-tutorial)
(net.didierverna.clon:nickname-package)
(defun main ()
"Entry point for the binary."
(thrift:serve #u"thrift://127.0.0.1:9090" tutorial:calculator))
(clon:dump "TutorialServer" main)

View File

@ -1,25 +0,0 @@
(in-package #:shared-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.
(defvar *structs* (make-hash-table))
(defun shared.shared-service-implementation:get-struct (key)
(format t "getStruct(~a)~%" key)
(gethash key *structs*))
(defun add-log (key value)
(setf (gethash key *structs*)
(make-instance 'shared:sharedstruct
:key key
:value (write-to-string value))))

View File

@ -1,17 +0,0 @@
;;;; 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.
(asdf:defsystem #:thrift-tutorial
:depends-on (#:thrift-gen-tutorial)
:serial t
:components ((:file "shared-implementation")
(:file "tutorial-implementation")))

View File

@ -1,41 +0,0 @@
(in-package #:tutorial-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 tutorial.calculator-implementation:ping ()
(format t "ping()~%"))
(defun tutorial.calculator-implementation:add (num1 num2)
(format t "add(~a, ~a)~%" num1 num2)
(+ num1 num2))
(defun tutorial.calculator-implementation:calculate (logid work)
(format t "calculate(~a, ~a)~%" logid work)
(handler-case
(let* ((num1 (tutorial:work-num1 work))
(num2 (tutorial:work-num2 work))
(op (tutorial:work-op work))
(result
(cond
((= op tutorial:operation.add) (+ num1 num2))
((= op tutorial:operation.subtract) (- num1 num2))
((= op tutorial:operation.multiply) (* num1 num2))
((= op tutorial:operation.divide) (/ num1 num2)))))
(shared-implementation::add-log logid result)
result)
(division-by-zero () (error 'tutorial:invalidoperation
:why "Division by zero."
:what-op (tutorial:work-op work)))))
(defun tutorial.calculator-implementation:zip ()
(format t "zip()~%"))