Mercurial > projects > qtd
comparison generator/typesystem_core-java.java @ 248:7664de4a55e5
Fixed #23.
QtD_QObjectEntity is not created dynamically for shell classes any more.
Class initialization is now performed by static constructors.
When wrapping QObjects returned from functions, their run-time types are now taken into account.
QObjects are allocated on GC heap, a doubly-linked list is used to prevent them from been collected (arguably a better solution than allocating on C heap and adding GC ranges)
Minor changes (including unnecessary).
author | maxter |
---|---|
date | Thu, 20 Aug 2009 14:47:17 +0000 |
parents | 7dd099050621 |
children | 37eed70de029 |
comparison
equal
deleted
inserted
replaced
247:27497bbe62a1 | 248:7664de4a55e5 |
---|---|
20 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and | 20 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and |
21 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special | 21 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special |
22 * exception, Nokia gives you certain additional rights. These rights | 22 * exception, Nokia gives you certain additional rights. These rights |
23 * are described in the Nokia Qt GPL Exception version 1.2, included in | 23 * are described in the Nokia Qt GPL Exception version 1.2, included in |
24 * the file GPL_EXCEPTION.txt in this package. | 24 * the file GPL_EXCEPTION.txt in this package. |
25 * | 25 * |
26 * Qt for Windows(R) Licensees | 26 * Qt for Windows(R) Licensees |
27 * As a special exception, Nokia, as the sole copyright holder for Qt | 27 * As a special exception, Nokia, as the sole copyright holder for Qt |
28 * Designer, grants users of the Qt/Eclipse Integration plug-in the | 28 * Designer, grants users of the Qt/Eclipse Integration plug-in the |
29 * right for the Qt/Eclipse Integration to link to functionality | 29 * right for the Qt/Eclipse Integration to link to functionality |
30 * provided by Qt Designer and its related libraries. | 30 * provided by Qt Designer and its related libraries. |
44 import qt.*; | 44 import qt.*; |
45 import qt.core.*; | 45 import qt.core.*; |
46 | 46 |
47 class QObject___ extends QObject { | 47 class QObject___ extends QObject { |
48 | 48 |
49 /* TODO: test whether the linked list is really a better solution | |
49 public bool __stackAllocated = false; | 50 public bool __stackAllocated = false; |
50 | |
51 public bool __qobject_is_deleting = false; | |
52 | 51 |
53 new(size_t size, void* p = null) | 52 new(size_t size, void* p = null) |
54 { | 53 { |
55 if (!p) | 54 if (!p) |
56 { | 55 { |
70 free(p); | 69 free(p); |
71 GC.removeRange(p); | 70 GC.removeRange(p); |
72 } | 71 } |
73 } | 72 } |
74 } | 73 } |
74 */ | |
75 | 75 |
76 // list of QObjects references to prevent them from garbage collecting if they are managed by Qt | 76 private |
77 private static QObject[] __gc_ref_list; | 77 { |
78 static QObject __root; | |
79 QObject __next; | |
80 QObject __prev; | |
81 } | |
78 | 82 |
79 // this flag needs to be set false when QObject is deleted from inside Qt so when deleting it from D it won't delete C++ object | 83 ~this() |
80 public bool __no_real_delete = false; | 84 { |
85 if (__prev) | |
86 __prev.__next = __next; | |
87 else | |
88 __root = __next; | |
89 | |
90 if (__next) | |
91 __next.__prev = __prev; | |
92 } | |
93 | |
94 /** | |
95 */ | |
96 T findChild(T : QObject = QObject)(string name = null) | |
97 { | |
98 foreach (obj; children) | |
99 { | |
100 auto tmp = cast(T)obj; | |
101 if (tmp && (!name.length || tmp.objectName == name)) | |
102 return tmp; | |
103 | |
104 tmp = obj.findChild!(T)(name); | |
105 if (tmp) | |
106 return tmp; | |
107 } | |
108 | |
109 return null; | |
110 } | |
111 | |
112 /** | |
113 */ | |
114 T[] findChildren(T : QObject = QObject)(string name = null) | |
115 { | |
116 T[] result; | |
117 | |
118 void find(QObject[] objects) | |
119 { | |
120 foreach (obj; objects) | |
121 { | |
122 auto tmp = cast(T)obj; | |
123 if (tmp && (!name.length || tmp.objectName == name)) | |
124 result ~= tmp; | |
125 find(obj.children); | |
126 } | |
127 } | |
128 | |
129 find(children); | |
130 return result; | |
131 } | |
81 }// class | 132 }// class |
82 | 133 |
83 abstract class QAbstractItemModel___ extends QAbstractItemModel { | 134 abstract class QAbstractItemModel___ extends QAbstractItemModel { |
84 /* private native boolean setData_native(long id, int row, int col, Object value, int role); | 135 /* private native boolean setData_native(long id, int row, int col, Object value, int role); |
85 | 136 |
139 | 190 |
140 this(string[] args) | 191 this(string[] args) |
141 { | 192 { |
142 // if (m_instance != null) | 193 // if (m_instance != null) |
143 // throw new RuntimeException("QCoreApplication can only be initialized once"); | 194 // throw new RuntimeException("QCoreApplication can only be initialized once"); |
144 | 195 |
145 argc = args.length; | 196 argc = args.length; |
146 argv = toStringzArray(args); | 197 argv = toStringzArray(args); |
147 this(&argc, argv); | 198 this(&argc, argv); |
148 | 199 |
149 // m_instance.aboutToQuit.connect(m_instance, "disposeOfMyself()"); | 200 // m_instance.aboutToQuit.connect(m_instance, "disposeOfMyself()"); |
150 } | 201 } |
151 | 202 |
152 private int argc; | 203 private int argc; |
153 private char **argv; | 204 private char **argv; |
154 /* | 205 /* |
155 public static string translate(string context, string key, string disambiguation, QCoreApplication_Encoding encoding) { | 206 public static string translate(string context, string key, string disambiguation, QCoreApplication_Encoding encoding) { |
156 string res; | 207 string res; |
487 } | 538 } |
488 */ | 539 */ |
489 | 540 |
490 public final long write(string str) { | 541 public final long write(string str) { |
491 return write(str.ptr, str.length); | 542 return write(str.ptr, str.length); |
492 } | 543 } |
493 }// class | 544 }// class |
494 | 545 |
495 class QCryptographicHash___ extends QCryptographicHash { | 546 class QCryptographicHash___ extends QCryptographicHash { |
496 | 547 |
497 public final void addData(byte data[]) { | 548 public final void addData(byte data[]) { |