From 7c420f87cd3274a4e685e7a5abf972d03f29414b Mon Sep 17 00:00:00 2001 From: pdurante Date: Mon, 23 Jul 2007 18:31:49 +0000 Subject: [PATCH] * Enabled the symbol visibility feature from gcc 4, reduces binary size and dynamic loading speed * A lot of fixes to keep compatibility with older (0.6x) versions of libdbus * Moved the xml handling code from the library to the code generator * Rewrote the routine to generate introspection data * Autojunk cleanup git-svn-id: http://dev.openwengo.org/svn/openwengo/wengophone-ng/branches/wengophone-dbus-api/libs/dbus@12019 30a43799-04e7-0310-8b2b-ea0d24f86d0e --- configure.ac | 85 +++++++++++++++++++---------- examples/echo/echo-client.cpp | 8 +++ include/dbus-c++/api.h | 42 ++++++++++++++ include/dbus-c++/config.h.in | 6 ++ include/dbus-c++/connection.h | 5 +- include/dbus-c++/dbus.h | 1 - include/dbus-c++/debug.h | 4 +- include/dbus-c++/dispatcher.h | 23 ++++---- include/dbus-c++/error.h | 66 +++++++++++----------- include/dbus-c++/eventloop.h | 13 +++-- include/dbus-c++/glib-integration.h | 7 ++- include/dbus-c++/interface.h | 13 +++-- include/dbus-c++/introspection.h | 13 +++-- include/dbus-c++/message.h | 19 ++++--- include/dbus-c++/object.h | 17 +++--- include/dbus-c++/pendingcall.h | 5 +- include/dbus-c++/property.h | 5 +- include/dbus-c++/refptr_impl.h | 1 + include/dbus-c++/server.h | 3 +- include/dbus-c++/types.h | 13 +++-- include/dbus-c++/util.h | 7 ++- src/Makefile.am | 7 +-- src/connection_p.h | 2 +- src/debug.cpp | 4 +- src/dispatcher.cpp | 2 + src/dispatcher_p.h | 2 +- src/error.cpp | 4 ++ src/internalerror.h | 2 +- src/introspection.cpp | 66 ++++++++++++---------- src/message_p.h | 2 +- src/pendingcall_p.h | 2 +- src/server_p.h | 2 +- tools/Makefile.am | 3 +- {src => tools}/xml.cpp | 3 +- {include/dbus-c++ => tools}/xml.h | 0 tools/xml2cpp.h | 2 + 36 files changed, 287 insertions(+), 172 deletions(-) create mode 100644 include/dbus-c++/api.h rename {src => tools}/xml.cpp (99%) rename {include/dbus-c++ => tools}/xml.h (100%) diff --git a/configure.ac b/configure.ac index 9b23c12..864e361 100644 --- a/configure.ac +++ b/configure.ac @@ -14,19 +14,22 @@ AC_CANONICAL_HOST AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable debugging support]), - enable_debug=$enableval,enable_debug=auto + [enable_debug=$enableval], + [enable_debug=no] ) AC_ARG_ENABLE(glib, AS_HELP_STRING([--enable-glib], [enable glib integration]), - enable_glib=$enableval,enable_debug=auto + [enable_glib=$enableval], + [enable_glib=no] ) AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs], [build DOXYGEN documentation (requires Doxygen)]), - enable_doxygen_docs=$enableval,enable_doxygen_docs=auto + [enable_doxygen_docs=$enableval], + [enable_doxygen_docs=no] ) # Check for programs @@ -44,10 +47,24 @@ AM_PROG_LIBTOOL PKG_PROG_PKG_CONFIG +AC_MSG_CHECKING([whether $CXX supports symbol visibility]) + +vtest=`$CXX --help --verbose 2>&1 | grep fvisibility` + +if test -n "$vtest"; then + AC_MSG_RESULT(yes) + + AC_DEFINE(GCC_HASCLASSVISIBILITY, 1, [to enable hidden symbols]) + CXXFLAGS="-fvisibility=hidden" +else + AC_MSG_RESULT(no) +fi + + # Check for dependencies DBUS_REQUIRED_VERSION=0.60 -PKG_CHECK_MODULES([dbus], dbus-1 >= $DBUS_REQUIRED_VERSION,, +PKG_CHECK_MODULES(dbus, [dbus-1 >= $DBUS_REQUIRED_VERSION],, AC_MSG_ERROR([You need the DBus libraries (version 0.6 or better)] [http://www.freedesktop.org/wiki/Software_2fdbus]) ) @@ -55,16 +72,22 @@ AC_SUBST(dbus_CFLAGS) AC_SUBST(dbus_LIBS) DBUS_API_STABLE_VERSION=1.0.0 -PKG_CHECK_EXISTS(dbus-1 < $DBUS_API_STABLE_VERSION, - AC_DEFINE(DBUS_API_SUBJECT_TO_CHANGE, , [unstable DBus]) +PKG_CHECK_EXISTS([dbus-1 < $DBUS_API_STABLE_VERSION], + [AC_DEFINE(DBUS_API_SUBJECT_TO_CHANGE, , [unstable DBus])] +) + +DBUS_THREADS_INIT_DEFAULT_VERSION=0.93 +PKG_CHECK_EXISTS([dbus-1 >= $DBUS_THREADS_INIT_DEFAULT_VERSION], + [AC_DEFINE(DBUS_HAS_THREADS_INIT_DEFAULT, , [dbus_threads_init_default (needs DBus >= 0.93)])] ) DBUS_RECURSIVE_MUTEX_VERSION=0.95 -PKG_CHECK_EXISTS(dbus-1 >= $DBUS_RECURSIVE_MUTEX_VERSION, - AC_DEFINE(DBUS_HAS_RECURSIVE_MUTEX, , [DBus supports recursive mutexes (needs DBus >= 0.95)]) +PKG_CHECK_EXISTS([dbus-1 >= $DBUS_RECURSIVE_MUTEX_VERSION], + [AC_DEFINE(DBUS_HAS_RECURSIVE_MUTEX, , [DBus supports recursive mutexes (needs DBus >= 0.95)])] ) -if test x$enable_glib = xyes ; then + +if test "$enable_glib" = "yes" ; then PKG_CHECK_MODULES([glib], glib-2.0) AC_SUBST(glib_CFLAGS) AC_SUBST(glib_LIBS) @@ -99,12 +122,12 @@ AC_CHECK_LIB([pthread], pthread_create, [AC_CHECK_HEADERS(pthread.h, have_pthread=true, have_pthread=false)], have_pthread=false) -AM_CONDITIONAL(HAVE_PTHREAD, test x$have_pthread = xtrue) +AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "true") -if test x$enable_debug = xyes ; then - CXXFLAGS="-Wall -ggdb -O0 -DDEBUG" +if test "$enable_debug" = "yes" ; then + CXXFLAGS="$CXXFLAGS -Wall -ggdb -O0 -DDEBUG" else - CXXFLAGS="-Wall -O3" + CXXFLAGS="$CXXFLAGS -Wall -O3" fi @@ -114,35 +137,37 @@ AC_PATH_PROG(DOXYGEN, doxygen, no) AC_MSG_CHECKING([whether to build Doxygen documentation]) -if test x$DOXYGEN = xno ; then - have_doxygen=no +if test "$DOXYGEN" = "no" ; then + have_doxygen=no else - have_doxygen=yes + have_doxygen=yes fi -if test x$enable_doxygen_docs = xauto ; then - enable_doxygen_docs=no +if test "$enable_doxygen_docs" = "auto" ; then + enable_doxygen_docs=no + + AC_MSG_RESULT(no) fi -if test x$enable_doxygen_docs = xyes ; then - if test x$have_doxygen = xno; then - AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found]) - fi +if test "$enable_doxygen_docs" = "yes" ; then + if test "$have_doxygen" = "no"; then + AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found]) + fi + + AC_MSG_RESULT(yes) fi -AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test x$enable_doxygen_docs = xyes) -AC_MSG_RESULT(yes) - +AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test "$enable_doxygen_docs" = "yes") # For the tools/, we need libdbus-c++ for the "build" architecture as well -AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes) +AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = "yes") AC_ARG_WITH(build-libdbus-cxx, - AS_HELP_STRING([--with-build-libdbus-cxx],[For cross compilation: path to - libdbus-cxx which was compiled for the 'build' system.]), - [ BUILD_LIBDBUS_CXX_DIR=${withval} ], - [ BUILD_LIBDBUS_CXX_DIR="\$(top_builddir)" ] + AS_HELP_STRING([--with-build-libdbus-cxx], + [For cross compilation: path to libdbus-cxx which was compiled for the 'build' system.]), + [ BUILD_LIBDBUS_CXX_DIR=${withval} ], + [ BUILD_LIBDBUS_CXX_DIR="\$(top_builddir)" ] ) AC_SUBST(BUILD_LIBDBUS_CXX_DIR) diff --git a/examples/echo/echo-client.cpp b/examples/echo/echo-client.cpp index a242294..429e61c 100644 --- a/examples/echo/echo-client.cpp +++ b/examples/echo/echo-client.cpp @@ -3,6 +3,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + using namespace std; static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo"; @@ -58,7 +62,11 @@ int main() signal(SIGTERM, niam); signal(SIGINT, niam); +#ifdef DBUS_HAS_THREADS_INIT_DEFAULT DBus::_init_threading(); +#else + cerr << "Thread support is not enabled! your D-Bus version is too old" << endl; +#endif DBus::default_dispatcher = &dispatcher; diff --git a/include/dbus-c++/api.h b/include/dbus-c++/api.h new file mode 100644 index 0000000..c874956 --- /dev/null +++ b/include/dbus-c++/api.h @@ -0,0 +1,42 @@ +/* + * + * D-Bus++ - C++ bindings for D-Bus + * + * Copyright (C) 2005-2007 Paolo Durante + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + +#ifndef __DBUSXX_API_H +#define __DBUSXX_API_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef GCC_HASCLASSVISIBILITY +# define DXXAPILOCAL __attribute__ ((visibility("hidden"))) +# define DXXAPIPUBLIC __attribute__ ((visibility("default"))) +#else +# define DXXAPILOCAL +# define DXXAPIPUBLIC +#endif + +#define DXXAPI DXXAPIPUBLIC + +#endif//__DBUSXX_API_H diff --git a/include/dbus-c++/config.h.in b/include/dbus-c++/config.h.in index e02365b..f803e5d 100644 --- a/include/dbus-c++/config.h.in +++ b/include/dbus-c++/config.h.in @@ -6,6 +6,12 @@ /* DBus supports recursive mutexes (needs DBus >= 0.95) */ #undef DBUS_HAS_RECURSIVE_MUTEX +/* dbus_threads_init_default (needs DBus >= 0.93) */ +#undef DBUS_HAS_THREADS_INIT_DEFAULT + +/* to enable hidden symbols */ +#undef GCC_HASCLASSVISIBILITY + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H diff --git a/include/dbus-c++/connection.h b/include/dbus-c++/connection.h index 028ab85..5a52722 100644 --- a/include/dbus-c++/connection.h +++ b/include/dbus-c++/connection.h @@ -31,6 +31,7 @@ #include +#include "api.h" #include "types.h" #include "util.h" #include "message.h" @@ -47,7 +48,7 @@ typedef std::list ConnectionList; class ObjectAdaptor; class Dispatcher; -class Connection +class DXXAPI Connection { public: @@ -111,7 +112,7 @@ public: private: - void init(); + DXXAPILOCAL void init(); private: diff --git a/include/dbus-c++/dbus.h b/include/dbus-c++/dbus.h index 5c03b16..d8d7fa2 100644 --- a/include/dbus-c++/dbus.h +++ b/include/dbus-c++/dbus.h @@ -43,7 +43,6 @@ #include "util.h" #include "dispatcher.h" #include "eventloop.h" -#include "xml.h" #include "introspection.h" #endif//__DBUSXX_DBUS_H diff --git a/include/dbus-c++/debug.h b/include/dbus-c++/debug.h index fcc3e73..457ea5a 100644 --- a/include/dbus-c++/debug.h +++ b/include/dbus-c++/debug.h @@ -29,11 +29,13 @@ #include "config.h" #endif +#include "api.h" + namespace DBus { typedef void (*LogFunction)(const char* format, ...); -extern LogFunction debug_log; +extern DXXAPI LogFunction debug_log; } /* namespace DBus */ diff --git a/include/dbus-c++/dispatcher.h b/include/dbus-c++/dispatcher.h index a613735..8cce2d1 100644 --- a/include/dbus-c++/dispatcher.h +++ b/include/dbus-c++/dispatcher.h @@ -29,11 +29,12 @@ #include "config.h" #endif +#include "api.h" #include "connection.h" namespace DBus { -class Timeout +class DXXAPI Timeout { public: @@ -53,14 +54,14 @@ public: private: - Timeout( const Timeout& ); + DXXAPILOCAL Timeout( const Timeout& ); private: Internal* _int; }; -class Watch +class DXXAPI Watch { public: @@ -82,14 +83,14 @@ public: private: - Watch( const Watch& ); + DXXAPILOCAL Watch( const Watch& ); private: Internal* _int; }; -class Dispatcher +class DXXAPI Dispatcher { public: @@ -119,12 +120,12 @@ private: Connection::PrivatePList _pending_queue; }; -extern Dispatcher* default_dispatcher; +extern DXXAPI Dispatcher* default_dispatcher; /* classes for multithreading support */ -class Mutex +class DXXAPI Mutex { public: @@ -141,7 +142,7 @@ protected: Internal* _int; }; -class CondVar +class DXXAPI CondVar { public: @@ -181,9 +182,11 @@ typedef bool (*CondVarWaitTimeoutFn)( CondVar* cv, Mutex* mx, int timeout ); typedef void (*CondVarWakeOneFn)( CondVar* cv ); typedef void (*CondVarWakeAllFn)( CondVar* cv ); -void _init_threading(); +#ifdef DBUS_HAS_THREADS_INIT_DEFAULT +void DXXAPI _init_threading(); +#endif//DBUS_HAS_THREADS_INIT_DEFAULT -void _init_threading( +void DXXAPI _init_threading( MutexNewFn, MutexFreeFn, MutexLockFn, MutexUnlockFn, CondVarNewFn, CondVarFreeFn, CondVarWaitFn, CondVarWaitTimeoutFn, CondVarWakeOneFn, CondVarWakeAllFn ); diff --git a/include/dbus-c++/error.h b/include/dbus-c++/error.h index 023e36a..d30d7c2 100644 --- a/include/dbus-c++/error.h +++ b/include/dbus-c++/error.h @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "api.h" #include "util.h" #include @@ -38,7 +39,7 @@ namespace DBus { class Message; class InternalError; -class Error : public std::exception +class DXXAPI Error : public std::exception { public: @@ -50,8 +51,7 @@ public: Error( Message& ); - ~Error() throw() - {} + ~Error() throw(); const char* what() const throw(); @@ -74,210 +74,210 @@ private: RefPtrI _int; }; -struct ErrorFailed : public Error +struct DXXAPI ErrorFailed : public Error { ErrorFailed( const char* message ) : Error("org.freedesktop.DBus.Error.Failed", message) {} }; -struct ErrorNoMemory : public Error +struct DXXAPI ErrorNoMemory : public Error { ErrorNoMemory( const char* message ) : Error("org.freedesktop.DBus.Error.NoMemory", message) {} }; -struct ErrorServiceUnknown : public Error +struct DXXAPI ErrorServiceUnknown : public Error { ErrorServiceUnknown( const char* message ) : Error("org.freedesktop.DBus.Error.ServiceUnknown", message) {} }; -struct ErrorNameHasNoOwner : public Error +struct DXXAPI ErrorNameHasNoOwner : public Error { ErrorNameHasNoOwner( const char* message ) : Error("org.freedesktop.DBus.Error.NameHasNoOwner", message) {} }; -struct ErrorNoReply : public Error +struct DXXAPI ErrorNoReply : public Error { ErrorNoReply( const char* message ) : Error("org.freedesktop.DBus.Error.NoReply", message) {} }; -struct ErrorIOError : public Error +struct DXXAPI ErrorIOError : public Error { ErrorIOError( const char* message ) : Error("org.freedesktop.DBus.Error.IOError", message) {} }; -struct ErrorBadAddress : public Error +struct DXXAPI ErrorBadAddress : public Error { ErrorBadAddress( const char* message ) : Error("org.freedesktop.DBus.Error.BadAddress", message) {} }; -struct ErrorNotSupported : public Error +struct DXXAPI ErrorNotSupported : public Error { ErrorNotSupported( const char* message ) : Error("org.freedesktop.DBus.Error.NotSupported", message) {} }; -struct ErrorLimitsExceeded : public Error +struct DXXAPI ErrorLimitsExceeded : public Error { ErrorLimitsExceeded( const char* message ) : Error("org.freedesktop.DBus.Error.LimitsExceeded", message) {} }; -struct ErrorAccessDenied : public Error +struct DXXAPI ErrorAccessDenied : public Error { ErrorAccessDenied( const char* message ) : Error("org.freedesktop.DBus.Error.AccessDenied", message) {} }; -struct ErrorAuthFailed : public Error +struct DXXAPI ErrorAuthFailed : public Error { ErrorAuthFailed( const char* message ) : Error("org.freedesktop.DBus.Error.AuthFailed", message) {} }; -struct ErrorNoServer : public Error +struct DXXAPI ErrorNoServer : public Error { ErrorNoServer( const char* message ) : Error("org.freedesktop.DBus.Error.NoServer", message) {} }; -struct ErrorTimeout : public Error +struct DXXAPI ErrorTimeout : public Error { ErrorTimeout( const char* message ) : Error("org.freedesktop.DBus.Error.Timeout", message) {} }; -struct ErrorNoNetwork : public Error +struct DXXAPI ErrorNoNetwork : public Error { ErrorNoNetwork( const char* message ) : Error("org.freedesktop.DBus.Error.NoNetwork", message) {} }; -struct ErrorAddressInUse : public Error +struct DXXAPI ErrorAddressInUse : public Error { ErrorAddressInUse( const char* message ) : Error("org.freedesktop.DBus.Error.AddressInUse", message) {} }; -struct ErrorDisconnected : public Error +struct DXXAPI ErrorDisconnected : public Error { ErrorDisconnected( const char* message ) : Error("org.freedesktop.DBus.Error.Disconnected", message) {} }; -struct ErrorInvalidArgs : public Error +struct DXXAPI ErrorInvalidArgs : public Error { ErrorInvalidArgs( const char* message ) : Error("org.freedesktop.DBus.Error.InvalidArgs", message) {} }; -struct ErrorFileNotFound : public Error +struct DXXAPI ErrorFileNotFound : public Error { ErrorFileNotFound( const char* message ) : Error("org.freedesktop.DBus.Error.FileNotFound", message) {} }; -struct ErrorUnknownMethod : public Error +struct DXXAPI ErrorUnknownMethod : public Error { ErrorUnknownMethod( const char* message ) : Error("org.freedesktop.DBus.Error.UnknownMethod", message) {} }; -struct ErrorTimedOut : public Error +struct DXXAPI ErrorTimedOut : public Error { ErrorTimedOut( const char* message ) : Error("org.freedesktop.DBus.Error.TimedOut", message) {} }; -struct ErrorMatchRuleNotFound : public Error +struct DXXAPI ErrorMatchRuleNotFound : public Error { ErrorMatchRuleNotFound( const char* message ) : Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message) {} }; -struct ErrorMatchRuleInvalid : public Error +struct DXXAPI ErrorMatchRuleInvalid : public Error { ErrorMatchRuleInvalid( const char* message ) : Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message) {} }; -struct ErrorSpawnExecFailed : public Error +struct DXXAPI ErrorSpawnExecFailed : public Error { ErrorSpawnExecFailed( const char* message ) : Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message) {} }; -struct ErrorSpawnForkFailed : public Error +struct DXXAPI ErrorSpawnForkFailed : public Error { ErrorSpawnForkFailed( const char* message ) : Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message) {} }; -struct ErrorSpawnChildExited : public Error +struct DXXAPI ErrorSpawnChildExited : public Error { ErrorSpawnChildExited( const char* message ) : Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message) {} }; -struct ErrorSpawnChildSignaled : public Error +struct DXXAPI ErrorSpawnChildSignaled : public Error { ErrorSpawnChildSignaled( const char* message ) : Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message) {} }; -struct ErrorSpawnFailed : public Error +struct DXXAPI ErrorSpawnFailed : public Error { ErrorSpawnFailed( const char* message ) : Error("org.freedesktop.DBus.Error.Spawn.Failed", message) {} }; -struct ErrorInvalidSignature : public Error +struct DXXAPI ErrorInvalidSignature : public Error { ErrorInvalidSignature( const char* message ) : Error("org.freedesktop.DBus.Error.InvalidSignature", message) {} }; -struct ErrorUnixProcessIdUnknown : public Error +struct DXXAPI ErrorUnixProcessIdUnknown : public Error { ErrorUnixProcessIdUnknown( const char* message ) : Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message) {} }; -struct ErrorSELinuxSecurityContextUnknown : public Error +struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error { ErrorSELinuxSecurityContextUnknown( const char* message ) : Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message) diff --git a/include/dbus-c++/eventloop.h b/include/dbus-c++/eventloop.h index 016dd86..932479c 100644 --- a/include/dbus-c++/eventloop.h +++ b/include/dbus-c++/eventloop.h @@ -31,6 +31,7 @@ #include +#include "api.h" #include "dispatcher.h" #include "util.h" @@ -38,7 +39,7 @@ namespace DBus { class EepleMainLoop; -class EepleTimeout +class DXXAPI EepleTimeout { public: @@ -78,7 +79,7 @@ friend class EepleMainLoop; typedef std::list< EepleTimeout* > Timeouts; -class EepleWatch +class DXXAPI EepleWatch { public: @@ -118,7 +119,7 @@ friend class EepleMainLoop; typedef std::list< EepleWatch* > Watches; -class EepleMainLoop +class DXXAPI EepleMainLoop { public: @@ -145,7 +146,7 @@ friend class EepleWatch; class BusDispatcher; -class BusTimeout : public Timeout, public EepleTimeout +class DXXAPI BusTimeout : public Timeout, public EepleTimeout { BusTimeout( Timeout::Internal*, BusDispatcher* ); @@ -154,7 +155,7 @@ class BusTimeout : public Timeout, public EepleTimeout friend class BusDispatcher; }; -class BusWatch : public Watch, public EepleWatch +class DXXAPI BusWatch : public Watch, public EepleWatch { BusWatch( Watch::Internal*, BusDispatcher* ); @@ -163,7 +164,7 @@ class BusWatch : public Watch, public EepleWatch friend class BusDispatcher; }; -class BusDispatcher : public Dispatcher, public EepleMainLoop +class DXXAPI BusDispatcher : public Dispatcher, public EepleMainLoop { public: diff --git a/include/dbus-c++/glib-integration.h b/include/dbus-c++/glib-integration.h index a78d7ec..723c7d8 100644 --- a/include/dbus-c++/glib-integration.h +++ b/include/dbus-c++/glib-integration.h @@ -31,6 +31,7 @@ #include +#include "api.h" #include "eventloop.h" namespace DBus { @@ -39,7 +40,7 @@ namespace Glib { class BusDispatcher; -class BusTimeout : public Timeout +class DXXAPI BusTimeout : public Timeout { private: @@ -63,7 +64,7 @@ private: friend class BusDispatcher; }; -class BusWatch : public Watch +class DXXAPI BusWatch : public Watch { private: @@ -87,7 +88,7 @@ private: friend class BusDispatcher; }; -class BusDispatcher : public Dispatcher +class DXXAPI BusDispatcher : public Dispatcher { public: BusDispatcher() : _ctx(NULL) {} diff --git a/include/dbus-c++/interface.h b/include/dbus-c++/interface.h index 90c398d..a59785a 100644 --- a/include/dbus-c++/interface.h +++ b/include/dbus-c++/interface.h @@ -31,6 +31,7 @@ #include #include +#include "api.h" #include "util.h" #include "types.h" @@ -39,7 +40,7 @@ namespace DBus { //todo: this should belong to to properties.h -struct PropertyData +struct DXXAPI PropertyData { bool read; bool write; @@ -57,7 +58,7 @@ class SignalMessage; typedef std::map InterfaceAdaptorTable; -class AdaptorBase +class DXXAPI AdaptorBase { public: @@ -84,7 +85,7 @@ class CallMessage; typedef std::map InterfaceProxyTable; -class ProxyBase +class DXXAPI ProxyBase { public: @@ -102,7 +103,7 @@ protected: InterfaceProxyTable _interfaces; }; -class Interface +class DXXAPI Interface { public: @@ -130,7 +131,7 @@ const std::string& Interface::name() const typedef std::map< std::string, Slot > MethodTable; -class InterfaceAdaptor : public Interface, public virtual AdaptorBase +class DXXAPI InterfaceAdaptor : public Interface, public virtual AdaptorBase { public: @@ -160,7 +161,7 @@ protected: typedef std::map< std::string, Slot > SignalTable; -class InterfaceProxy : public Interface, public virtual ProxyBase +class DXXAPI InterfaceProxy : public Interface, public virtual ProxyBase { public: diff --git a/include/dbus-c++/introspection.h b/include/dbus-c++/introspection.h index a6d7ebf..00a33b0 100644 --- a/include/dbus-c++/introspection.h +++ b/include/dbus-c++/introspection.h @@ -29,24 +29,25 @@ #include "config.h" #endif +#include "api.h" #include "interface.h" namespace DBus { -struct IntrospectedArgument +struct DXXAPI IntrospectedArgument { const char* name; const char* type; const bool in; }; -struct IntrospectedMethod +struct DXXAPI IntrospectedMethod { const char* name; const IntrospectedArgument* args; }; -struct IntrospectedProperty +struct DXXAPI IntrospectedProperty { const char* name; const char* type; @@ -54,7 +55,7 @@ struct IntrospectedProperty const bool write; }; -struct IntrospectedInterface +struct DXXAPI IntrospectedInterface { const char* name; const IntrospectedMethod* methods; @@ -62,7 +63,7 @@ struct IntrospectedInterface const IntrospectedProperty* properties; }; -class IntrospectableAdaptor : public InterfaceAdaptor +class DXXAPI IntrospectableAdaptor : public InterfaceAdaptor { public: @@ -75,7 +76,7 @@ protected: IntrospectedInterface* const introspect() const; }; -class IntrospectableProxy : public InterfaceProxy +class DXXAPI IntrospectableProxy : public InterfaceProxy { public: diff --git a/include/dbus-c++/message.h b/include/dbus-c++/message.h index 158e58a..2d132bb 100644 --- a/include/dbus-c++/message.h +++ b/include/dbus-c++/message.h @@ -32,6 +32,7 @@ #include #include +#include "api.h" #include "util.h" namespace DBus { @@ -43,7 +44,7 @@ class ReturnMessage; class Error; class Connection; -class MessageIter +class DXXAPI MessageIter { public: @@ -140,11 +141,11 @@ public: private: - MessageIter(Message& msg) : _msg(&msg) {} + DXXAPILOCAL MessageIter(Message& msg) : _msg(&msg) {} - bool append_basic( int type_id, void* value ); + DXXAPILOCAL bool append_basic( int type_id, void* value ); - void get_basic( int type_id, void* ptr ); + DXXAPILOCAL void get_basic( int type_id, void* ptr ); private: @@ -157,7 +158,7 @@ private: friend class Message; }; -class Message +class DXXAPI Message { public: @@ -221,7 +222,7 @@ friend class Connection; /* */ -class ErrorMessage : public Message +class DXXAPI ErrorMessage : public Message { public: @@ -239,7 +240,7 @@ public: /* */ -class SignalMessage : public Message +class DXXAPI SignalMessage : public Message { public: @@ -267,7 +268,7 @@ public: /* */ -class CallMessage : public Message +class DXXAPI CallMessage : public Message { public: @@ -297,7 +298,7 @@ public: /* */ -class ReturnMessage : public Message +class DXXAPI ReturnMessage : public Message { public: diff --git a/include/dbus-c++/object.h b/include/dbus-c++/object.h index 65bbcf0..7c3240b 100644 --- a/include/dbus-c++/object.h +++ b/include/dbus-c++/object.h @@ -32,6 +32,7 @@ #include #include +#include "api.h" #include "interface.h" #include "connection.h" #include "message.h" @@ -39,7 +40,7 @@ namespace DBus { -class Object +class DXXAPI Object { protected: @@ -57,9 +58,9 @@ public: private: - virtual bool handle_message( const Message& ) = 0; - virtual void register_obj() = 0; - virtual void unregister_obj() = 0; + DXXAPILOCAL virtual bool handle_message( const Message& ) = 0; + DXXAPILOCAL virtual void register_obj() = 0; + DXXAPILOCAL virtual void unregister_obj() = 0; private: @@ -89,7 +90,7 @@ const std::string& Object::service() const /* */ -class Tag +class DXXAPI Tag { public: @@ -104,7 +105,7 @@ class ObjectAdaptor; typedef std::list ObjectAdaptorPList; -class ObjectAdaptor : public Object, public virtual AdaptorBase +class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase { public: @@ -122,7 +123,7 @@ public: protected: - class Continuation + class DXXAPI Continuation { public: @@ -188,7 +189,7 @@ class ObjectProxy; typedef std::list ObjectProxyPList; -class ObjectProxy : public Object, public virtual ProxyBase +class DXXAPI ObjectProxy : public Object, public virtual ProxyBase { public: diff --git a/include/dbus-c++/pendingcall.h b/include/dbus-c++/pendingcall.h index 1b7ccbc..4b9abc6 100644 --- a/include/dbus-c++/pendingcall.h +++ b/include/dbus-c++/pendingcall.h @@ -29,13 +29,14 @@ #include "config.h" #endif +#include "api.h" #include "util.h" namespace DBus { class Connection; -class PendingCall +class DXXAPI PendingCall { public: @@ -59,7 +60,7 @@ public: private: - PendingCall( const PendingCall& ); + DXXAPILOCAL PendingCall( const PendingCall& ); private: diff --git a/include/dbus-c++/property.h b/include/dbus-c++/property.h index f0b4670..28e1846 100644 --- a/include/dbus-c++/property.h +++ b/include/dbus-c++/property.h @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "api.h" #include "types.h" #include "interface.h" @@ -67,7 +68,7 @@ private: struct IntrospectedInterface; -class PropertiesAdaptor : public InterfaceAdaptor +class DXXAPI PropertiesAdaptor : public InterfaceAdaptor { public: @@ -88,7 +89,7 @@ protected: IntrospectedInterface* const introspect() const; }; -class PropertiesProxy : public InterfaceProxy +class DXXAPI PropertiesProxy : public InterfaceProxy { public: diff --git a/include/dbus-c++/refptr_impl.h b/include/dbus-c++/refptr_impl.h index 1f78a24..bf42f40 100644 --- a/include/dbus-c++/refptr_impl.h +++ b/include/dbus-c++/refptr_impl.h @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "api.h" #include "util.h" namespace DBus { diff --git a/include/dbus-c++/server.h b/include/dbus-c++/server.h index 8e858e0..4597610 100644 --- a/include/dbus-c++/server.h +++ b/include/dbus-c++/server.h @@ -31,6 +31,7 @@ #include +#include "api.h" #include "error.h" #include "connection.h" #include "util.h" @@ -42,7 +43,7 @@ class Server; typedef std::list ServerList; -class Server +class DXXAPI Server { public: diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h index ed81726..f90f980 100644 --- a/include/dbus-c++/types.h +++ b/include/dbus-c++/types.h @@ -33,6 +33,7 @@ #include #include +#include "api.h" #include "util.h" #include "message.h" #include "error.h" @@ -50,7 +51,7 @@ typedef unsigned long long UInt64; typedef double Double; typedef std::string String; -struct Path : public std::string +struct DXXAPI Path : public std::string { Path() {} Path( const std::string& s ) : std::string(s) {} @@ -62,7 +63,7 @@ struct Path : public std::string } }; -struct Signature : public std::string +struct DXXAPI Signature : public std::string { Signature() {} Signature( const std::string& s ) : std::string(s) {} @@ -74,9 +75,9 @@ struct Signature : public std::string } }; -struct Invalid {}; +struct DXXAPI Invalid {}; -class Variant +class DXXAPI Variant { public: @@ -344,7 +345,7 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Str return iter; } -DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Variant& val ); +extern DXXAPI DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Variant& val ); /* */ @@ -507,7 +508,7 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Struct> ( DBus::MessageIter& iter, DBus::Variant& val ); +extern DXXAPI DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Variant& val ); #endif//__DBUSXX_TYPES_H diff --git a/include/dbus-c++/util.h b/include/dbus-c++/util.h index a8ac23c..a22f267 100644 --- a/include/dbus-c++/util.h +++ b/include/dbus-c++/util.h @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "api.h" #include "debug.h" namespace DBus { @@ -37,7 +38,7 @@ namespace DBus { * Very simple reference counting */ -class RefCnt +class DXXAPI RefCnt { public: @@ -78,11 +79,11 @@ public: private: - void ref() const + DXXAPILOCAL void ref() const { ++ (*__ref); } - void unref() const + DXXAPILOCAL void unref() const { -- (*__ref); diff --git a/src/Makefile.am b/src/Makefile.am index aa850b2..f7e5617 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,5 @@ AM_CPPFLAGS = \ $(dbus_CFLAGS) \ - $(xml_CFLAGS) \ $(glib_CFLAGS) \ -I$(top_srcdir)/include @@ -28,16 +27,16 @@ HEADER_FILES = \ $(HEADER_DIR)/debug.h \ $(HEADER_DIR)/util.h \ $(HEADER_DIR)/refptr_impl.h \ - $(HEADER_DIR)/xml.h \ $(HEADER_DIR)/introspection.h \ + $(HEADER_DIR)/api.h \ $(GLIB_H) lib_includedir=$(includedir)/dbus-c++-1/dbus-c++/ lib_include_HEADERS = $(HEADER_FILES) lib_LTLIBRARIES = libdbus-c++-1.la -libdbus_c___1_la_SOURCES = $(HEADER_FILES) interface.cpp object.cpp introspection.cpp debug.cpp eventloop.cpp xml.cpp types.cpp connection.cpp connection_p.h property.cpp dispatcher.cpp dispatcher_p.h pendingcall.cpp pendingcall_p.h error.cpp internalerror.h message.cpp message_p.h server.cpp server_p.h $(GLIB_CPP) -libdbus_c___1_la_LIBADD = $(dbus_LIBS) $(xml_LIBS) $(glib_LIBS) +libdbus_c___1_la_SOURCES = $(HEADER_FILES) interface.cpp object.cpp introspection.cpp debug.cpp eventloop.cpp types.cpp connection.cpp connection_p.h property.cpp dispatcher.cpp dispatcher_p.h pendingcall.cpp pendingcall_p.h error.cpp internalerror.h message.cpp message_p.h server.cpp server_p.h $(GLIB_CPP) +libdbus_c___1_la_LIBADD = $(dbus_LIBS) $(glib_LIBS) MAINTAINERCLEANFILES = \ Makefile.in diff --git a/src/connection_p.h b/src/connection_p.h index 9a1d489..eec96e3 100644 --- a/src/connection_p.h +++ b/src/connection_p.h @@ -40,7 +40,7 @@ namespace DBus { -struct Connection::Private +struct DXXAPILOCAL Connection::Private { DBusConnection* conn; diff --git a/src/debug.cpp b/src/debug.cpp index b2fe8fe..ee4f459 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -28,12 +28,12 @@ #include #include -static int debug_env = -1; - static void _debug_log_default(const char* format, ...) { #ifdef DEBUG + static int debug_env = -1; + if(debug_env < 0) debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0; if(debug_env) diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp index f0f5293..23c92c8 100644 --- a/src/dispatcher.cpp +++ b/src/dispatcher.cpp @@ -168,10 +168,12 @@ void Dispatcher::dispatch_pending() } } +#ifdef DBUS_HAS_THREADS_INIT_DEFAULT void DBus::_init_threading() { dbus_threads_init_default(); } +#endif//DBUS_HAS_THREADS_INIT_DEFAULT void DBus::_init_threading( MutexNewFn m1, diff --git a/src/dispatcher_p.h b/src/dispatcher_p.h index 97e2e36..be2dea7 100644 --- a/src/dispatcher_p.h +++ b/src/dispatcher_p.h @@ -37,7 +37,7 @@ namespace DBus { -struct Dispatcher::Private +struct DXXAPILOCAL Dispatcher::Private { static dbus_bool_t on_add_watch( DBusWatch* watch, void* data ); diff --git a/src/error.cpp b/src/error.cpp index db7bfdb..9225117 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -55,6 +55,10 @@ Error::Error( Message& m ) dbus_set_error_from_message(&(_int->error), m._pvt->msg); } +Error::~Error() throw() +{ +} + const char* Error::name() const { return _int->error.name; diff --git a/src/internalerror.h b/src/internalerror.h index 9285f55..0f287e1 100644 --- a/src/internalerror.h +++ b/src/internalerror.h @@ -35,7 +35,7 @@ namespace DBus { -struct InternalError +struct DXXAPI InternalError { DBusError error; diff --git a/src/introspection.cpp b/src/introspection.cpp index 093bf4f..7fc7b38 100644 --- a/src/introspection.cpp +++ b/src/introspection.cpp @@ -25,10 +25,11 @@ #include #include #include -#include #include +#include + using namespace DBus; static const char* introspectable_name = "org.freedesktop.DBus.Introspectable"; @@ -42,8 +43,14 @@ IntrospectableAdaptor::IntrospectableAdaptor() Message IntrospectableAdaptor::Introspect( const CallMessage& call ) { debug_log("requested introspection data"); - - Xml::Node iroot("node"); + + std::ostringstream xml; + + xml << DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE; + + const std::string path = object()->path(); + + xml << ""; InterfaceAdaptorTable::const_iterator iti; @@ -54,71 +61,72 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call ) IntrospectedInterface* const intro = iti->second->introspect(); if(intro) { - Xml::Node& iface = iroot.add(Xml::Node("interface")); - iface.set("name", intro->name); + xml << "name << "\">"; for(const IntrospectedProperty* p = intro->properties; p->name; ++p) { - Xml::Node& property = iface.add(Xml::Node("property")); - property.set("name", p->name); - property.set("type", p->type); - std::string access; if(p->read) access += "read"; if(p->write) access += "write"; - property.set("access", access); + xml << "name << "\"" + << " type=\"" << p->type << "\"" + << " access=\"" << access << "\"/>"; } for(const IntrospectedMethod* m = intro->methods; m->args; ++m) { - Xml::Node& method = iface.add(Xml::Node("method")); - method.set("name", m->name); + xml << "name << "\">"; for(const IntrospectedArgument* a = m->args; a->type; ++a) { - Xml::Node& arg = method.add(Xml::Node("arg")); - if(a->name) arg.set("name", a->name); - arg.set("direction", a->in ? "in" : "out"); - arg.set("type", a->type); + xml << "in ? "in" : "out") << "\"" + << " type=\"" << a->type << "\""; + + if(a->name) xml << " name=\"" << a->name << "\""; + + xml << "/>"; } + + xml << ""; } for(const IntrospectedMethod* m = intro->signals; m->args; ++m) { - Xml::Node& method = iface.add(Xml::Node("signal")); - method.set("name", m->name); + xml << "name << "\">"; for(const IntrospectedArgument* a = m->args; a->type; ++a) { - Xml::Node& arg = method.add(Xml::Node("arg")); - if(a->name) arg.set("name", a->name); - arg.set("type", a->type); + xml << "type << "\""; + + if(a->name) xml << " name=\"" << a->name << "\""; + + xml << "/>"; } + xml << ""; } + + xml << ""; } } - const std::string parent = object()->path(); - const ObjectAdaptorPList children = ObjectAdaptor::from_path_prefix(parent + '/'); + const ObjectAdaptorPList children = ObjectAdaptor::from_path_prefix(path + '/'); ObjectAdaptorPList::const_iterator oci; for(oci = children.begin(); oci != children.end(); ++oci) { - Xml::Node& subnode = iroot.add(Xml::Node("node")); - - std::string name = (*oci)->path().substr(parent.length()+1); + std::string name = (*oci)->path().substr(path.length()+1); name.substr(name.find('/')); - subnode.set("name", name); + xml << ""; } - std::string xml = DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE + iroot.to_xml(); + xml << ""; ReturnMessage reply(call); MessageIter wi = reply.writer(); - wi.append_string(xml.c_str()); + wi.append_string(xml.str().c_str()); return reply; } diff --git a/src/message_p.h b/src/message_p.h index 406ee6a..c080d01 100644 --- a/src/message_p.h +++ b/src/message_p.h @@ -36,7 +36,7 @@ namespace DBus { -struct Message::Private +struct DXXAPILOCAL Message::Private { DBusMessage* msg; diff --git a/src/pendingcall_p.h b/src/pendingcall_p.h index 2f65f11..6f132db 100644 --- a/src/pendingcall_p.h +++ b/src/pendingcall_p.h @@ -36,7 +36,7 @@ namespace DBus { -struct PendingCall::Private +struct DXXAPILOCAL PendingCall::Private { DBusPendingCall* call; int dataslot; diff --git a/src/server_p.h b/src/server_p.h index c6c050b..7eb4608 100644 --- a/src/server_p.h +++ b/src/server_p.h @@ -37,7 +37,7 @@ namespace DBus { -struct Server::Private +struct DXXAPILOCAL Server::Private { DBusServer* server; diff --git a/tools/Makefile.am b/tools/Makefile.am index c512098..c1904cb 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,6 +4,7 @@ CXX = $(CXX_FOR_BUILD) AM_CPPFLAGS = \ $(dbus_CFLAGS) \ + $(xml_CFLAGS) \ -I$(top_srcdir)/include if CROSS_COMPILING @@ -14,7 +15,7 @@ endif bin_PROGRAMS = dbusxx-xml2cpp dbusxx-introspect -dbusxx_xml2cpp_SOURCES = xml2cpp.h xml2cpp.cpp +dbusxx_xml2cpp_SOURCES = xml.h xml.cpp xml2cpp.h xml2cpp.cpp dbusxx_xml2cpp_LDADD = $(libdbus_cxx_la) dbusxx_introspect_SOURCES = introspect.h introspect.cpp diff --git a/src/xml.cpp b/tools/xml.cpp similarity index 99% rename from src/xml.cpp rename to tools/xml.cpp index 5a073a8..69b403e 100644 --- a/src/xml.cpp +++ b/tools/xml.cpp @@ -22,7 +22,8 @@ */ -#include +#include "xml.h" + #include #include diff --git a/include/dbus-c++/xml.h b/tools/xml.h similarity index 100% rename from include/dbus-c++/xml.h rename to tools/xml.h diff --git a/tools/xml2cpp.h b/tools/xml2cpp.h index e385edb..84f53fe 100644 --- a/tools/xml2cpp.h +++ b/tools/xml2cpp.h @@ -32,4 +32,6 @@ #include #include +#include "xml.h" + #endif//__DBUSXX_TOOLS_XML2CPP_H