Changeset 386:7dddafad5a20

Show
Ignore:
Timestamp:
07/19/10 06:29:57 (3 years ago)
Author:
Max Samukha <maxter@spambox.com>
branch:
default
Message:

shared stor fix

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cpp/qt_qtd/qtd_core.cpp

    r384 r386  
    1111 
    1212QTD_EXTERN QTD_EXPORT void qtdInitCore() 
    13 { 
     13{     
    1414    QObjectLink::userDataId = QObject::registerUserData(); 
    1515} 
  • d2/qt/core/test/Objects.d

    r383 r386  
    11module qt.core.test.Objects; 
    2  
    3 import std.stdio; 
    42 
    53// make sure QtdUnittest is defined 
     
    1210    qt.core.QObject, 
    1311    qt.core.QMetaObject; 
    14  
    15 import std.stdio; 
    1612 
    1713extern (C) void* qtd_test_QObject_create(void* parent); 
     
    9894unittest 
    9995{ 
    100     writeln("Here"); 
    10196    static void reset() 
    10297    { 
  • d2/qtd/Core.d

    r384 r386  
    3939extern(C) void qtdInitCore(); 
    4040 
    41 static this() 
     41shared static this() 
    4242{ 
    4343    qtdInitCore(); 
  • d2/qtd/QtdObject.d

    r383 r386  
    118118        Disables GC for this object; 
    119119     */ 
    120     // TODO: needs to be properly synchronized 
    121120    final void qtdPin() const 
    122121    { 
     
    151150        Enables GC for this object. 
    152151     */ 
    153     // TODO: needs to be properly synchronized 
    154152    final void qtdUnpin() const 
    155153    { 
     
    172170        Sets the ownership of this object. 
    173171        Setting the same ownership twice results in undefined behavior. 
    174         The function is not thread-safe. 
    175172     */ 
    176173    void qtdSetOwnership(QtdObjectOwnership own) const 
     
    187184                qtdPin(); 
    188185            else 
     186            { 
     187                assert (!obj._flags.nativeDeleteDisabled); 
    189188                obj._flags.nativeDeleteDisabled = true; 
     189            } 
    190190        } 
    191191        else if (own == QtdObjectOwnership.d) 
     
    194194                qtdUnpin(); 
    195195            else 
     196            { 
     197                assert(obj._flags.nativeDeleteDisabled); 
    196198                obj._flags.nativeDeleteDisabled = false; 
     199            } 
    197200        } 
    198201        else 
     
    200203 
    201204        mixin(debugHandler("onObjectOwnershipChanged", "obj")); 
    202     } 
    203  
     205    }     
     206     
    204207    // COMPILER BUG: 3206 
    205208    protected void qtdDeleteNative() 
     
    228231} 
    229232 
     233/* package */ abstract class PolymorphicObject : QtdObject 
     234{ 
     235    this(void* nativeId, QtdObjectInitFlags initFlags = QtdObjectInitFlags.none) 
     236    { 
     237        _flags.polymorphic = true; 
     238        super(nativeId, initFlags);  
     239    } 
     240     
     241    abstract QtdMetaClass metaObject(); 
     242} 
     243 
    230244/** 
    231245    Base class for polymorphic non-QObjects (TBD). 
    232246 */ 
    233 /* package */ abstract class NonQObject : QtdObject 
     247/* package */ abstract class NonQObject : PolymorphicObject 
    234248{ 
    235249    alias NonQObjectMetaClass Meta; 
     
    237251    this(void* nativeId, QtdObjectInitFlags initFlags) 
    238252    { 
    239         _flags.polymorphic = true; 
    240253        super(nativeId, initFlags); 
    241254    } 
     255     
     256    override abstract Meta metaObject(); 
    242257} 
    243258 
     
    256271    /** 
    257272     */ 
    258     @property 
    259     void* nativeId() 
     273    @property void* nativeId() 
    260274    { 
    261275        return _nativeId; 
     
    313327} 
    314328 
    315 extern (C) bool qtdTypeInfosEqual(void* info1, void* info2); 
     329extern(C) bool qtdTypeInfosEqual(void* info1, void* info2); 
    316330 
    317331mixin(qtdExport("void", "QtdObject_delete", "void* dId", 
  • generator/cppimplgenerator.cpp

    r384 r386  
    918918    AbstractMetaFunctionList virtualFunctions = java_class->virtualFunctions(); 
    919919    AbstractMetaFunction::Options opts(AbstractMetaFunction::DeclaringClass | AbstractMetaFunction::NoExternNamespace); 
    920     for (int pos = 0; pos<virtualFunctions.size(); ++pos) { 
    921         const AbstractMetaFunction *function = virtualFunctions.at(pos); 
     920 
     921    size_t virtual_index = 0; 
     922    foreach (const AbstractMetaFunction *function, virtualFunctions) {         
    922923        if (!notWrappedYet(function) && java_class == function->declaringClass()) { // qtd2 
    923924            QString mName = function->marshalledName(opts); 
    924925            s << "    qtd_" << mName << "_dispatch = " 
    925                  "(qtd_" << mName << "_dispatch_t) virts[" << pos << "];" << endl; 
     926                 "(qtd_" << mName << "_dispatch_t) virts[" << virtual_index << "];" << endl; 
     927            virtual_index++; 
    926928        } 
    927929    } 
  • generator/dgenerator.cpp

    r384 r386  
    20742074            } 
    20752075            */ 
     2076            // only QObjects are handled polymorphically for now 
    20762077            if (d_class->isQObject()) 
    2077                 s << " : QtdObject"; 
     2078                s << " : PolymorphicObject"; 
    20782079            else 
    20792080                s << " : QtdObject"; 
     
    23302331            } 
    23312332 
    2332             // only QObjects are handled polymorphically for now 
    2333             if (d_class->name() == "QObject" /* d_class->polymorphicBase() == d_class */) 
    2334                 s << INDENT << "_flags.polymorphic = true;" << endl; 
    2335  
    23362333            s << INDENT << "super(nativeId, initFlags);" << endl; 
    23372334 
     
    25702567 
    25712568            // virtual functions 
    2572             s << INDENT << "void*[" << virtualFunctions.size() << "] virt_arr;" << endl; 
    2573             for (int pos = 0; pos<virtualFunctions.size(); ++pos) { 
    2574                 const AbstractMetaFunction *function = virtualFunctions.at(pos); 
     2569            int virtuals_index = 0; 
     2570            QString virtuals_init; 
     2571 
     2572            foreach (const AbstractMetaFunction *function, virtualFunctions) { 
    25752573                if (!notWrappedYet(function) && d_class == function->declaringClass()) { 
    25762574                    QString mName = function->marshalledName(opts); 
    2577                     s << INDENT << "virt_arr[" << pos << "] = &qtd_export_" << mName << "_dispatch;" <<endl; 
     2575                    virtuals_init += QString("    virt_arr[%1] = &qtd_export_%2_dispatch;\n").arg(virtuals_index).arg(mName); 
     2576                    virtuals_index++; 
    25782577                } 
    25792578            } 
    25802579 
    2581             if (virtualFunctions.size() == 0) 
     2580            if (virtuals_index == 0) 
    25822581                initArgs = "null"; 
    2583             else 
     2582            else { 
     2583                s << "    void*[" << virtuals_index << "] virt_arr;" << endl; 
     2584                s << virtuals_init; 
    25842585                initArgs = "virt_arr.ptr"; 
     2586            } 
    25852587 
    25862588            if (d_class->name() == "QObject") {