view qt/d2/qt/QtdObject.d @ 282:256ab6cb8e85

Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
author eldar
date Fri, 16 Oct 2009 02:43:59 +0000
parents 073b9153ed8a
children f9559a957be9
line wrap: on
line source

/**
*
*  Copyright: Copyright QtD Team, 2008-2009
*  License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
*
*  Copyright QtD Team, 2008-2009
*  Distributed under the Boost Software License, Version 1.0.
*  (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/

module qt.QtdObject;

import qt.Signal;

enum QtdObjectFlags : ubyte
{
    none,
    nativeOwnership           = 0x1,
    dOwnership                = 0x2,
    dynamicEntity             = 0x4
    //gcManaged               = 0x4
}

package abstract class QtdObject
{
    protected QtdObjectFlags __flags_;
    void* __nativeId;

    mixin SignalHandlerOps;
        
    this(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.none)
    {
        __nativeId = nativeId;
        __flags_ = flags;
    }

    final QtdObjectFlags __flags()
    {
        return __flags_;
    }

    /+ final +/ void __setFlags(QtdObjectFlags flags, bool value)
    {
        if (value)
            __flags_ |= flags;
        else
            __flags_ &= ~flags;
    }

    // COMPILER BUG: 3206
    protected void __deleteNative()
    {
        assert(false);
    }

    ~this()
    {
        if (!(__flags_ & QtdObjectFlags.nativeOwnership))
        {
            // avoid deleting D object twice.
            __flags_ |= QtdObjectFlags.dOwnership;
            __deleteNative;
        }
    }
}