diff generator/dgenerator.cpp @ 295:463563fc9e17 signals

more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
author eldar
date Sun, 22 Nov 2009 11:01:19 +0000
parents bb37b0ed94c9
children bc783e20da2b
line wrap: on
line diff
--- a/generator/dgenerator.cpp	Fri Nov 13 20:42:51 2009 +0000
+++ b/generator/dgenerator.cpp	Sun Nov 22 11:01:19 2009 +0000
@@ -882,7 +882,7 @@
 
     // return value marschalling
     if(return_type) {
-        if (!returnImmediately && !d_function->storeResult()) {
+        if (!returnImmediately) {
             s << INDENT;
             QString modified_type = d_function->typeReplaced(0);
             if (modified_type.isEmpty())
@@ -908,12 +908,7 @@
             s << "new " << return_type->name() << "(ret, QtdObjectFlags.nativeOwnership);" << endl;
 
         if (return_type->isObject()) {
-            if(d_function->storeResult())
-                s << INDENT << QString("__m_%1.__nativeId = ret;").arg(d_function->name()) << endl
-                  << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl;
-            else
-                s << "qtd_" << return_type->name() << "_from_ptr(ret);" << endl;
-            s << endl;
+            s << "qtd_" << return_type->name() << "_from_ptr(ret);" << endl << endl;
         }
 
         if (return_type->isArray()) {
@@ -924,7 +919,7 @@
             writeReferenceCount(s, referenceCount, "__d_return_value");
         }
 
-        if (!returnImmediately && !d_function->storeResult())
+        if (!returnImmediately)
             s << INDENT << "return __d_return_value;" << endl;
     }
     writeInjectedCode(s, d_function, CodeSnip::End);
@@ -988,6 +983,9 @@
     writeFunctionArguments(s, d_function, argument_count, option);
     s << ")";
 
+    if(d_function->isConstant())
+        s << " const";
+
     return result;
 }
 
@@ -2307,31 +2305,6 @@
         }
         */
 
-        // customized store-result instances
-        d_funcs = d_class->functionsInTargetLang();
-        for (int i=0; i<d_funcs.size(); ++i) {
-            AbstractMetaFunction *d_function = d_funcs.at(i);
-            uint included_attributes = 0;
-            uint excluded_attributes = 0;
-            setupForFunction(d_function, &included_attributes, &excluded_attributes);
-            uint attr = d_function->attributes() & (~excluded_attributes) | included_attributes;
-            bool isStatic = (attr & AbstractMetaAttributes::Static);
-
-            if (!isStatic && (attr & AbstractMetaAttributes::Abstract))
-                continue;
-
-            if(d_function->storeResult()) {
-                QString type_name = d_function->type()->name();
-                const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry());
-                if(ctype->isAbstract())
-                    type_name = type_name + "_ConcreteWrapper";
-
-                s << INDENT << "    __m_" << d_function->name() << " = new "
-                        << type_name << "(cast(void*)null);" << endl;
-                if (d_function->type()->isQObject())
-                    s << INDENT << "    __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl;
-            }
-        }
 
         // pointers to native interface objects for classes that implement interfaces
         // initializing
@@ -2348,29 +2321,6 @@
 
         s << INDENT << "}" << endl << endl;
 
-/******************!!!DUPLICATE OF ABOVE!!!*********************/
-        for (int i=0; i<d_funcs.size(); ++i) {
-            AbstractMetaFunction *d_function = d_funcs.at(i);
-            uint included_attributes = 0;
-            uint excluded_attributes = 0;
-            setupForFunction(d_function, &included_attributes, &excluded_attributes);
-            uint attr = d_function->attributes() & (~excluded_attributes) | included_attributes;
-            bool isStatic = (attr & AbstractMetaAttributes::Static);
-
-            if (!isStatic && (attr & AbstractMetaAttributes::Abstract))
-                continue;
-
-            if(d_function->storeResult()) {
-                QString type_name = d_function->type()->name();
-                const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry());
-                if(ctype->isAbstract())
-                    type_name = type_name + "_ConcreteWrapper";
-
-                s << INDENT << type_name << " __m_" << d_function->name() << ";" << endl;
-            }
-        }
-/***************************************************************/
-
         // pointers to native interface objects for classes that implement interfaces
         // initializing
         interfaces = d_class->interfaces();
