annotate d1/qt/core/QMetaObject.d @ 311:8674fd5f34f4 lifetime

Added d1/d2 top directories
author maxter <spambox@d-coding.com>
date Wed, 23 Dec 2009 16:17:22 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
311
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
1 module qt.core.QMetaObject;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
2
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
3 import
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
4 qt.Core,
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
5 qt.core.QObject,
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
6 qt.QtdObject;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
7
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
8 /++
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
9 Meta-object for QObject classes.
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
10 +/
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
11 final class QMetaObject : QtdMetaObjectBase
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
12 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
13 alias typeof(this) This;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
14
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
15 this(void* nativeId, QtdMetaObjectBase base, CreateWrapper createWrapper)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
16 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
17 super(nativeId, base, createWrapper);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
18 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
19
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
20 private QMetaObject lookupDerived(void*[] moIds)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
21 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
22 assert (moIds.length >= 1);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
23
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
24 for (auto mo = static_cast!(This)(firstDerived); mo !is null; mo = static_cast!(This)(mo.next))
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
25 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
26 if (mo.nativeId == moIds[0])
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
27 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
28 if (moIds.length == 1) // exact match found
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
29 return mo;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
30 else // look deeper
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
31 return mo.lookupDerived(moIds[1..$]);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
32 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
33 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
34
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
35 // no initialized wrapper that matches the native object.
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
36 // use the base class wrapper
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
37 return this;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
38 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
39
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
40 QObject wrap(void* nativeObjId, QtdObjectFlags flags = QtdObjectFlags.none)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
41 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
42 QObject result;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
43
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
44 if (nativeObjId)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
45 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
46 result = cast(QObject)qtd_get_d_qobject(nativeObjId);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
47 if (!result)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
48 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
49 auto moId = qtd_QObject_typeId(nativeObjId);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
50 if (nativeId == moId)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
51 result = static_cast!(QObject)(_createWrapper(nativeObjId, flags));
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
52 else
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
53 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
54 // get native metaobjects for the entire derivation lattice
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
55 // up to, but not including, the current metaobject.
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
56 size_t moCount = 1;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
57
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
58 for (void* tmp = moId;;)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
59 {
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
60 tmp = qtd_QMetaObject_superClass(tmp);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
61 if (!tmp)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
62 return null;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
63
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
64 if (tmp == nativeId)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
65 break;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
66 moCount++;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
67 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
68
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
69 void*[] moIds = (cast(void**)alloca(moCount * (void*).sizeof))[0..moCount];
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
70
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
71 moIds[--moCount] = moId;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
72 while (moCount > 0)
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
73 moIds[--moCount] = moId = qtd_QMetaObject_superClass(moId);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
74
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
75 auto mo = lookupDerived(moIds);
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
76 result = static_cast!(QObject)(mo._createWrapper(nativeObjId, flags));
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
77 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
78 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
79 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
80
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
81 return result;
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
82 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
83 }
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
84
8674fd5f34f4 Added d1/d2 top directories
maxter <spambox@d-coding.com>
parents:
diff changeset
85 extern(C) void* qtd_QMetaObject_superClass(void* nativeId);