Mercurial > projects > qtd
changeset 386:7dddafad5a20
shared stor fix
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Mon, 19 Jul 2010 13:29:57 +0300 |
parents | e700fa4916e4 |
children | b13910fdd739 |
files | cpp/qt_qtd/qtd_core.cpp d2/qt/core/test/Objects.d d2/qtd/Core.d d2/qtd/QtdObject.d generator/cppimplgenerator.cpp generator/dgenerator.cpp |
diffstat | 6 files changed, 44 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/cpp/qt_qtd/qtd_core.cpp Fri Jul 16 20:11:14 2010 +0300 +++ b/cpp/qt_qtd/qtd_core.cpp Mon Jul 19 13:29:57 2010 +0300 @@ -10,7 +10,7 @@ QTD_FUNC(CORE, QtdObject_delete); QTD_EXTERN QTD_EXPORT void qtdInitCore() -{ +{ QObjectLink::userDataId = QObject::registerUserData(); }
--- a/d2/qt/core/test/Objects.d Fri Jul 16 20:11:14 2010 +0300 +++ b/d2/qt/core/test/Objects.d Mon Jul 19 13:29:57 2010 +0300 @@ -1,7 +1,5 @@ module qt.core.test.Objects; -import std.stdio; - // make sure QtdUnittest is defined version (QtdUnittest) {} else { static assert(false); } @@ -12,8 +10,6 @@ qt.core.QObject, qt.core.QMetaObject; -import std.stdio; - extern (C) void* qtd_test_QObject_create(void* parent); extern (C) void qtd_test_QObject_delete(void* nativeId); extern (C) void qtd_test_QObject_event(void* nativeId); @@ -97,7 +93,6 @@ unittest { - writeln("Here"); static void reset() { qtdDebug.reset();
--- a/d2/qtd/Core.d Fri Jul 16 20:11:14 2010 +0300 +++ b/d2/qtd/Core.d Mon Jul 19 13:29:57 2010 +0300 @@ -38,7 +38,7 @@ extern(C) alias void function() VoidFunc; extern(C) void qtdInitCore(); -static this() +shared static this() { qtdInitCore(); }
--- a/d2/qtd/QtdObject.d Fri Jul 16 20:11:14 2010 +0300 +++ b/d2/qtd/QtdObject.d Mon Jul 19 13:29:57 2010 +0300 @@ -117,7 +117,6 @@ /** Disables GC for this object; */ - // TODO: needs to be properly synchronized final void qtdPin() const { assert(!_flags.pinned); @@ -150,7 +149,6 @@ /** Enables GC for this object. */ - // TODO: needs to be properly synchronized final void qtdUnpin() const { assert(_flags.pinned); @@ -171,7 +169,6 @@ /** Sets the ownership of this object. Setting the same ownership twice results in undefined behavior. - The function is not thread-safe. */ void qtdSetOwnership(QtdObjectOwnership own) const { @@ -186,21 +183,27 @@ if (_flags.polymorphic && _flags.createdByD) qtdPin(); else + { + assert (!obj._flags.nativeDeleteDisabled); obj._flags.nativeDeleteDisabled = true; + } } else if (own == QtdObjectOwnership.d) { if (_flags.polymorphic && _flags.createdByD) qtdUnpin(); else + { + assert(obj._flags.nativeDeleteDisabled); obj._flags.nativeDeleteDisabled = false; + } } else assert(false); mixin(debugHandler("onObjectOwnershipChanged", "obj")); - } - + } + // COMPILER BUG: 3206 protected void qtdDeleteNative() { @@ -227,18 +230,30 @@ } } +/* package */ abstract class PolymorphicObject : QtdObject +{ + this(void* nativeId, QtdObjectInitFlags initFlags = QtdObjectInitFlags.none) + { + _flags.polymorphic = true; + super(nativeId, initFlags); + } + + abstract QtdMetaClass metaObject(); +} + /** Base class for polymorphic non-QObjects (TBD). */ -/* package */ abstract class NonQObject : QtdObject +/* package */ abstract class NonQObject : PolymorphicObject { alias NonQObjectMetaClass Meta; this(void* nativeId, QtdObjectInitFlags initFlags) { - _flags.polymorphic = true; super(nativeId, initFlags); } + + override abstract Meta metaObject(); } /** @@ -255,8 +270,7 @@ /** */ - @property - void* nativeId() + @property void* nativeId() { return _nativeId; } @@ -312,7 +326,7 @@ } } -extern (C) bool qtdTypeInfosEqual(void* info1, void* info2); +extern(C) bool qtdTypeInfosEqual(void* info1, void* info2); mixin(qtdExport("void", "QtdObject_delete", "void* dId", q{
--- a/generator/cppimplgenerator.cpp Fri Jul 16 20:11:14 2010 +0300 +++ b/generator/cppimplgenerator.cpp Mon Jul 19 13:29:57 2010 +0300 @@ -917,12 +917,14 @@ // virtual functions handlers AbstractMetaFunctionList virtualFunctions = java_class->virtualFunctions(); AbstractMetaFunction::Options opts(AbstractMetaFunction::DeclaringClass | AbstractMetaFunction::NoExternNamespace); - for (int pos = 0; pos<virtualFunctions.size(); ++pos) { - const AbstractMetaFunction *function = virtualFunctions.at(pos); + + size_t virtual_index = 0; + foreach (const AbstractMetaFunction *function, virtualFunctions) { if (!notWrappedYet(function) && java_class == function->declaringClass()) { // qtd2 QString mName = function->marshalledName(opts); s << " qtd_" << mName << "_dispatch = " - "(qtd_" << mName << "_dispatch_t) virts[" << pos << "];" << endl; + "(qtd_" << mName << "_dispatch_t) virts[" << virtual_index << "];" << endl; + virtual_index++; } } // D-side signal callbacks
--- a/generator/dgenerator.cpp Fri Jul 16 20:11:14 2010 +0300 +++ b/generator/dgenerator.cpp Mon Jul 19 13:29:57 2010 +0300 @@ -2073,8 +2073,9 @@ implements = true; } */ + // only QObjects are handled polymorphically for now if (d_class->isQObject()) - s << " : QtdObject"; + s << " : PolymorphicObject"; else s << " : QtdObject"; implements = true; @@ -2329,10 +2330,6 @@ << INDENT << "_flags.isQObject = true;" << endl; } - // only QObjects are handled polymorphically for now - if (d_class->name() == "QObject" /* d_class->polymorphicBase() == d_class */) - s << INDENT << "_flags.polymorphic = true;" << endl; - s << INDENT << "super(nativeId, initFlags);" << endl; // pointers to native interface objects for classes that implement interfaces @@ -2569,19 +2566,24 @@ AbstractMetaFunction::Options opts(AbstractMetaFunction::DeclaringClass | AbstractMetaFunction::NoExternNamespace); // virtual functions - s << INDENT << "void*[" << virtualFunctions.size() << "] virt_arr;" << endl; - for (int pos = 0; pos<virtualFunctions.size(); ++pos) { - const AbstractMetaFunction *function = virtualFunctions.at(pos); + int virtuals_index = 0; + QString virtuals_init; + + foreach (const AbstractMetaFunction *function, virtualFunctions) { if (!notWrappedYet(function) && d_class == function->declaringClass()) { QString mName = function->marshalledName(opts); - s << INDENT << "virt_arr[" << pos << "] = &qtd_export_" << mName << "_dispatch;" <<endl; + virtuals_init += QString(" virt_arr[%1] = &qtd_export_%2_dispatch;\n").arg(virtuals_index).arg(mName); + virtuals_index++; } } - if (virtualFunctions.size() == 0) + if (virtuals_index == 0) initArgs = "null"; - else + else { + s << " void*[" << virtuals_index << "] virt_arr;" << endl; + s << virtuals_init; initArgs = "virt_arr.ptr"; + } if (d_class->name() == "QObject") { // qt_metacall, metaObject