Move QNativeInterface helpers to their own header file
The machinery is not needed for all translation units, so keep it out of qglobal.h. Change-Id: Ib0459a3f7bc036f56b0810eb750d4641f567f1fe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
590f70a849
commit
b0e8c52fd4
@ -49,6 +49,7 @@ qt_internal_add_module(Core
|
||||
global/qlogging.cpp global/qlogging.h
|
||||
global/qmalloc.cpp
|
||||
global/qnamespace.h # this header is specified on purpose so AUTOMOC processes it
|
||||
global/qnativeinterface.h
|
||||
global/qnumeric.cpp global/qnumeric.h global/qnumeric_p.h
|
||||
global/qoperatingsystemversion.cpp global/qoperatingsystemversion.h global/qoperatingsystemversion_p.h
|
||||
global/qprocessordetection.h
|
||||
|
@ -1395,30 +1395,6 @@ inline int qIntCast(float f) { return int(f); }
|
||||
#define QT_OVERLOADED_MACRO_IMP(MACRO, ARGC) QT_OVERLOADED_MACRO_EXPAND(MACRO, ARGC)
|
||||
#define QT_OVERLOADED_MACRO(MACRO, ...) QT_VA_ARGS_EXPAND(QT_OVERLOADED_MACRO_IMP(MACRO, QT_VA_ARGS_COUNT(__VA_ARGS__))(__VA_ARGS__))
|
||||
|
||||
// Ensures that the interface's typeinfo is exported so that
|
||||
// dynamic casts work reliably, and protects the destructor
|
||||
// so that pointers to the interface can't be deleted.
|
||||
#define QT_DECLARE_NATIVE_INTERFACE(InterfaceClass) \
|
||||
protected: virtual ~InterfaceClass(); public:
|
||||
|
||||
// Declares an accessor for the native interface
|
||||
#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR \
|
||||
template <typename QNativeInterface> \
|
||||
QNativeInterface *nativeInterface() const;
|
||||
|
||||
// Provides a definition for the interface destructor
|
||||
#define QT_DEFINE_NATIVE_INTERFACE_2(Namespace, InterfaceClass) \
|
||||
QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass::~InterfaceClass() = default
|
||||
|
||||
// Provides a definition for the destructor, and an explicit
|
||||
// template instantiation of the native interface accessor.
|
||||
#define QT_DEFINE_NATIVE_INTERFACE_3(Namespace, InterfaceClass, PublicClass) \
|
||||
QT_DEFINE_NATIVE_INTERFACE_2(Namespace, InterfaceClass); \
|
||||
template Q_DECL_EXPORT QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass *PublicClass::nativeInterface() const
|
||||
|
||||
#define QT_DEFINE_NATIVE_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_NATIVE_INTERFACE, QNativeInterface, __VA_ARGS__)
|
||||
#define QT_DEFINE_PRIVATE_NATIVE_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_NATIVE_INTERFACE, QNativeInterface::Private, __VA_ARGS__)
|
||||
|
||||
// This macro can be used to calculate member offsets for types with a non standard layout.
|
||||
// It uses the fact that offsetof() is allowed to support those types since C++17 as an optional
|
||||
// feature. All our compilers do support this, but some issue a warning, so we wrap the offsetof()
|
||||
|
73
src/corelib/global/qnativeinterface.h
Normal file
73
src/corelib/global/qnativeinterface.h
Normal file
@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef QNATIVEINTERFACE_H
|
||||
#define QNATIVEINTERFACE_H
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Ensures that the interface's typeinfo is exported so that
|
||||
// dynamic casts work reliably, and protects the destructor
|
||||
// so that pointers to the interface can't be deleted.
|
||||
#define QT_DECLARE_NATIVE_INTERFACE(InterfaceClass) \
|
||||
protected: virtual ~InterfaceClass(); public:
|
||||
|
||||
// Declares an accessor for the native interface
|
||||
#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR \
|
||||
template <typename QNativeInterface> \
|
||||
QNativeInterface *nativeInterface() const;
|
||||
|
||||
// Provides a definition for the interface destructor
|
||||
#define QT_DEFINE_NATIVE_INTERFACE_2(Namespace, InterfaceClass) \
|
||||
QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass::~InterfaceClass() = default
|
||||
|
||||
// Provides a definition for the destructor, and an explicit
|
||||
// template instantiation of the native interface accessor.
|
||||
#define QT_DEFINE_NATIVE_INTERFACE_3(Namespace, InterfaceClass, PublicClass) \
|
||||
QT_DEFINE_NATIVE_INTERFACE_2(Namespace, InterfaceClass); \
|
||||
template Q_DECL_EXPORT QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass *PublicClass::nativeInterface() const
|
||||
|
||||
#define QT_DEFINE_NATIVE_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_NATIVE_INTERFACE, QNativeInterface, __VA_ARGS__)
|
||||
#define QT_DEFINE_PRIVATE_NATIVE_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_NATIVE_INTERFACE, QNativeInterface::Private, __VA_ARGS__)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QNATIVEINTERFACE_H
|
@ -41,6 +41,7 @@
|
||||
#define QCOREAPPLICATION_PLATFORM_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
|
||||
class _jobject;
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/private/qcoreapplication_p.h>
|
||||
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
#include <QtCore/private/qthread_p.h>
|
||||
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <qlocale.h>
|
||||
#include <qevent.h>
|
||||
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include <QtGui/qtguiglobal.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
#include <QtGui/qsurface.h>
|
||||
Q_MOC_INCLUDE(<QScreen>)
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include <QtGui/qtguiglobal.h>
|
||||
#include <QtGui/qoffscreensurface.h>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
struct ANativeWindow;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
#include <QtGui/QSurfaceFormat>
|
||||
|
||||
@ -60,6 +61,7 @@
|
||||
#include <QtGui/qopengl.h>
|
||||
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include <QtGui/qopenglcontext.h>
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
Q_FORWARD_DECLARE_OBJC_CLASS(NSOpenGLContext);
|
||||
#endif
|
||||
|
@ -53,6 +53,8 @@
|
||||
|
||||
#include <QtGui/private/qtguiglobal_p.h>
|
||||
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// ----------------- QNativeInterface -----------------
|
||||
|
@ -54,6 +54,8 @@
|
||||
#include <QtGui/qoffscreensurface.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOffscreenSurface;
|
||||
|
@ -59,6 +59,8 @@
|
||||
#include <QtGui/qopengl.h>
|
||||
#include <QtGui/qopenglcontext.h>
|
||||
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <QtGui/private/qtguiglobal_p.h>
|
||||
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <QtGui/private/qtguiglobal_p.h>
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtCore/qnativeinterface.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user