diff --git a/CMakeLists.txt b/CMakeLists.txt index 721b0931..807503d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5.1) -project(rpc VERSION 2.3.0) +project(xpx.rpc VERSION 2.3.0) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -8,6 +8,10 @@ include(msvc_support) include(coverage) include(check_warning_flag) +if(WIN32) + add_definitions(-D _WIN32_WINNT=0x0601) +endif() + # # Options # @@ -59,6 +63,8 @@ set(CMAKE_CXX_STANDARD ${RPCLIB_CXX_STANDARD}) # if (WIN32) set(RPCLIB_OS_DEF "RPCLIB_WIN32") +elseif (WIN64) + set(RPCLIB_OS_DEF "RPCLIB_WIN64") elseif (LINUX) set(RPCLIB_OS_DEF "RPCLIB_LINUX") elseif (APPLE) @@ -90,7 +96,7 @@ set(DEP_SOURCES ${RPCLIB_DEPENDENCIES}/src/format.cc ${RPCLIB_DEPENDENCIES}/src/posix.cc) -add_library(${PROJECT_NAME} +add_library(${PROJECT_NAME} SHARED lib/rpc/dispatcher.cc lib/rpc/server.cc lib/rpc/client.cc @@ -261,4 +267,3 @@ if(NOT MSVC) # Don't install pkg-config files when building with MSVC configure_file(rpclib.pc.in "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" DESTINATION "${libdir}/pkgconfig") endif() - diff --git a/doc/pages/versions.md b/doc/pages/versions.md index b56c57bc..7fcf6355 100644 --- a/doc/pages/versions.md +++ b/doc/pages/versions.md @@ -1,4 +1,4 @@ -You are reading the documentation of 2.3.0. +You are reading the documentation of ... If, for some reason you need the documentation of older versions, you can download them from this page. * [1.0.0](/archive/rpclib_docs_1.0.0.zip) diff --git a/include/rpc/client.h b/include/rpc/client.h index fcd16ebe..0a2e6a3e 100644 --- a/include/rpc/client.h +++ b/include/rpc/client.h @@ -20,7 +20,11 @@ namespace rpc { //! functions. This class supports calling functions synchronously and //! asynchronously. When the client object is created, it initiates connecting //! to the given server asynchronically and disconnects when it is destroyed. +#if __MINGW32__ class client { +#else +class EXPORT client { +#endif public: //! \brief Constructs a client. //! @@ -77,8 +81,7 @@ class client { //! \returns A std::future, possibly holding a future result //! (which is a RPCLIB_MSGPACK::object). template - std::future async_call(std::string const &func_name, - Args... args); + std::future async_call(std::string const &func_name, Args... args); //! \brief Sends a notification with the given name and arguments (if any). //! @@ -144,4 +147,4 @@ class client { }; } -#include "rpc/client.inl" +#include "rpc/client.inl" \ No newline at end of file diff --git a/include/rpc/config.h b/include/rpc/config.h index f0611e34..79606d0b 100644 --- a/include/rpc/config.h +++ b/include/rpc/config.h @@ -8,6 +8,16 @@ #include "rpc/compatibility.h" +#if defined(WIN32) || defined(WIN64) +#ifdef DLL_EXPORTS +#define EXPORT __declspec(dllexport) +#else +#define EXPORT __declspec(dllimport) +#endif +#else +#define EXPORT __attribute__ ((visibility ("default"))) +#endif + namespace rpc { diff --git a/include/rpc/config.h.in b/include/rpc/config.h.in index d0538d01..5c52661f 100644 --- a/include/rpc/config.h.in +++ b/include/rpc/config.h.in @@ -8,6 +8,16 @@ #include "rpc/compatibility.h" +#if defined(WIN32) || defined(WIN64) +#ifdef DLL_EXPORTS +#define EXPORT __declspec(dllexport) +#else +#define EXPORT __declspec(dllimport) +#endif +#else +#define EXPORT __attribute__ ((visibility ("default"))) +#endif + namespace rpc { diff --git a/include/rpc/dispatcher.h b/include/rpc/dispatcher.h index 8044d4cb..0189f1d4 100644 --- a/include/rpc/dispatcher.h +++ b/include/rpc/dispatcher.h @@ -25,7 +25,11 @@ namespace detail { //! \brief This class maintains a registry of functors associated with their //! names, and callable using a msgpack-rpc call pack. +#if __MINGW32__ class dispatcher { +#else +class EXPORT dispatcher { +#endif public: //! \brief Binds a functor to a name so it becomes callable via RPC. //! \param name The name of the functor. @@ -96,7 +100,7 @@ class dispatcher { //! \brief Checks the argument count and throws an exception if //! it is not the expected amount. static void enforce_arg_count(std::string const &func, std::size_t found, - std::size_t expected); + std::size_t expected); void enforce_unique_name(std::string const &func); @@ -121,4 +125,4 @@ class dispatcher { #include "dispatcher.inl" -#endif /* end of include guard: DISPATCHER_H_CXIVZD5L */ +#endif /* end of include guard: DISPATCHER_H_CXIVZD5L */ \ No newline at end of file diff --git a/include/rpc/msgpack/v1/object.hpp b/include/rpc/msgpack/v1/object.hpp index a7220a5f..13108edc 100644 --- a/include/rpc/msgpack/v1/object.hpp +++ b/include/rpc/msgpack/v1/object.hpp @@ -652,8 +652,9 @@ inline object::object(const msgpack_object& o) inline void operator<< (clmdep_msgpack::object& o, const msgpack_object& v) { + auto buff = static_cast(v); // FIXME beter way? - std::memcpy(&o, &v, sizeof(v)); + std::memcpy(&o, &buff, sizeof(v)); } inline object::operator msgpack_object() const diff --git a/include/rpc/server.h b/include/rpc/server.h index 60c6b86a..4be9c46e 100644 --- a/include/rpc/server.h +++ b/include/rpc/server.h @@ -25,7 +25,11 @@ class server_session; //! to allow binding functions before that. Use the `run` or `async_run` //! functions to start listening on the port. //! This class is not copyable, but moveable. +#if __MINGW32__ class server { +#else +class EXPORT server { +#endif public: //! \brief Constructs a server that listens on the localhost on the //! specified port. @@ -121,4 +125,4 @@ class server { } /* rpc */ -#endif /* end of include guard: SERVER_H_S0HB5KXY */ +#endif /* end of include guard: SERVER_H_S0HB5KXY */ \ No newline at end of file diff --git a/include/rpc/version.h b/include/rpc/version.h index 47e19e92..cb699a59 100644 --- a/include/rpc/version.h +++ b/include/rpc/version.h @@ -5,9 +5,9 @@ namespace rpc { -static constexpr unsigned VERSION_MAJOR = 2; -static constexpr unsigned VERSION_MINOR = 3; -static constexpr unsigned VERSION_PATCH = 0; +static constexpr unsigned VERSION_MAJOR = ; +static constexpr unsigned VERSION_MINOR = ; +static constexpr unsigned VERSION_PATCH = ; } /* rpc */ diff --git a/lib/rpc/server.cc b/lib/rpc/server.cc index 1565b2b4..b3f0ef8d 100644 --- a/lib/rpc/server.cc +++ b/lib/rpc/server.cc @@ -55,9 +55,8 @@ struct server::impl { void start_accept() { acceptor_.async_accept(socket_, [this](std::error_code ec) { if (!ec) { - auto ep = socket_.remote_endpoint(); - LOG_INFO("Accepted connection from {}:{}", ep.address(), - ep.port()); + LOG_INFO("Accepted connection from {}:{}", socket_.remote_endpoint().address(), + socket_.remote_endpoint().port()); auto s = std::make_shared( parent_, &io_, std::move(socket_), parent_->disp_, suppress_exceptions_);