Changeset 386:7dddafad5a20
- Timestamp:
- 07/19/10 06:29:57
(3 years ago)
- Author:
- Max Samukha <maxter@spambox.com>
- branch:
- default
- Message:
shared stor fix
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r384 |
r386 |
|
| 11 | 11 | |
|---|
| 12 | 12 | QTD_EXTERN QTD_EXPORT void qtdInitCore() |
|---|
| 13 | | { |
|---|
| | 13 | { |
|---|
| 14 | 14 | QObjectLink::userDataId = QObject::registerUserData(); |
|---|
| 15 | 15 | } |
|---|
| r383 |
r386 |
|
| 1 | 1 | module qt.core.test.Objects; |
|---|
| 2 | | |
|---|
| 3 | | import std.stdio; |
|---|
| 4 | 2 | |
|---|
| 5 | 3 | // make sure QtdUnittest is defined |
|---|
| … | … | |
| 12 | 10 | qt.core.QObject, |
|---|
| 13 | 11 | qt.core.QMetaObject; |
|---|
| 14 | | |
|---|
| 15 | | import std.stdio; |
|---|
| 16 | 12 | |
|---|
| 17 | 13 | extern (C) void* qtd_test_QObject_create(void* parent); |
|---|
| … | … | |
| 98 | 94 | unittest |
|---|
| 99 | 95 | { |
|---|
| 100 | | writeln("Here"); |
|---|
| 101 | 96 | static void reset() |
|---|
| 102 | 97 | { |
|---|
| r384 |
r386 |
|
| 39 | 39 | extern(C) void qtdInitCore(); |
|---|
| 40 | 40 | |
|---|
| 41 | | static this() |
|---|
| | 41 | shared static this() |
|---|
| 42 | 42 | { |
|---|
| 43 | 43 | qtdInitCore(); |
|---|
| r383 |
r386 |
|
| 118 | 118 | Disables GC for this object; |
|---|
| 119 | 119 | */ |
|---|
| 120 | | // TODO: needs to be properly synchronized |
|---|
| 121 | 120 | final void qtdPin() const |
|---|
| 122 | 121 | { |
|---|
| … | … | |
| 151 | 150 | Enables GC for this object. |
|---|
| 152 | 151 | */ |
|---|
| 153 | | // TODO: needs to be properly synchronized |
|---|
| 154 | 152 | final void qtdUnpin() const |
|---|
| 155 | 153 | { |
|---|
| … | … | |
| 172 | 170 | Sets the ownership of this object. |
|---|
| 173 | 171 | Setting the same ownership twice results in undefined behavior. |
|---|
| 174 | | The function is not thread-safe. |
|---|
| 175 | 172 | */ |
|---|
| 176 | 173 | void qtdSetOwnership(QtdObjectOwnership own) const |
|---|
| … | … | |
| 187 | 184 | qtdPin(); |
|---|
| 188 | 185 | else |
|---|
| | 186 | { |
|---|
| | 187 | assert (!obj._flags.nativeDeleteDisabled); |
|---|
| 189 | 188 | obj._flags.nativeDeleteDisabled = true; |
|---|
| | 189 | } |
|---|
| 190 | 190 | } |
|---|
| 191 | 191 | else if (own == QtdObjectOwnership.d) |
|---|
| … | … | |
| 194 | 194 | qtdUnpin(); |
|---|
| 195 | 195 | else |
|---|
| | 196 | { |
|---|
| | 197 | assert(obj._flags.nativeDeleteDisabled); |
|---|
| 196 | 198 | obj._flags.nativeDeleteDisabled = false; |
|---|
| | 199 | } |
|---|
| 197 | 200 | } |
|---|
| 198 | 201 | else |
|---|
| … | … | |
| 200 | 203 | |
|---|
| 201 | 204 | mixin(debugHandler("onObjectOwnershipChanged", "obj")); |
|---|
| 202 | | } |
|---|
| 203 | | |
|---|
| | 205 | } |
|---|
| | 206 | |
|---|
| 204 | 207 | // COMPILER BUG: 3206 |
|---|
| 205 | 208 | protected void qtdDeleteNative() |
|---|
| … | … | |
| 228 | 231 | } |
|---|
| 229 | 232 | |
|---|
| | 233 | /* package */ abstract class PolymorphicObject : QtdObject |
|---|
| | 234 | { |
|---|
| | 235 | this(void* nativeId, QtdObjectInitFlags initFlags = QtdObjectInitFlags.none) |
|---|
| | 236 | { |
|---|
| | 237 | _flags.polymorphic = true; |
|---|
| | 238 | super(nativeId, initFlags); |
|---|
| | 239 | } |
|---|
| | 240 | |
|---|
| | 241 | abstract QtdMetaClass metaObject(); |
|---|
| | 242 | } |
|---|
| | 243 | |
|---|
| 230 | 244 | /** |
|---|
| 231 | 245 | Base class for polymorphic non-QObjects (TBD). |
|---|
| 232 | 246 | */ |
|---|
| 233 | | /* package */ abstract class NonQObject : QtdObject |
|---|
| | 247 | /* package */ abstract class NonQObject : PolymorphicObject |
|---|
| 234 | 248 | { |
|---|
| 235 | 249 | alias NonQObjectMetaClass Meta; |
|---|
| … | … | |
| 237 | 251 | this(void* nativeId, QtdObjectInitFlags initFlags) |
|---|
| 238 | 252 | { |
|---|
| 239 | | _flags.polymorphic = true; |
|---|
| 240 | 253 | super(nativeId, initFlags); |
|---|
| 241 | 254 | } |
|---|
| | 255 | |
|---|
| | 256 | override abstract Meta metaObject(); |
|---|
| 242 | 257 | } |
|---|
| 243 | 258 | |
|---|
| … | … | |
| 256 | 271 | /** |
|---|
| 257 | 272 | */ |
|---|
| 258 | | @property |
|---|
| 259 | | void* nativeId() |
|---|
| | 273 | @property void* nativeId() |
|---|
| 260 | 274 | { |
|---|
| 261 | 275 | return _nativeId; |
|---|
| … | … | |
| 313 | 327 | } |
|---|
| 314 | 328 | |
|---|
| 315 | | extern (C) bool qtdTypeInfosEqual(void* info1, void* info2); |
|---|
| | 329 | extern(C) bool qtdTypeInfosEqual(void* info1, void* info2); |
|---|
| 316 | 330 | |
|---|
| 317 | 331 | mixin(qtdExport("void", "QtdObject_delete", "void* dId", |
|---|
| r384 |
r386 |
|
| 918 | 918 | AbstractMetaFunctionList virtualFunctions = java_class->virtualFunctions(); |
|---|
| 919 | 919 | AbstractMetaFunction::Options opts(AbstractMetaFunction::DeclaringClass | AbstractMetaFunction::NoExternNamespace); |
|---|
| 920 | | for (int pos = 0; pos<virtualFunctions.size(); ++pos) { |
|---|
| 921 | | const AbstractMetaFunction *function = virtualFunctions.at(pos); |
|---|
| | 920 | |
|---|
| | 921 | size_t virtual_index = 0; |
|---|
| | 922 | foreach (const AbstractMetaFunction *function, virtualFunctions) { |
|---|
| 922 | 923 | if (!notWrappedYet(function) && java_class == function->declaringClass()) { // qtd2 |
|---|
| 923 | 924 | QString mName = function->marshalledName(opts); |
|---|
| 924 | 925 | s << " qtd_" << mName << "_dispatch = " |
|---|
| 925 | | "(qtd_" << mName << "_dispatch_t) virts[" << pos << "];" << endl; |
|---|
| | 926 | "(qtd_" << mName << "_dispatch_t) virts[" << virtual_index << "];" << endl; |
|---|
| | 927 | virtual_index++; |
|---|
| 926 | 928 | } |
|---|
| 927 | 929 | } |
|---|
| r384 |
r386 |
|
| 2074 | 2074 | } |
|---|
| 2075 | 2075 | */ |
|---|
| | 2076 | // only QObjects are handled polymorphically for now |
|---|
| 2076 | 2077 | if (d_class->isQObject()) |
|---|
| 2077 | | s << " : QtdObject"; |
|---|
| | 2078 | s << " : PolymorphicObject"; |
|---|
| 2078 | 2079 | else |
|---|
| 2079 | 2080 | s << " : QtdObject"; |
|---|
| … | … | |
| 2330 | 2331 | } |
|---|
| 2331 | 2332 | |
|---|
| 2332 | | // only QObjects are handled polymorphically for now |
|---|
| 2333 | | if (d_class->name() == "QObject" /* d_class->polymorphicBase() == d_class */) |
|---|
| 2334 | | s << INDENT << "_flags.polymorphic = true;" << endl; |
|---|
| 2335 | | |
|---|
| 2336 | 2333 | s << INDENT << "super(nativeId, initFlags);" << endl; |
|---|
| 2337 | 2334 | |
|---|
| … | … | |
| 2570 | 2567 | |
|---|
| 2571 | 2568 | // virtual functions |
|---|
| 2572 | | s << INDENT << "void*[" << virtualFunctions.size() << "] virt_arr;" << endl; |
|---|
| 2573 | | for (int pos = 0; pos<virtualFunctions.size(); ++pos) { |
|---|
| 2574 | | const AbstractMetaFunction *function = virtualFunctions.at(pos); |
|---|
| | 2569 | int virtuals_index = 0; |
|---|
| | 2570 | QString virtuals_init; |
|---|
| | 2571 | |
|---|
| | 2572 | foreach (const AbstractMetaFunction *function, virtualFunctions) { |
|---|
| 2575 | 2573 | if (!notWrappedYet(function) && d_class == function->declaringClass()) { |
|---|
| 2576 | 2574 | QString mName = function->marshalledName(opts); |
|---|
| 2577 | | s << INDENT << "virt_arr[" << pos << "] = &qtd_export_" << mName << "_dispatch;" <<endl; |
|---|
| | 2575 | virtuals_init += QString(" virt_arr[%1] = &qtd_export_%2_dispatch;\n").arg(virtuals_index).arg(mName); |
|---|
| | 2576 | virtuals_index++; |
|---|
| 2578 | 2577 | } |
|---|
| 2579 | 2578 | } |
|---|
| 2580 | 2579 | |
|---|
| 2581 | | if (virtualFunctions.size() == 0) |
|---|
| | 2580 | if (virtuals_index == 0) |
|---|
| 2582 | 2581 | initArgs = "null"; |
|---|
| 2583 | | else |
|---|
| | 2582 | else { |
|---|
| | 2583 | s << " void*[" << virtuals_index << "] virt_arr;" << endl; |
|---|
| | 2584 | s << virtuals_init; |
|---|
| 2584 | 2585 | initArgs = "virt_arr.ptr"; |
|---|
| | 2586 | } |
|---|
| 2585 | 2587 | |
|---|
| 2586 | 2588 | if (d_class->name() == "QObject") { |
|---|