Permalink
Browse files

THRIFT-1500: d programming language support

Client: D
Patch: David Nadlinger

D program language library and additions



git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1304085 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent f485e2b commit b95b0ffa720ffdebd829861ed420d10deab6c852 @jfarrell jfarrell committed Mar 22, 2012
Showing with 23,339 additions and 1 deletion.
  1. +124 −0 aclocal/ax_check_openssl.m4
  2. +107 −0 aclocal/ax_dmd.m4
  3. +2 −1 compiler/cpp/Makefile.am
  4. +772 −0 compiler/cpp/src/generate/t_d_generator.cc
  5. +104 −0 configure.ac
  6. +4 −0 lib/Makefile.am
  7. +181 −0 lib/d/Makefile.am
  8. +58 −0 lib/d/README
  9. +228 −0 lib/d/src/thrift/async/base.d
  10. +461 −0 lib/d/src/thrift/async/libevent.d
  11. +357 −0 lib/d/src/thrift/async/socket.d
  12. +292 −0 lib/d/src/thrift/async/ssl.d
  13. +123 −0 lib/d/src/thrift/base.d
  14. +255 −0 lib/d/src/thrift/codegen/async_client.d
  15. +906 −0 lib/d/src/thrift/codegen/async_client_pool.d
  16. +950 −0 lib/d/src/thrift/codegen/base.d
  17. +484 −0 lib/d/src/thrift/codegen/client.d
  18. +262 −0 lib/d/src/thrift/codegen/client_pool.d
  19. +767 −0 lib/d/src/thrift/codegen/idlgen.d
  20. +497 −0 lib/d/src/thrift/codegen/processor.d
  21. +33 −0 lib/d/src/thrift/index.d
  22. +55 −0 lib/d/src/thrift/internal/algorithm.d
  23. +438 −0 lib/d/src/thrift/internal/codegen.d
  24. +96 −0 lib/d/src/thrift/internal/ctfe.d
  25. +75 −0 lib/d/src/thrift/internal/endian.d
  26. +419 −0 lib/d/src/thrift/internal/resource_pool.d
  27. +96 −0 lib/d/src/thrift/internal/socket.d
  28. +240 −0 lib/d/src/thrift/internal/ssl.d
  29. +190 −0 lib/d/src/thrift/internal/ssl_bio.d
  30. +183 −0 lib/d/src/thrift/internal/test/protocol.d
  31. +110 −0 lib/d/src/thrift/internal/test/server.d
  32. +141 −0 lib/d/src/thrift/internal/traits.d
  33. +436 −0 lib/d/src/thrift/protocol/base.d
  34. +414 −0 lib/d/src/thrift/protocol/binary.d
  35. +695 −0 lib/d/src/thrift/protocol/compact.d
  36. +979 −0 lib/d/src/thrift/protocol/json.d
  37. +145 −0 lib/d/src/thrift/protocol/processor.d
  38. +147 −0 lib/d/src/thrift/server/base.d
  39. +1,397 −0 lib/d/src/thrift/server/nonblocking.d
  40. +181 −0 lib/d/src/thrift/server/simple.d
  41. +302 −0 lib/d/src/thrift/server/taskpool.d
  42. +215 −0 lib/d/src/thrift/server/threaded.d
  43. +133 −0 lib/d/src/thrift/server/transport/base.d
  44. +380 −0 lib/d/src/thrift/server/transport/socket.d
  45. +88 −0 lib/d/src/thrift/server/transport/ssl.d
  46. +370 −0 lib/d/src/thrift/transport/base.d
  47. +215 −0 lib/d/src/thrift/transport/buffered.d
  48. +1,100 −0 lib/d/src/thrift/transport/file.d
  49. +334 −0 lib/d/src/thrift/transport/framed.d
  50. +459 −0 lib/d/src/thrift/transport/http.d
  51. +233 −0 lib/d/src/thrift/transport/memory.d
  52. +219 −0 lib/d/src/thrift/transport/piped.d
  53. +147 −0 lib/d/src/thrift/transport/range.d
  54. +453 −0 lib/d/src/thrift/transport/socket.d
  55. +680 −0 lib/d/src/thrift/transport/ssl.d
  56. +497 −0 lib/d/src/thrift/transport/zlib.d
  57. +212 −0 lib/d/src/thrift/util/awaitable.d
  58. +105 −0 lib/d/src/thrift/util/cancellation.d
  59. +549 −0 lib/d/src/thrift/util/future.d
  60. +145 −0 lib/d/src/thrift/util/hashset.d
  61. +123 −0 lib/d/test/Makefile.am
  62. +396 −0 lib/d/test/async_test.d
  63. +6 −0 lib/d/test/async_test_runner.sh
  64. +416 −0 lib/d/test/client_pool_test.d
  65. +14 −0 lib/d/test/openssl.test.cnf
  66. +70 −0 lib/d/test/serialization_benchmark.d
  67. +81 −0 lib/d/test/stress_test_server.d
  68. +96 −0 lib/d/test/test_utils.d
  69. +372 −0 lib/d/test/thrift_test_client.d
  70. +92 −0 lib/d/test/thrift_test_common.d
  71. +65 −0 lib/d/test/thrift_test_runner.sh
  72. +264 −0 lib/d/test/thrift_test_server.d
  73. +803 −0 lib/d/test/transport_test.d
  74. +1 −0 test/StressTest.thrift
  75. +37 −0 tutorial/d/Makefile
  76. +86 −0 tutorial/d/async_client.d
  77. +64 −0 tutorial/d/client.d
  78. +111 −0 tutorial/d/server.d
  79. +1 −0 tutorial/shared.thrift
  80. +1 −0 tutorial/tutorial.thrift
