Mercurial > projects > qtd
changeset 294:bb37b0ed94c9 signals
some more QList
author | eldar |
---|---|
date | Fri, 13 Nov 2009 20:42:51 +0000 |
parents | 8627891e4556 |
children | 463563fc9e17 |
files | generator/cppimplgenerator.cpp generator/dgenerator.cpp qt/core/QList.d qt/core/QTypeInfo.d |
diffstat | 4 files changed, 32 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/generator/cppimplgenerator.cpp Fri Nov 13 19:09:28 2009 +0000 +++ b/generator/cppimplgenerator.cpp Fri Nov 13 20:42:51 2009 +0000 @@ -2344,12 +2344,14 @@ { if (cls->hasConstructors()) { s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_destructor(void *ptr)" << endl - << INDENT << "{" << endl; - { - s << INDENT << "delete (" << shellClassName(cls) << " *)ptr;" << endl; - } - - s << INDENT << "}" << endl << endl; + << INDENT << "{" << endl + << INDENT << " delete (" << shellClassName(cls) << " *)ptr;" << endl + << INDENT << "}" << endl << endl; + + s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_call_destructor(" << shellClassName(cls) << " *ptr)" << endl + << INDENT << "{" << endl + << INDENT << QString (" ptr->~%1();").arg(shellClassName(cls)) << endl + << INDENT << "}" << endl << endl; } }
--- a/generator/dgenerator.cpp Fri Nov 13 19:09:28 2009 +0000 +++ b/generator/dgenerator.cpp Fri Nov 13 20:42:51 2009 +0000 @@ -1694,6 +1694,20 @@ } s << INDENT << "}" << endl << endl; } + + if (d_class->typeEntry()->isValue()) + { + s << INDENT << "public static void __deleteNativeObject(void* ptr) {" << endl + << INDENT << " qtd_" << d_class->name() << "_destructor(ptr);" << endl + << INDENT << "}" << endl << endl; + } + + if (d_class->typeEntry()->isValue()) + { + s << INDENT << "public static void __callNativeDestructor(void* ptr) {" << endl + << INDENT << " qtd_" << d_class->name() << "_call_destructor(ptr);" << endl + << INDENT << "}" << endl << endl; + } } void DGenerator::writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class) @@ -2535,7 +2549,8 @@ writeConversionFunction(s, d_class); if (d_class->hasConstructors() && !d_class->isQObject()) - s << "extern (C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl << endl; + s << "extern (C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl + << "extern (C) void qtd_" << d_class->name() << "_call_destructor(void *ptr);" << endl << endl; // qtd
--- a/qt/core/QList.d Fri Nov 13 19:09:28 2009 +0000 +++ b/qt/core/QList.d Fri Nov 13 20:42:51 2009 +0000 @@ -429,11 +429,11 @@ static if (isValueType!T) { if (isLarge!T() || isStatic!T()) // TODO should be static if - n.v = T.__constructNativeCopy(t.__nativeId); + n.v = T.__constructNativeCopy(t.__nativeId); // n.v = new T(t); else if (isComplex!T()) - T.__constructPlacedNativeCopy(t.__nativeId, n); + T.__constructPlacedNativeCopy(t.__nativeId, n); // new (n) T(t); else - T.__constructPlacedNativeCopy(t.__nativeId, n); // TODO should be *cast(T*)(n) = cast(T)(t); as it is a primitive type. not until they are implemented with structs + T.__constructPlacedNativeCopy(t.__nativeId, n); // TODO should be *cast(T*)(n) = cast(T)(t); as it is a primitive type. fix when they are implemented with structs } else // in case of QObject or Object Qt types we place a pointer to a native object in the node n = cast(Node*) t.__nativeId; @@ -451,6 +451,7 @@ void node_copy(Node *from, Node *to, Node *src) { + writeln("QList node_copy"); /* TODO if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) while(from != to) (from++)->v = new T(*reinterpret_cast<T*>((src++)->v)); @@ -477,9 +478,10 @@ { if (isLarge!T() || isStatic!T()) // TODO should be static if while (from != to) - --to, delete cast(T*)(to->v); - else if (QTypeInfo!T.isComplex) - while (from != to) --to, cast(T*)(to).~T(); + --to, T.__deleteNativeObject(to.v); + else if (isComplex!T()) + while (from != to) + --to, T.__callNativeDestructor(to); } else { /*