Fixed how the methods and signals creation by adding always first the signals and later the other methods.
This commit is contained in:
parent
aaf62ce426
commit
da91b63246
|
@ -1 +1 @@
|
|||
dmd -debug dotherside.d dslot.d dsignal.d dobject.d typemapper.d dothersideinterface.di test.d -L-lDOtherSide -L-L../build/DOtherSide
|
||||
dmd -debug dotherside.d dslot.d dsignal.d dobject.d dothersideinterface.di test.d -L-lDOtherSide -L-L../build/DOtherSide
|
||||
|
|
4
D/test.d
4
D/test.d
|
@ -2,8 +2,8 @@ import std.stdio;
|
|||
import std.string;
|
||||
import std.traits;
|
||||
import std.conv;
|
||||
import core.memory;
|
||||
import std.functional;
|
||||
import core.memory;
|
||||
import dotherside;
|
||||
import dobject;
|
||||
import dslot;
|
||||
|
@ -13,9 +13,9 @@ class MyObject : DObject
|
|||
{
|
||||
this()
|
||||
{
|
||||
nameChanged = registerSignal!(string)("nameChanged");
|
||||
foo = registerSlot("foo", &_foo);
|
||||
bar = registerSlot("bar", &_bar);
|
||||
nameChanged = registerSignal!(string)("nameChanged");
|
||||
tor = registerSlot("tor", &_tor);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import std.stdio;
|
||||
import std.container;
|
||||
import std.conv;
|
||||
import std.typecons;
|
||||
import std.traits;
|
||||
|
||||
public static class TypeMapper
|
||||
{
|
||||
|
||||
}
|
|
@ -32,11 +32,34 @@ bool DynamicQObject::registerSlot(const QString& name,
|
|||
m_slotsByName.insertMulti(slot.name(), slot);
|
||||
m_slotsBySignature[slot.signature()] = slot;
|
||||
|
||||
QMetaObjectBuilder builder(m_metaObject.data());
|
||||
QMetaMethodBuilder methodBuilder = builder.addSlot(slot.signature());
|
||||
// Collect the current methods and signals
|
||||
QList<QMetaMethod> signalsList;
|
||||
QList<QMetaMethod> methodsList;
|
||||
|
||||
for (int i = m_metaObject->methodOffset(); i < m_metaObject->methodCount(); ++i)
|
||||
{
|
||||
auto method = m_metaObject->method(i);
|
||||
if (method.methodType() == QMetaMethod::Signal)
|
||||
signalsList.append(method);
|
||||
else
|
||||
methodsList.append(method);
|
||||
}
|
||||
|
||||
QMetaObjectBuilder newMetaObjectBuilder;
|
||||
newMetaObjectBuilder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
|
||||
newMetaObjectBuilder.setClassName("DynamicObject");
|
||||
newMetaObjectBuilder.setSuperClass(&QObject::staticMetaObject);
|
||||
|
||||
foreach(auto method, signalsList)
|
||||
newMetaObjectBuilder.addMethod(method);
|
||||
|
||||
foreach (auto method, methodsList)
|
||||
newMetaObjectBuilder.addMethod(method);
|
||||
|
||||
QMetaMethodBuilder methodBuilder = newMetaObjectBuilder.addSlot(slot.signature());
|
||||
methodBuilder.setReturnType(QMetaType::typeName(returnType));
|
||||
methodBuilder.setAttributes(QMetaMethod::Scriptable);
|
||||
m_metaObject.reset(builder.toMetaObject());
|
||||
m_metaObject.reset(newMetaObjectBuilder.toMetaObject());
|
||||
|
||||
slotIndex = m_metaObject->indexOfSlot(QMetaObject::normalizedSignature(slot.signature()));
|
||||
|
||||
|
@ -53,11 +76,35 @@ bool DynamicQObject::registerSignal(const QString& name, const QList<QMetaType::
|
|||
m_signalsByName.insertMulti(signal.name(), signal);
|
||||
m_signalsBySignature[signal.signature()] = signal;
|
||||
|
||||
QMetaObjectBuilder builder(m_metaObject.data());
|
||||
QMetaMethodBuilder methodBuilder = builder.addSignal(signal.signature());
|
||||
// Collect the current methods and signals
|
||||
QList<QMetaMethod> signalsList;
|
||||
QList<QMetaMethod> methodsList;
|
||||
|
||||
for (int i = m_metaObject->methodOffset(); i < m_metaObject->methodCount(); ++i)
|
||||
{
|
||||
auto method = m_metaObject->method(i);
|
||||
if (method.methodType() == QMetaMethod::Signal)
|
||||
signalsList.append(method);
|
||||
else
|
||||
methodsList.append(method);
|
||||
}
|
||||
|
||||
QMetaObjectBuilder newMetaObjectBuilder;
|
||||
newMetaObjectBuilder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
|
||||
newMetaObjectBuilder.setClassName("DynamicObject");
|
||||
newMetaObjectBuilder.setSuperClass(&QObject::staticMetaObject);
|
||||
|
||||
foreach(auto method, signalsList)
|
||||
newMetaObjectBuilder.addMethod(method);
|
||||
|
||||
QMetaMethodBuilder methodBuilder = newMetaObjectBuilder.addSignal(signal.signature());
|
||||
methodBuilder.setReturnType(QMetaType::typeName(QMetaType::Void));
|
||||
methodBuilder.setAccess(QMetaMethod::Public);
|
||||
m_metaObject.reset(builder.toMetaObject());
|
||||
|
||||
foreach (auto method, methodsList)
|
||||
newMetaObjectBuilder.addMethod(method);
|
||||
|
||||
m_metaObject.reset(newMetaObjectBuilder.toMetaObject());
|
||||
|
||||
signalIndex = m_metaObject->indexOfSignal(QMetaObject::normalizedSignature(signal.signature()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue