changeset 111:2a85b786fa3a

same thing for Objects
author eldar
date Mon, 01 Jun 2009 23:46:16 +0000
parents 136c9ee83ee5
children e416c5215366
files generator/dgenerator.cpp qt/QGlobal.d
diffstat 2 files changed, 10 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/generator/dgenerator.cpp	Mon Jun 01 23:32:57 2009 +0000
+++ b/generator/dgenerator.cpp	Mon Jun 01 23:46:16 2009 +0000
@@ -866,7 +866,8 @@
                 s << INDENT << QString("__m_%1.nativeId = __qt_return_value;").arg(d_function->name()) << endl
                         << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl;
             else {
-                QString type_name = return_type->name();
+                s << INDENT << "return qtd_" << return_type->name() << "_from_ptr(__qt_return_value);" << endl;
+/*                QString type_name = return_type->name();
                 const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(return_type->typeEntry());
                 if(ctype->isAbstract())
                     type_name = type_name + "_ConcreteWrapper";
@@ -894,7 +895,7 @@
                     s << INDENT << "auto return_value = new " << type_name << "(__qt_return_value, true);" << endl
                             << INDENT << "return_value.__no_real_delete = true;" << endl
                             << INDENT << "return return_value;" << endl;
-                }
+                }*/
             }
             s << endl;
         }
@@ -2600,9 +2601,12 @@
 {
     const ComplexTypeEntry *ctype = d_class->typeEntry();
     QString class_name = ctype->name();
+    QString return_type_name = class_name;
+    if(ctype->designatedInterface())
+        return_type_name = ctype->designatedInterface()->name();
+    s << return_type_name << " qtd_" << class_name << "_from_ptr(void* __qt_return_value) {" << endl;
 
     if(ctype->isQObject()) {
-s << class_name << " qtd_" << class_name << "_from_ptr(void* __qt_return_value) {" << endl;
         QString type_name = class_name;
         if(ctype->isAbstract())
             type_name = type_name + "_ConcreteWrapper";
@@ -2617,17 +2621,11 @@
           << INDENT << "    return new_obj;" << endl
           << INDENT << "} else" << endl
           << INDENT << "    return cast(" << class_name << ") d_obj;" << endl;
-s << "}" << endl << endl;
-
-    } /* else if (ctype->isObject()) {
+    } else if (ctype->isObject()) {
         QString type_name = class_name;
         if(ctype->isAbstract())
             type_name = type_name + "_ConcreteWrapper";
 
-        QString return_type_name = ctype->name();
-        if(ctype->designatedInterface())
-            return_type_name = ctype->designatedInterface()->name();
-
         // if class has virtual functions then it has classname_entity function so
         // we can look for D Object pointer. otherwise create new wrapper
         if (d_class->hasVirtualFunctions()) {
@@ -2645,7 +2643,8 @@
               << INDENT << "return_value.__no_real_delete = true;" << endl
               << INDENT << "return return_value;" << endl;
         }
-    }*/
+    }
+    s << "}" << endl << endl;
 }
 
 
--- a/qt/QGlobal.d	Mon Jun 01 23:32:57 2009 +0000
+++ b/qt/QGlobal.d	Mon Jun 01 23:46:16 2009 +0000
@@ -582,18 +582,5 @@
 const ushort QT_EDITION_EDUCATIONAL = QT_EDITION_DESKTOP;
 const ushort QT_EDITION_EVALUATION =  QT_EDITION_DESKTOP;
 
-T qObjectFromPtr(T)(void *__qt_return_value) {
-    if (__qt_return_value is null)
-        return null;
-    mixin("void* d_obj = qtd_" ~ T.stringof ~ "_d_pointer(__qt_return_value);");
-    if (d_obj is null) {
-        T new_obj = new T(__qt_return_value, true);
-        mixin("qtd_" ~ T.stringof ~ "_create_link(new_obj.nativeId, cast(void*) new_obj);");
-        new_obj.__no_real_delete = true;
-        return new_obj;
-    } else
-        return cast(T) d_obj;
-}
-
 mixin QT_END_NAMESPACE;
 mixin QT_END_HEADER;