2018-03-04 13:31:49 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_META_INVOKABLE_H
|
|
|
|
#define QSK_META_INVOKABLE_H 1
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
|
|
|
|
|
|
|
#include <QMetaType>
|
|
|
|
#include <Qt>
|
|
|
|
|
|
|
|
template< typename T > class QVector;
|
|
|
|
|
|
|
|
class QskMetaFunction;
|
|
|
|
class QMetaObject;
|
|
|
|
class QMetaMethod;
|
2018-03-09 12:24:18 +01:00
|
|
|
class QMetaProperty;
|
2018-03-04 13:31:49 +01:00
|
|
|
class QObject;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskMetaInvokable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
Invalid = 0,
|
|
|
|
|
|
|
|
// A QMetaMethod
|
|
|
|
MetaMethod,
|
|
|
|
|
2018-03-09 12:24:18 +01:00
|
|
|
// The WRITE accessor of a QMetaProperty
|
|
|
|
MetaProperty,
|
|
|
|
|
2018-03-04 13:31:49 +01:00
|
|
|
// A function pointer, for what Qt calls "functor based" callbacks
|
|
|
|
MetaFunction
|
|
|
|
};
|
|
|
|
|
|
|
|
QskMetaInvokable();
|
|
|
|
|
|
|
|
QskMetaInvokable( const QskMetaFunction& );
|
2018-03-09 12:24:18 +01:00
|
|
|
|
2018-03-04 13:31:49 +01:00
|
|
|
QskMetaInvokable( const QMetaMethod& );
|
|
|
|
QskMetaInvokable( const QObject*, const char* methodName );
|
|
|
|
QskMetaInvokable( const QMetaObject*, const char* methodName );
|
|
|
|
|
2018-03-09 12:24:18 +01:00
|
|
|
QskMetaInvokable( const QMetaProperty& );
|
|
|
|
|
2018-03-04 13:31:49 +01:00
|
|
|
QskMetaInvokable( const QskMetaInvokable& );
|
|
|
|
|
|
|
|
~QskMetaInvokable();
|
|
|
|
|
|
|
|
QskMetaInvokable& operator=( const QskMetaInvokable& );
|
|
|
|
|
|
|
|
bool operator==( const QskMetaInvokable& ) const;
|
|
|
|
bool operator!=( const QskMetaInvokable& ) const;
|
|
|
|
|
|
|
|
explicit operator bool() const;
|
|
|
|
|
|
|
|
Type type() const;
|
|
|
|
bool isNull() const;
|
|
|
|
|
|
|
|
QVector< int > parameterTypes() const;
|
2018-03-08 08:37:44 +01:00
|
|
|
int returnType() const;
|
2018-03-04 13:31:49 +01:00
|
|
|
|
|
|
|
void invoke( QObject*, void* args[],
|
|
|
|
Qt::ConnectionType = Qt::AutoConnection );
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
2018-03-09 16:20:33 +01:00
|
|
|
QByteArray name() const;
|
|
|
|
|
|
|
|
QMetaMethod method() const;
|
|
|
|
QMetaProperty property() const;
|
|
|
|
QskMetaFunction function() const;
|
2018-03-08 08:37:44 +01:00
|
|
|
|
2018-03-04 13:31:49 +01:00
|
|
|
private:
|
|
|
|
struct FunctionData
|
|
|
|
{
|
|
|
|
void* functionCall;
|
|
|
|
};
|
|
|
|
|
2018-03-09 12:24:18 +01:00
|
|
|
struct MetaData
|
2018-03-04 13:31:49 +01:00
|
|
|
{
|
|
|
|
const QMetaObject* metaObject;
|
2018-03-09 12:24:18 +01:00
|
|
|
int index; // method or property index
|
2018-03-04 13:31:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
FunctionData m_functionData;
|
2018-03-09 12:24:18 +01:00
|
|
|
MetaData m_metaData;
|
2018-03-04 13:31:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int m_type : 3;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline QskMetaInvokable::QskMetaInvokable():
|
|
|
|
m_type( Invalid )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool QskMetaInvokable::operator!=( const QskMetaInvokable& other ) const
|
|
|
|
{
|
|
|
|
return !( *this == other );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QskMetaInvokable::operator bool() const
|
|
|
|
{
|
|
|
|
return !isNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QskMetaInvokable::Type QskMetaInvokable::type() const
|
|
|
|
{
|
|
|
|
return static_cast< Type >( m_type );
|
|
|
|
}
|
|
|
|
|
2018-03-11 17:28:32 +01:00
|
|
|
QSK_EXPORT QMetaMethod qskMetaMethod( const QMetaObject*, const char* methodName );
|
|
|
|
QSK_EXPORT QMetaMethod qskMetaMethod( const QObject*, const char* methodName );
|
|
|
|
|
|
|
|
QSK_EXPORT void qskInvokeMetaMethod(
|
|
|
|
QObject*, const QMetaObject*, int methodIndex, void* args[],
|
|
|
|
Qt::ConnectionType = Qt::AutoConnection );
|
|
|
|
|
|
|
|
QSK_EXPORT void qskInvokeMetaMethod(
|
|
|
|
QObject*, const QMetaMethod&, void* args[],
|
|
|
|
Qt::ConnectionType = Qt::AutoConnection );
|
|
|
|
|
|
|
|
QSK_EXPORT void qskInvokeMetaPropertyWrite(
|
|
|
|
QObject*, const QMetaObject*, int propertyIndex,
|
|
|
|
void* args[], Qt::ConnectionType = Qt::AutoConnection );
|
|
|
|
|
|
|
|
QSK_EXPORT void qskInvokeMetaPropertyWrite(
|
|
|
|
const QObject* object, const QMetaProperty&,
|
|
|
|
void* args[], Qt::ConnectionType = Qt::AutoConnection );
|
|
|
|
|
|
|
|
|
|
|
|
QSK_EXPORT QMetaMethod qskNotifySignal( const QMetaObject*, const char* propertyName );
|
|
|
|
QSK_EXPORT QMetaMethod qskNotifySignal( const QObject*, const char* propertyName );
|
|
|
|
|
|
|
|
|
2018-03-04 13:31:49 +01:00
|
|
|
Q_DECLARE_METATYPE( QskMetaInvokable )
|
|
|
|
|
|
|
|
#endif
|