253
|
1 /**
|
|
2 *
|
|
3 * Copyright: Copyright QtD Team, 2008-2009
|
|
4 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
|
|
5 *
|
|
6 * Copyright QtD Team, 2008-2009
|
|
7 * Distributed under the Boost Software License, Version 1.0.
|
|
8 * (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
9 *
|
|
10 */
|
|
11
|
344
|
12 module qtd.QtdObject;
|
253
|
13
|
|
14 enum QtdObjectFlags : ubyte
|
|
15 {
|
|
16 none,
|
|
17 nativeOwnership = 0x1,
|
|
18 dOwnership = 0x2,
|
|
19 dynamicEntity = 0x4
|
|
20 //gcManaged = 0x4
|
|
21 }
|
|
22
|
|
23 package abstract class QtdObject
|
|
24 {
|
|
25 protected QtdObjectFlags __flags_;
|
|
26 void* __nativeId;
|
|
27
|
|
28 this(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.none)
|
|
29 {
|
|
30 __nativeId = nativeId;
|
|
31 __flags_ = flags;
|
|
32 }
|
|
33
|
|
34 final QtdObjectFlags __flags()
|
|
35 {
|
|
36 return __flags_;
|
|
37 }
|
|
38
|
|
39 /+ final +/ void __setFlags(QtdObjectFlags flags, bool value)
|
|
40 {
|
|
41 if (value)
|
|
42 __flags_ |= flags;
|
|
43 else
|
|
44 __flags_ &= ~flags;
|
|
45 }
|
|
46
|
|
47 // COMPILER BUG: 3206
|
|
48 protected void __deleteNative()
|
|
49 {
|
|
50 assert(false);
|
|
51 }
|
|
52
|
|
53 ~this()
|
|
54 {
|
|
55 if (!(__flags_ & QtdObjectFlags.nativeOwnership))
|
|
56 {
|
|
57 // avoid deleting D object twice.
|
|
58 __flags_ |= QtdObjectFlags.dOwnership;
|
|
59 __deleteNative;
|
|
60 }
|
|
61 }
|
|
62 }
|