QskMetaFunction::init removed - saves some size in the text segment
This commit is contained in:
parent
3079698d63
commit
6e4421d4b7
@ -20,6 +20,8 @@ static void debugValue( qreal d, int i )
|
||||
|
||||
class MyObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyObject( QObject* parent = nullptr ):
|
||||
QObject( parent )
|
||||
@ -45,31 +47,65 @@ public:
|
||||
{
|
||||
qDebug() << i;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void done( double, int );
|
||||
};
|
||||
|
||||
class MyObject2: public MyObject
|
||||
{
|
||||
public:
|
||||
MyObject2( QObject* parent = nullptr ):
|
||||
MyObject( parent )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~MyObject2()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void noop()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
static auto fs = []( int i, double d ) { qDebug() << i << d; };
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QCoreApplication app( argc, argv );
|
||||
|
||||
MyObject object;
|
||||
MyObject2 object2;
|
||||
|
||||
Invoker invoker;
|
||||
|
||||
invoker.addCallback( QskMetaFunction() );
|
||||
#if 1
|
||||
invoker.addCallback( debugValue );
|
||||
invoker.addCallback( debugValueI );
|
||||
invoker.addCallback( &object, &MyObject::print1 );
|
||||
invoker.addCallback( &object2, &MyObject2::print1 );
|
||||
invoker.addCallback( &object, &MyObject::print2 );
|
||||
invoker.addCallback( &object, &MyObject::print3 );
|
||||
invoker.addCallback( &object, &MyObject::print4 );
|
||||
invoker.addCallback( &object, []( double d, int i ) { qDebug() << d << i; } );
|
||||
invoker.addCallback( &object, []( int i, double d ) { qDebug() << i << d; } );
|
||||
|
||||
int num = 111;
|
||||
auto f = [&num]( int i, double d ) { qDebug() << i << d << (++num); };
|
||||
invoker.addCallback( &object, f );
|
||||
invoker.addCallback( &object2, f );
|
||||
invoker.addCallback( &object, fs );
|
||||
invoker.addCallback( &object2, fs );
|
||||
|
||||
invoker.addCallback( &object, []( double d ) { qDebug() << d; } );
|
||||
invoker.addCallback( []() { qDebug() << "HERE"; } );
|
||||
invoker.addCallback( [ = ]( double d, int i ) { qDebug() << d << i; } );
|
||||
invoker.addCallback( []( int i, double d ) { qDebug() << i << d; } );
|
||||
invoker.addCallback( []( int i ) { qDebug() << i; } );
|
||||
invoker.addCallback( []( double d ) { qDebug() << d; } );
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
qDebug() << "== Direct Connections";
|
||||
invoker.invoke( 3.14, 35, Qt::DirectConnection );
|
||||
|
||||
@ -77,7 +113,39 @@ int main( int argc, char* argv[] )
|
||||
|
||||
QTimer::singleShot( 0,
|
||||
[&invoker] { invoker.invoke( 0.07, 42, Qt::QueuedConnection ); } );
|
||||
#endif
|
||||
|
||||
QTimer::singleShot( 100, &app, QCoreApplication::quit );
|
||||
|
||||
#if 0
|
||||
QObject::connect( &object2, &MyObject2::done,
|
||||
&object, &MyObject::print1 );
|
||||
|
||||
QObject::connect( &object2, &MyObject2::done, debugValue );
|
||||
QObject::connect( &object2, &MyObject2::done, debugValueI );
|
||||
QObject::connect( &object2, &MyObject2::done, &object, &MyObject::print1 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object2, &MyObject2::print1 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object, &MyObject::print2 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object, &MyObject::print3 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object, &MyObject::print4 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object, []( double d, int i ) { qDebug() << d << i; } );
|
||||
|
||||
int num2 = 111;
|
||||
auto f2 = [&num2]( int i, double d ) { qDebug() << i << d << (++num2); };
|
||||
QObject::connect( &object2, &MyObject2::done, &object, f2 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object2, f2 );
|
||||
QObject::connect( &object2, &MyObject2::done, &object, fs );
|
||||
QObject::connect( &object2, &MyObject2::done, &object2, fs );
|
||||
|
||||
QObject::connect( &object2, &MyObject2::done, &object, []( double d ) { qDebug() << d; } );
|
||||
QObject::connect( &object2, &MyObject2::done, []() { qDebug() << "HERE"; } );
|
||||
QObject::connect( &object2, &MyObject2::done, []( int i, double d ) { qDebug() << i << d; } );
|
||||
QObject::connect( &object2, &MyObject2::done, []( int i ) { qDebug() << i; } );
|
||||
QObject::connect( &object2, &MyObject2::done, []( double d ) { qDebug() << d; } );
|
||||
|
||||
#endif
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
||||
|
@ -98,13 +98,6 @@ QskMetaFunction& QskMetaFunction::operator=( const QskMetaFunction& other )
|
||||
return *this;
|
||||
}
|
||||
|
||||
void QskMetaFunction::init( QskMetaInvokable* invokable,
|
||||
const int* parameterTypes )
|
||||
{
|
||||
m_invokable = invokable;
|
||||
m_parameterTypes = parameterTypes;
|
||||
}
|
||||
|
||||
size_t QskMetaFunction::parameterCount() const
|
||||
{
|
||||
if ( m_parameterTypes )
|
||||
|
@ -82,8 +82,6 @@ protected:
|
||||
friend class QskMetaCallback;
|
||||
|
||||
QskMetaFunction( QskMetaInvokable*, const int* );
|
||||
|
||||
void init( QskMetaInvokable*, const int* );
|
||||
QskMetaInvokable* invokable() const;
|
||||
|
||||
private:
|
||||
@ -108,14 +106,14 @@ inline QskMetaFunction::QskMetaFunction( T function )
|
||||
|
||||
using Traits = FunctionPointer< T >;
|
||||
|
||||
const int Argc = Traits::ArgumentCount;
|
||||
constexpr int Argc = Traits::ArgumentCount;
|
||||
using Args = typename List_Left< typename Traits::Arguments, Argc >::Value;
|
||||
|
||||
auto invokable = QskMetaInvokable::instance(
|
||||
QskMetaMemberInvokable< T, Args, void >::invoke,
|
||||
reinterpret_cast< void** >( &function ) );
|
||||
m_invokable = QskMetaInvokable::instance(
|
||||
QskMetaMemberInvokable< T, Args, void >::invoke,
|
||||
reinterpret_cast< void** >( &function ) );
|
||||
|
||||
init( invokable, ConnectionTypes< typename Traits::Arguments >::types() );
|
||||
m_parameterTypes = ConnectionTypes< typename Traits::Arguments >::types();
|
||||
}
|
||||
|
||||
template< typename T, QskMetaFunctionTraits::IsFunction< T >* >
|
||||
@ -125,14 +123,14 @@ inline QskMetaFunction::QskMetaFunction( T function )
|
||||
|
||||
using Traits = FunctionPointer< T >;
|
||||
|
||||
const int Argc = Traits::ArgumentCount;
|
||||
constexpr int Argc = Traits::ArgumentCount;
|
||||
using Args = typename List_Left< typename Traits::Arguments, Argc >::Value;
|
||||
|
||||
auto invokable = QskMetaInvokable::instance(
|
||||
m_invokable = QskMetaInvokable::instance(
|
||||
QskMetaFunctionInvokable< T, Args, void >::invoke,
|
||||
reinterpret_cast< void** >( &function ) );
|
||||
|
||||
init( invokable, ConnectionTypes< typename Traits::Arguments >::types() );
|
||||
m_parameterTypes = ConnectionTypes< typename Traits::Arguments >::types();
|
||||
}
|
||||
|
||||
template< typename T, QskMetaFunctionTraits::IsFunctor< T >* >
|
||||
@ -142,14 +140,14 @@ inline QskMetaFunction::QskMetaFunction( T functor )
|
||||
|
||||
using Traits = FunctionPointer< decltype( &T::operator() ) >;
|
||||
|
||||
const int Argc = Traits::ArgumentCount;
|
||||
constexpr int Argc = Traits::ArgumentCount;
|
||||
using Args = typename List_Left< typename Traits::Arguments, Argc >::Value;
|
||||
|
||||
auto invokable = QskMetaInvokable::instance(
|
||||
m_invokable = QskMetaInvokable::instance(
|
||||
QskMetaFunctorInvokable< T, Argc, Args, void >::invoke,
|
||||
reinterpret_cast< void** >( &functor ) );
|
||||
|
||||
init( invokable, ConnectionTypes< typename Traits::Arguments >::types() );
|
||||
m_parameterTypes = ConnectionTypes< typename Traits::Arguments >::types();
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE( QskMetaFunction )
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
static QskMetaInvokable* instance( InvokeFunction, void** function );
|
||||
|
||||
protected:
|
||||
explicit QskMetaInvokable( InvokeFunction f ):
|
||||
explicit inline QskMetaInvokable( InvokeFunction f ):
|
||||
QSlotObjectBase( f )
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user