View
@@ -0,0 +1,124 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]])
+#
+# DESCRIPTION
+#
+# Look for OpenSSL in a number of default spots, or in a user-selected
+# spot (via --with-openssl). Sets
+#
+# OPENSSL_INCLUDES to the include directives required
+# OPENSSL_LIBS to the -l directives required
+# OPENSSL_LDFLAGS to the -L or -R flags required
+#
+# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
+#
+# This macro sets OPENSSL_INCLUDES such that source files should use the
+# openssl/ directory in include directives:
+#
+# #include <openssl/hmac.h>
+#
+# LICENSE
+#
+# Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
+# Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 8
+
+AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
+AC_DEFUN([AX_CHECK_OPENSSL], [
+ found=false
+ AC_ARG_WITH([openssl],
+ [AS_HELP_STRING([--with-openssl=DIR],
+ [root of the OpenSSL directory])],
+ [
+ case "$withval" in
+ "" | y | ye | yes | n | no)
+ AC_MSG_ERROR([Invalid --with-openssl value])
+ ;;
+ *) ssldirs="$withval"
+ ;;
+ esac
+ ], [
+ # if pkg-config is installed and openssl has installed a .pc file,
+ # then use that information and don't search ssldirs
+ AC_PATH_PROG([PKG_CONFIG], [pkg-config])
+ if test x"$PKG_CONFIG" != x""; then
+ OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
+ if test $? = 0; then
+ OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
+ OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
+ found=true
+ fi
+ fi
+
+ # no such luck; use some default ssldirs
+ if ! $found; then
+ ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
+ fi
+ ]
+ )
+
+
+ # note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
+ # an 'openssl' subdirectory
+
+ if ! $found; then
+ OPENSSL_INCLUDES=
+ for ssldir in $ssldirs; do
+ AC_MSG_CHECKING([for openssl/ssl.h in $ssldir])
+ if test -f "$ssldir/include/openssl/ssl.h"; then
+ OPENSSL_INCLUDES="-I$ssldir/include"
+ OPENSSL_LDFLAGS="-L$ssldir/lib"
+ OPENSSL_LIBS="-lssl -lcrypto"
+ found=true
+ AC_MSG_RESULT([yes])
+ break
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
+
+ # if the file wasn't found, well, go ahead and try the link anyway -- maybe
+ # it will just work!
+ fi
+
+ # try the preprocessor and linker with our new flags,
+ # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
+
+ AC_MSG_CHECKING([whether compiling and linking against OpenSSL works])
+ echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
+ "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD
+
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+ save_CPPFLAGS="$CPPFLAGS"
+ LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
+ LIBS="$OPENSSL_LIBS $LIBS"
+ CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
+ [
+ AC_MSG_RESULT([yes])
+ $1
+ ], [
+ AC_MSG_RESULT([no])
+ $2
+ ])
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+
+ AC_SUBST([OPENSSL_INCLUDES])
+ AC_SUBST([OPENSSL_LIBS])
+ AC_SUBST([OPENSSL_LDFLAGS])
+])
View
@@ -0,0 +1,107 @@
+dnl @synopsis AX_DMD
+dnl
+dnl Test for the presence of a DMD-compatible D2 compiler, and (optionally)
+dnl specified modules on the import path.
+dnl
+dnl If "DMD" is defined in the environment, that will be the only
+dnl dmd command tested. Otherwise, a hard-coded list will be used.
+dnl
+dnl After AX_DMD runs, the shell variables "success" and "ax_dmd" are set to
+dnl "yes" or "no", and "DMD" is set to the appropriate command. Furthermore,
+dnl "dmd_optlink" will be set to "yes" or "no" depending on whether OPTLINK is
+dnl used as the linker (DMD/Windows), and "dmd_of_dirsep" will be set to the
+dnl directory separator to use when passing -of to DMD (OPTLINK requires a
+dnl backslash).
+dnl
+dnl AX_CHECK_D_MODULE must be run after AX_DMD. It tests for the presence of a
+dnl module in the import path of the chosen compiler, and sets the shell
+dnl variable "success" to "yes" or "no".
+dnl
+dnl @category D
+dnl @version 2011-05-31
+dnl @license AllPermissive
+dnl
+dnl Copyright (C) 2009 David Reiss
+dnl Copyright (C) 2011 David Nadlinger
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+
+
+AC_DEFUN([AX_DMD],
+ [
+ dnl Hard-coded default commands to test.
+ DMD_PROGS="dmd,gdmd,ldmd"
+
+ dnl Allow the user to specify an alternative.
+ if test -n "$DMD" ; then
+ DMD_PROGS="$DMD"
+ fi
+
+ AC_MSG_CHECKING(for DMD)
+
+ # std.algorithm as a quick way to check for D2/Phobos.
+ echo "import std.algorithm; void main() {}" > configtest_ax_dmd.d
+ success=no
+ oIFS="$IFS"
+
+ IFS=","
+ for DMD in $DMD_PROGS ; do
+ IFS="$oIFS"
+
+ echo "Running \"$DMD configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD
+ if $DMD configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then
+ success=yes
+ break
+ fi
+ done
+
+ if test "$success" != "yes" ; then
+ AC_MSG_RESULT(no)
+ DMD=""
+ else
+ AC_MSG_RESULT(yes)
+ fi
+
+ ax_dmd="$success"
+
+ # Test whether OPTLINK is used by trying if DMD accepts -L/? without
+ # erroring out.
+ if test "$success" == "yes" ; then
+ AC_MSG_CHECKING(whether DMD uses OPTLINK)
+ echo "Running \”$DMD -L/? configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD
+ if $DMD -L/? configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then
+ AC_MSG_RESULT(yes)
+ dmd_optlink="yes"
+
+ # This actually produces double slashes in the final configure
+ # output, but at least it works.
+ dmd_of_dirsep="\\\\"
+ else
+ AC_MSG_RESULT(no)
+ dmd_optlink="no"
+ dmd_of_dirsep="/"
+ fi
+ fi
+
+ rm -f configtest_ax_dmd*
+ ])
+
+
+AC_DEFUN([AX_CHECK_D_MODULE],
+ [
+ AC_MSG_CHECKING(for D module [$1])
+
+ echo "import $1; void main() {}" > configtest_ax_dmd.d
+
+ echo "Running \"$DMD configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD
+ if $DMD -c configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then
+ AC_MSG_RESULT(yes)
+ success=yes
+ else
+ AC_MSG_RESULT(no)
+ success=no
+ fi
+
+ rm -f configtest_ax_dmd*
+ ])
View
@@ -83,7 +83,8 @@ thrift_SOURCES += src/generate/t_c_glib_generator.cc \
src/generate/t_js_generator.cc \
src/generate/t_javame_generator.cc \
src/generate/t_delphi_generator.cc \
- src/generate/t_go_generator.cc
+ src/generate/t_go_generator.cc \
+ src/generate/t_d_generator.cc
thrift_CPPFLAGS = -I$(srcdir)/src
thrift_CXXFLAGS = -Wall
Oops, something went wrong.

0 comments on commit b95b0ff

Please sign in to comment.