From a07b97b3abe235ad8a98fb6577b9721cb36d8721 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Thu, 30 May 2013 20:30:28 +0300 Subject: Rename signal.h to qglib_signal.h to avoid it being used instead of the system's signal.h This is a problem that appears on windows builds --- src/QGlib/CMakeLists.txt | 2 +- src/QGlib/Signal | 2 +- src/QGlib/gen.cpp | 2 +- src/QGlib/qglib_signal.h | 182 ++++++++++++++++++++++++++++++++++++ src/QGlib/signal.cpp | 2 +- src/QGlib/signal.h | 182 ------------------------------------ src/QGst/Ui/graphicsvideowidget.cpp | 2 +- src/QGst/Ui/videowidget.cpp | 2 +- src/QGst/bus.cpp | 2 +- 9 files changed, 189 insertions(+), 189 deletions(-) create mode 100644 src/QGlib/qglib_signal.h delete mode 100644 src/QGlib/signal.h diff --git a/src/QGlib/CMakeLists.txt b/src/QGlib/CMakeLists.txt index 71850b1..5ee1809 100644 --- a/src/QGlib/CMakeLists.txt +++ b/src/QGlib/CMakeLists.txt @@ -22,7 +22,7 @@ set(QtGLib_INSTALLED_HEADERS paramspec.h ParamSpec object.h Object value.h Value - signal.h Signal + qglib_signal.h Signal emitimpl.h connect.h Connect connectimpl.h diff --git a/src/QGlib/Signal b/src/QGlib/Signal index d0e5cf6..e9b59c3 100644 --- a/src/QGlib/Signal +++ b/src/QGlib/Signal @@ -1 +1 @@ -#include "signal.h" +#include "qglib_signal.h" diff --git a/src/QGlib/gen.cpp b/src/QGlib/gen.cpp index 9ef9920..7a972ac 100644 --- a/src/QGlib/gen.cpp +++ b/src/QGlib/gen.cpp @@ -29,7 +29,7 @@ #include #include "QGlib/string_p.h" -#include "QGlib/signal.h" +#include "QGlib/qglib_signal.h" namespace QGlib { BOOST_STATIC_ASSERT(static_cast(Signal::RunFirst) == static_cast(G_SIGNAL_RUN_FIRST)); diff --git a/src/QGlib/qglib_signal.h b/src/QGlib/qglib_signal.h new file mode 100644 index 0000000..b317897 --- /dev/null +++ b/src/QGlib/qglib_signal.h @@ -0,0 +1,182 @@ +/* + Copyright (C) 2010 George Kiagiadakis + Copyright (C) 2010 Collabora Ltd. + @author George Kiagiadakis + + 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 program 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 program. If not, see . +*/ +#ifndef QGLIB_SIGNAL_H +#define QGLIB_SIGNAL_H + +#include "global.h" +#include +#include +#include + +//Qt's emit will clash +#if defined(emit) +# if !defined(QGLIB_NO_EMIT_WARNING) //define that to get rid of the warning +# if defined(Q_CC_GNU) +# warning "The emit keyword is defined and will be undefined here to compile QGlib::emit." +# warning "It is recommended to compile your project with QT_NO_KEYWORDS defined." +# elif defined(Q_CC_MSVC) +# pragma message("Warning: The emit keyword is defined and will be undefined here to compile QGlib::emit.") +# pragma message("Warning: It is recommended to compile your project with QT_NO_KEYWORDS defined.") +# endif +# endif +# undef emit +# define QT_NO_EMIT //undocumented Qt macro that skips "#define emit" in qglobal.h +#endif + +namespace QGlib { + +/*! \headerfile qglib_signal.h + * \brief Helper class providing introspection of GObject signals + * + * Signals are a generic notification mechanism. Each signal is bound to a + * certain instantiatable Type and can be emitted on any instance of this type. + * + * This class allows you to inspect these signals. You can use the lookup() and + * listSignals() methods to get a Signal instance. You can then use one of the + * accessor methods to retrieve information about this signal. + * + * This class does not offer methods to emit or connect to signals. + * To emit or connect a signal, use the QGlib::emit() and QGlib::connect() + * methods, respectively. + * + * For more information, please read the relevant Glib documentation. + * + * \sa connect(), emit() + */ +class QTGLIB_EXPORT Signal +{ +public: + enum SignalFlag { + RunFirst = 1<<0, + RunLast = 1<<1, + RunCleanup = 1<<2, + NoRecurse = 1<<3, + Detailed = 1<<4, + Action = 1<<5, + NoHooks = 1<<6 + }; + Q_DECLARE_FLAGS(SignalFlags, SignalFlag); + + Signal(const Signal & other); + Signal & operator=(const Signal & other); + virtual ~Signal(); + + /*! Returns true if this Signal instance represents + * an existing signal, or false otherwise. */ + bool isValid() const; + + uint id() const; ///< Returns the signal's id. + QString name() const; ///< Returns the signal's name. + SignalFlags flags() const; ///< Returns the signal's flags. + + /*! Returns the interface/instance Type that this signal can be emitted for. */ + Type instanceType() const; + Type returnType() const; ///< Returns the return Type of the signal. + QList paramTypes() const; ///< Returns the types of the signal parameters. + + /*! Finds and returns a Signal with the specified \a name + * on the specified interface/instance \a type. */ + static Signal lookup(const char *name, Type type); + + /*! Returns a list with all the signals that an interface/instance \a type has. */ + static QList listSignals(Type type); + +private: + QTGLIB_NO_EXPORT Signal(uint id); + + struct Private; + QSharedDataPointer d; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(Signal::SignalFlags) + +#if defined(DOXYGEN_RUN) + +/*! Emits a signal on a specified \a instance with the specified arguments. + * + * This method will convert all the specified arguments to GValues using Value::set() + * and will then emit the signal using g_signal_emitv(). The returned value from the signal + * (if the signal returns a value) will be converted from GValue to the type R using + * Value::get() and will be returned. If some argument is not of the type that the signal + * expects and a conversion is not possible, a warning will be printed to stderr at runtime + * and the signal will not be emitted. On the contrary, if the return value is not of the type + * that the signal returns and a conversion is not possible, the signal \em will be emitted, + * but a default-constructed value for the type R will be returned and a warning will be + * printed to stderr. + * + * Note that since the implementation uses Value::set() to convert the GValues into the + * specified types, the same rules that apply to Value::set() apply here (i.e. you should + * only use the types of the bindings and not the C types, which means QGst::ObjectPtr instead + * of GstObject*, etc...). + * + * Emitting a signal is useful for the so-called Action signals. These are meant to be emitted + * from the application and not connected to. They are more like dynamic methods that can be + * identified with a string. + * + * \note + * \li This method makes use of C++0x features (namely, variadic templates and rvalue + * references). If your compiler does not support them, a hacky implementation using boost's + * preprocessor, function and bind libraries will be compiled instead. That version has a + * limit of 9 arguments by default. Define QGLIB_SIGNAL_MAX_ARGS to a greater value before + * including QGlib/Signal if you want to support more arguments. + * \li This function's name clashes with Qt's emit keyword. To compile it successfully, + * the headers will undefine Qt's emit and print a warning at compile time. It is recommended + * that you compile your project with QT_NO_KEYWORDS to avoid this, however note that this + * means that the "signals", "slots" and "foreach" keywords will also be unavailable under these + * names (you can use "Q_SIGNALS", "Q_SLOTS" and "Q_FOREACH" respectively). If you do not wish + * to do that, you can also define QT_NO_EMIT or QGLIB_NO_EMIT_WARNING. The first one undefines + * Qt's emit completely and the second one supresses the warning and undefines Qt's emit in all + * the code files that include the QGlib/Signal header. In all cases, to emit Qt signals you + * will have to use "Q_EMIT" instead of "emit". + * + * \param instance The instance of the object on which the signal will be emitted. You can pass + * a RefPointer as an instance without any problems; it will automatically cast to void*. + * \param detailedSignal The name of the signal that you want to emit, with an optional + * detail if the signal is detailed. The detail may be specified with the following syntax: + * "signal::detail". + * \param args The arguments that will be passed to the signal. + * \returns The return value of the signal. + */ +template +R emit(void *instance, const char *detailedSignal, const Args & ... args); + +/*! \overload + * This method takes the detail argument as a quark, separated from the signal name. + * It may be useful if you already have the quark of the detail that you want to specify. + */ +template +R emitWithDetail(void *instance, const char *signal, Quark detail, const Args & ... args); + +#endif //DOXYGEN_RUN + +} //namespace QGlib + +#if !QGLIB_HAVE_CXX0X && !defined(QGLIB_SIGNAL_MAX_ARGS) +# define QGLIB_SIGNAL_MAX_ARGS 9 +#endif + +#define IN_QGLIB_SIGNAL_H +# include "emitimpl.h" +#undef IN_QGLIB_SIGNAL_H + +#if defined(QGLIB_SIGNAL_MAX_ARGS) +# undef QGLIB_SIGNAL_MAX_ARGS +#endif + +#endif diff --git a/src/QGlib/signal.cpp b/src/QGlib/signal.cpp index 4138a88..db3b5fc 100644 --- a/src/QGlib/signal.cpp +++ b/src/QGlib/signal.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -#include "signal.h" +#include "qglib_signal.h" #include "quark.h" #include #include diff --git a/src/QGlib/signal.h b/src/QGlib/signal.h deleted file mode 100644 index 523b53c..0000000 --- a/src/QGlib/signal.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - Copyright (C) 2010 George Kiagiadakis - Copyright (C) 2010 Collabora Ltd. - @author George Kiagiadakis - - 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 program 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 program. If not, see . -*/ -#ifndef QGLIB_SIGNAL_H -#define QGLIB_SIGNAL_H - -#include "global.h" -#include -#include -#include - -//Qt's emit will clash -#if defined(emit) -# if !defined(QGLIB_NO_EMIT_WARNING) //define that to get rid of the warning -# if defined(Q_CC_GNU) -# warning "The emit keyword is defined and will be undefined here to compile QGlib::emit." -# warning "It is recommended to compile your project with QT_NO_KEYWORDS defined." -# elif defined(Q_CC_MSVC) -# pragma message("Warning: The emit keyword is defined and will be undefined here to compile QGlib::emit.") -# pragma message("Warning: It is recommended to compile your project with QT_NO_KEYWORDS defined.") -# endif -# endif -# undef emit -# define QT_NO_EMIT //undocumented Qt macro that skips "#define emit" in qglobal.h -#endif - -namespace QGlib { - -/*! \headerfile signal.h - * \brief Helper class providing introspection of GObject signals - * - * Signals are a generic notification mechanism. Each signal is bound to a - * certain instantiatable Type and can be emitted on any instance of this type. - * - * This class allows you to inspect these signals. You can use the lookup() and - * listSignals() methods to get a Signal instance. You can then use one of the - * accessor methods to retrieve information about this signal. - * - * This class does not offer methods to emit or connect to signals. - * To emit or connect a signal, use the QGlib::emit() and QGlib::connect() - * methods, respectively. - * - * For more information, please read the relevant Glib documentation. - * - * \sa connect(), emit() - */ -class QTGLIB_EXPORT Signal -{ -public: - enum SignalFlag { - RunFirst = 1<<0, - RunLast = 1<<1, - RunCleanup = 1<<2, - NoRecurse = 1<<3, - Detailed = 1<<4, - Action = 1<<5, - NoHooks = 1<<6 - }; - Q_DECLARE_FLAGS(SignalFlags, SignalFlag); - - Signal(const Signal & other); - Signal & operator=(const Signal & other); - virtual ~Signal(); - - /*! Returns true if this Signal instance represents - * an existing signal, or false otherwise. */ - bool isValid() const; - - uint id() const; ///< Returns the signal's id. - QString name() const; ///< Returns the signal's name. - SignalFlags flags() const; ///< Returns the signal's flags. - - /*! Returns the interface/instance Type that this signal can be emitted for. */ - Type instanceType() const; - Type returnType() const; ///< Returns the return Type of the signal. - QList paramTypes() const; ///< Returns the types of the signal parameters. - - /*! Finds and returns a Signal with the specified \a name - * on the specified interface/instance \a type. */ - static Signal lookup(const char *name, Type type); - - /*! Returns a list with all the signals that an interface/instance \a type has. */ - static QList listSignals(Type type); - -private: - QTGLIB_NO_EXPORT Signal(uint id); - - struct Private; - QSharedDataPointer d; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(Signal::SignalFlags) - -#if defined(DOXYGEN_RUN) - -/*! Emits a signal on a specified \a instance with the specified arguments. - * - * This method will convert all the specified arguments to GValues using Value::set() - * and will then emit the signal using g_signal_emitv(). The returned value from the signal - * (if the signal returns a value) will be converted from GValue to the type R using - * Value::get() and will be returned. If some argument is not of the type that the signal - * expects and a conversion is not possible, a warning will be printed to stderr at runtime - * and the signal will not be emitted. On the contrary, if the return value is not of the type - * that the signal returns and a conversion is not possible, the signal \em will be emitted, - * but a default-constructed value for the type R will be returned and a warning will be - * printed to stderr. - * - * Note that since the implementation uses Value::set() to convert the GValues into the - * specified types, the same rules that apply to Value::set() apply here (i.e. you should - * only use the types of the bindings and not the C types, which means QGst::ObjectPtr instead - * of GstObject*, etc...). - * - * Emitting a signal is useful for the so-called Action signals. These are meant to be emitted - * from the application and not connected to. They are more like dynamic methods that can be - * identified with a string. - * - * \note - * \li This method makes use of C++0x features (namely, variadic templates and rvalue - * references). If your compiler does not support them, a hacky implementation using boost's - * preprocessor, function and bind libraries will be compiled instead. That version has a - * limit of 9 arguments by default. Define QGLIB_SIGNAL_MAX_ARGS to a greater value before - * including QGlib/Signal if you want to support more arguments. - * \li This function's name clashes with Qt's emit keyword. To compile it successfully, - * the headers will undefine Qt's emit and print a warning at compile time. It is recommended - * that you compile your project with QT_NO_KEYWORDS to avoid this, however note that this - * means that the "signals", "slots" and "foreach" keywords will also be unavailable under these - * names (you can use "Q_SIGNALS", "Q_SLOTS" and "Q_FOREACH" respectively). If you do not wish - * to do that, you can also define QT_NO_EMIT or QGLIB_NO_EMIT_WARNING. The first one undefines - * Qt's emit completely and the second one supresses the warning and undefines Qt's emit in all - * the code files that include the QGlib/Signal header. In all cases, to emit Qt signals you - * will have to use "Q_EMIT" instead of "emit". - * - * \param instance The instance of the object on which the signal will be emitted. You can pass - * a RefPointer as an instance without any problems; it will automatically cast to void*. - * \param detailedSignal The name of the signal that you want to emit, with an optional - * detail if the signal is detailed. The detail may be specified with the following syntax: - * "signal::detail". - * \param args The arguments that will be passed to the signal. - * \returns The return value of the signal. - */ -template -R emit(void *instance, const char *detailedSignal, const Args & ... args); - -/*! \overload - * This method takes the detail argument as a quark, separated from the signal name. - * It may be useful if you already have the quark of the detail that you want to specify. - */ -template -R emitWithDetail(void *instance, const char *signal, Quark detail, const Args & ... args); - -#endif //DOXYGEN_RUN - -} //namespace QGlib - -#if !QGLIB_HAVE_CXX0X && !defined(QGLIB_SIGNAL_MAX_ARGS) -# define QGLIB_SIGNAL_MAX_ARGS 9 -#endif - -#define IN_QGLIB_SIGNAL_H -# include "emitimpl.h" -#undef IN_QGLIB_SIGNAL_H - -#if defined(QGLIB_SIGNAL_MAX_ARGS) -# undef QGLIB_SIGNAL_MAX_ARGS -#endif - -#endif diff --git a/src/QGst/Ui/graphicsvideowidget.cpp b/src/QGst/Ui/graphicsvideowidget.cpp index 9275404..37f2eea 100644 --- a/src/QGst/Ui/graphicsvideowidget.cpp +++ b/src/QGst/Ui/graphicsvideowidget.cpp @@ -17,7 +17,7 @@ */ #include "graphicsvideowidget.h" #include "graphicsvideosurface_p.h" -#include "../../QGlib/signal.h" +#include "../../QGlib/Signal" namespace QGst { namespace Ui { diff --git a/src/QGst/Ui/videowidget.cpp b/src/QGst/Ui/videowidget.cpp index 73fd61b..fcdd2e1 100644 --- a/src/QGst/Ui/videowidget.cpp +++ b/src/QGst/Ui/videowidget.cpp @@ -22,7 +22,7 @@ #include "../bus.h" #include "../message.h" #include "../../QGlib/connect.h" -#include "../../QGlib/signal.h" +#include "../../QGlib/Signal" #include #include #include diff --git a/src/QGst/bus.cpp b/src/QGst/bus.cpp index 199f905..2e04059 100644 --- a/src/QGst/bus.cpp +++ b/src/QGst/bus.cpp @@ -16,7 +16,7 @@ */ #include "bus.h" #include "message.h" -#include "../QGlib/signal.h" +#include "../QGlib/Signal" #include #include #include -- cgit v1.2.3