@@ -2459,54 +2409,8 @@
             s << INDENT << "public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.nativeOwnership) {" << endl
               << INDENT << "    super(native_id, flags);" << endl << endl;
             
-            /******************!!!DUPLICATE!!!*********************/
-            d_funcs = d_class->functionsInTargetLang();
-            for (int i=0; i<d_funcs.size(); ++i) {
-                AbstractMetaFunction *d_function = d_funcs.at(i);
-                uint included_attributes = 0;
-                uint excluded_attributes = 0;
-                setupForFunction(d_function, &included_attributes, &excluded_attributes);
-                uint attr = d_function->attributes() & (~excluded_attributes) | included_attributes;
-// qtd                bool isStatic = (attr & AbstractMetaAttributes::Static);
-
-                if(d_function->storeResult()) {
-                    QString type_name = d_function->type()->name();
-                    const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry());
-                    if(ctype->isAbstract())
-                        type_name = type_name + "_ConcreteWrapper";
-                    s << INDENT << "    __m_" << d_function->name() << " = new "
-                            << type_name << "(cast(void*)null);" << endl;
-                    if (d_function->type()->isQObject())
-                        s << INDENT << "    __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl;
-                }
-            }
-
             s << INDENT << "}" << endl << endl;
 
-            for (int i=0; i<d_funcs.size(); ++i) {
-                AbstractMetaFunction *d_function = d_funcs.at(i);
-                uint included_attributes = 0;
-                uint excluded_attributes = 0;
-                setupForFunction(d_function, &included_attributes, &excluded_attributes);
-                uint attr = d_function->attributes() & (~excluded_attributes) | included_attributes;
-// qtd                bool isStatic = (attr & AbstractMetaAttributes::Static);
-
-                if(d_function->storeResult()) {
-                    QString type_name = d_function->type()->name();
-                    const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(d_function->type()->typeEntry());
-                    if(ctype->isAbstract())
-                        type_name = type_name + "_ConcreteWrapper";
-
-                    s << INDENT << d_function->type()->name() << " __m_" << d_function->name() << ";" << endl;
-                }
-            }
-            /***************************************************************/
-
-
-
-
-
-
             uint exclude_attributes = AbstractMetaAttributes::Native | AbstractMetaAttributes::Abstract;
             uint include_attributes = 0;
             AbstractMetaFunctionList functions = d_class->queryFunctions(AbstractMetaClass::NormalFunctions | AbstractMetaClass::AbstractFunctions | AbstractMetaClass::NonEmptyFunctions | AbstractMetaClass::NotRemovedFromTargetLang);
@@ -2514,14 +2418,19 @@
                 retrieveModifications(d_function, d_class, &exclude_attributes, &include_attributes);
                 if (notWrappedYet(d_function))
                     continue;
-                /* qtd                s << endl
-                  << INDENT << "@Override" << endl; */
+                s << endl
+                  << INDENT << "override ";
                 writeFunctionAttributes(s, d_function, include_attributes, exclude_attributes,
                                         d_function->isNormal() || d_function->isSignal() ? 0 : SkipReturnType);
 
                 s << d_function->name() << "(";
                 writeFunctionArguments(s, d_function, d_function->arguments().count());
-                s << ") {" << endl;
+                s << ")";
+
+                if(d_function->isConstant())
+                    s << " const";
+
+                s << " {" << endl;
                 {
                     Indentation indent(INDENT);
                     writeJavaCallThroughContents(s, d_function, SuperCall);
@@ -3198,8 +3107,6 @@
             ctype_child->addedTo = cls->name();
         }
 
-        foreach (AbstractMetaFunction *function, cls->functions())
-            function->checkStoreResult();
 /* we don't need this anymore
         // generate QObject conversion functions only those that are required
         AbstractMetaFunctionList d_funcs = cls->functionsInTargetLang();