comparison generator/typesystem_core-java.java @ 253:073b9153ed8a

Rev. 264 done right. Problems: - classwizard segfaults on exit due to a bug in signals/slots or runtime. - hellogl doesn't compile with dmd2 due to a bug in the compiler backend
author maxter
date Sun, 30 Aug 2009 09:59:12 +0000
parents 37eed70de029
children 17b5e13364b7 f9559a957be9
comparison
equal deleted inserted replaced
252:37eed70de029 253:073b9153ed8a
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 override void onSignalHandlerCreated(ref SignalHandler sh)
80 public bool __no_real_delete = false; 84 {
85 sh.signalEvent = &onSignalEvent;
86 }
87
88 private void onSignalEvent(int signalId, SignalEventId event)
89 {
90 stringz signature;
91 signalSignature(signalId, signature);
92 if (signature)
93 {
94 switch (event)
95 {
96 case SignalEventId.firstSlotConnected:
97 qtd_connect(__nativeId, signature, signalId, cast(bool)(__flags_ & QtdObjectFlags.dynamicEntity));
98 break;
99 case SignalEventId.lastSlotDisconnected:
100 qtd_disconnect(__nativeId, signature, signalId, cast(bool)(__flags_ & QtdObjectFlags.dynamicEntity));
101 break;
102 default:
103 assert (false);
104 }
105 }
106 }
107
108 ~this()
109 {
110 if (__prev)
111 __prev.__next = __next;
112 else
113 __root = __next;
114
115 if (__next)
116 __next.__prev = __prev;
117 }
118
119 /**
120 */
121 T findChild(T : QObject = QObject)(string name = null)
122 {
123 foreach (obj; children)
124 {
125 auto tmp = cast(T)obj;
126 if (tmp && (!name.length || tmp.objectName == name))
127 return tmp;
128
129 tmp = obj.findChild!(T)(name);
130 if (tmp)
131 return tmp;
132 }
133
134 return null;
135 }
136
137 /**
138 */
139 T[] findChildren(T : QObject = QObject)(string name = null)
140 {
141 T[] result;
142
143 void find(QObject[] objects)
144 {
145 foreach (obj; objects)
146 {
147 auto tmp = cast(T)obj;
148 if (tmp && (!name.length || tmp.objectName == name))
149 result ~= tmp;
150 find(obj.children);
151 }
152 }
153
154 find(children);
155 return result;
156 }
81 }// class 157 }// class
82 158
83 abstract class QAbstractItemModel___ extends QAbstractItemModel { 159 abstract class QAbstractItemModel___ extends QAbstractItemModel {
84 /* private native boolean setData_native(long id, int row, int col, Object value, int role); 160 /* private native boolean setData_native(long id, int row, int col, Object value, int role);
85 161
139 215
140 this(string[] args) 216 this(string[] args)
141 { 217 {
142 // if (m_instance != null) 218 // if (m_instance != null)
143 // throw new RuntimeException("QCoreApplication can only be initialized once"); 219 // throw new RuntimeException("QCoreApplication can only be initialized once");
144 220
145 argc = args.length; 221 argc = args.length;
146 argv = toStringzArray(args); 222 argv = toStringzArray(args);
147 this(&argc, argv); 223 this(&argc, argv);
148 224
149 // m_instance.aboutToQuit.connect(m_instance, "disposeOfMyself()"); 225 // m_instance.aboutToQuit.connect(m_instance, "disposeOfMyself()");
150 } 226 }
151 227
152 private int argc; 228 private int argc;
153 private char **argv; 229 private char **argv;
154 /* 230 /*
155 public static string translate(string context, string key, string disambiguation, QCoreApplication_Encoding encoding) { 231 public static string translate(string context, string key, string disambiguation, QCoreApplication_Encoding encoding) {
156 string res; 232 string res;
487 } 563 }
488 */ 564 */
489 565
490 public final long write(string str) { 566 public final long write(string str) {
491 return write(str.ptr, str.length); 567 return write(str.ptr, str.length);
492 } 568 }
493 }// class 569 }// class
494 570
495 class QCryptographicHash___ extends QCryptographicHash { 571 class QCryptographicHash___ extends QCryptographicHash {
496 572
497 public final void addData(byte data[]) { 573 public final void addData(byte data[]) {