[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kjsembed
From:       Erik Lloyd Bunce <kde () bunce ! us>
Date:       2006-10-01 21:56:08
Message-ID: 1159739768.279962.19254.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 591162 by bunce:

Improve autobind indentation.  Document new autobind functions.

 M  +37 -16    autobind/values/generatebinding.js  
 M  +21 -21    kjsembed/QBrush_bind.cpp  


--- trunk/KDE/kdelibs/kjsembed/autobind/values/generatebinding.js #591161:591162
@@ -239,10 +239,16 @@
     else {
         enums = 'const Enumerator KJSEmbed::' + compoundData + '::p_enums[] = {{0, 0 \
}};\n';  }
-
+ 
     return enums;
 }
 
+// function find_method_overloads(memberList, startIdx, name)
+//   memberList - The DOM list of all memberdef XML elements.
+//   startIdx   - The index to start searching for dups at.
+//   name       - The name of the method overloads to search for.
+// Finds all the method overloads named name in the memberList starting at 
+// startIdx
 function find_method_overloads(memberList, startIdx, name)
 {
     var overloadList = new Array;
@@ -254,6 +260,7 @@
         var memberKind = memberElement.attribute('kind');
         var memberProt = memberElement.attribute('prot');
         var memberName = \
memberElement.firstChildElement('name').toElement().toString(); +
         if ( ( memberKind == 'function' ) && // Make sure we're working with a \
function here  ( memberProt == 'public' ) &&
              ( memberName.indexOf('operator') == -1 ) && // Make sure this is not an \
operator. @@ -274,6 +281,16 @@
     return overloadList;
 }
 
+// function write_method(compoundName, memberName, overloadList, compoundEnums)
+//   compoundName  - The name of the compound object
+//   memberName    - The name of the method/member being processed.
+//   overloadList  - An array of arrays of method overloads, with outter
+//                   array indexed by parameter count, and the inner ones
+//                   containg the member elements of the members with that 
+//                   parameter count.
+//   compoundEnums - An associative array of enums defined within the 
+//                   compound object.
+// Generates the code to handle all the overloads of an individual method
 function write_method(compoundName, memberName, overloadList, compoundEnums)
 {
     // Handle arguments
@@ -297,12 +314,17 @@
         if (!overloadList[idx])
             continue;
 
-        println( '      writing method with ' + idx + ' args, overrides = ' + \
overloadList[idx].length );  
         var memberElement = overloadList[idx][0];
         var methodType = \
memberElement.firstChildElement('type').toElement().toString();  var coreMethodType = \
findCoreParamType(methodType);  var methodArgList = \
memberElement.elementsByTagName('param'); +        var indent = '';
+        if (methodArgList.count() != 0)
+            indent = '    ';
+
+        println( '      writing method with ' + idx + ' args, overrides = ' + \
overloadList[idx].length + '"' + indent + '"'); +
         method += '    if (args.size() == ' + methodArgList.count() + ' )\n' +
         '    {\n';
 
@@ -326,23 +348,23 @@
                 methodType + ' tmp = value.' + memberName + '(';
             if ( coreMethodType.indexOf('Qt::') != -1 ) // Enum Value
             {
-                funcCallEnd += 
-                    '            result = KJS::Number( tmp );\n';
+                funcCallEnd += indent +
+                    '        result = KJS::Number( tmp );\n';
             }
             else if (isVariant(coreMethodType))
             {
-                funcCallEnd +=
-                    "            result = KJSEmbed::createVariant( exec, \"" + \
coreMethodType + "\", tmp );\n"; +                funcCallEnd += indent +
+                    '        result = KJSEmbed::createVariant( exec, "' + \
coreMethodType + '", tmp );\n';  }
             else
             {
-                funcCallEnd +=
-                    "            result = KJSEmbed::createObject( exec, \"" + \
coreMethodType + "\", tmp );\n"; +                funcCallEnd += indent +
+                    '        result = KJSEmbed::createValue( exec, "' + \
coreMethodType + '", tmp );\n';  }
         }
         funcCallEnd += 
-            '            imp->setValue(qVariantFromValue(value)); \n' +
-            '            return result; \n';
+            indent + '        imp->setValue(qVariantFromValue(value)); \n' +
+            indent + '        return result; \n';
 
         if (methodArgList.count() != 0)
         {
@@ -367,7 +389,7 @@
         }
         else
         {
-            method += '            ' + funcCallStart + funcCallEnd;
+            method += '        ' + funcCallStart + funcCallEnd;
         }
 
         method += 
@@ -382,14 +404,13 @@
     return method;
 }
 
-// function write_enums(compoundName, compoundData, memberList, compoundEnums)
+// function write_methods(compoundName, memberList, compoundEnums)
 //   compoundName  - The name of the compound object
-//   compoundData  - The data object to use for the compound object
 //   compoundDef   - The base element of the compound objects definition
 //   compoundEnums - An associative array of enums defined within the 
 //                   compound object.
-// Constructs and fills out the enums
-function write_methods(compoundName, compoundData, memberList, compoundEnums)
+// Iterates over and generates all the method implementations
+function write_methods(compoundName, memberList, compoundEnums)
 {
     var methods = 'namespace ' + compoundName + 'NS\n' +
         '{\n';
@@ -605,7 +626,7 @@
 
     var enums = write_enums(compoundName, compoundData, memberList, compoundEnums);
 
-    var methods = write_methods(compoundName, compoundData, memberList, \
compoundEnums); +    var methods = write_methods(compoundName, memberList, \
compoundEnums);  
     // Statics
     statics += 'NO_STATICS( KJSEmbed::' + compoundData + ' )';
--- trunk/KDE/kdelibs/kjsembed/kjsembed/QBrush_bind.cpp #591161:591162
@@ -5,6 +5,7 @@
 
 
 using namespace KJSEmbed;
+
 // Temp - for building
 class QColorBinding { public: static const KJS::ClassInfo info; };
 class QPixmapBinding { public: static const KJS::ClassInfo info; };
@@ -14,7 +15,6 @@
 const KJS::ClassInfo QPixmapBinding::info = { "QPixmap", &VariantBinding::info, 0, 0 \
};  const KJS::ClassInfo QGradientBinding::info = { "QGradient", \
&ObjectBinding::info, 0, 0 };  
-
 const KJS::ClassInfo QBrushBinding::info = { "QBrush", &VariantBinding::info, 0, 0 \
};  QBrushBinding::QBrushBinding( KJS::ExecState *exec, const QBrush &value )
    : VariantBinding(exec, value)
@@ -38,10 +38,10 @@
     QBrush value = imp->value<QBrush>();
     if (args.size() == 0 )
     {
-            Qt::BrushStyle tmp = value.style();
-            result = KJS::Number( tmp );
-            imp->setValue(qVariantFromValue(value)); 
-            return result; 
+        Qt::BrushStyle tmp = value.style();
+        result = KJS::Number( tmp );
+        imp->setValue(qVariantFromValue(value)); 
+        return result; 
     }
 
     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list \
for QBrush.style");  @@ -85,10 +85,10 @@
     QBrush value = imp->value<QBrush>();
     if (args.size() == 0 )
     {
-            QPixmap tmp = value.texture();
-            result = KJSEmbed::createVariant( exec, "QPixmap", tmp );
-            imp->setValue(qVariantFromValue(value)); 
-            return result; 
+        QPixmap tmp = value.texture();
+        result = KJSEmbed::createVariant( exec, "QPixmap", tmp );
+        imp->setValue(qVariantFromValue(value)); 
+        return result; 
     }
 
     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list \
for QBrush.texture");  @@ -132,10 +132,10 @@
     QBrush value = imp->value<QBrush>();
     if (args.size() == 0 )
     {
-            const QColor & tmp = value.color();
-            result = KJSEmbed::createVariant( exec, "QColor", tmp );
-            imp->setValue(qVariantFromValue(value)); 
-            return result; 
+        const QColor & tmp = value.color();
+        result = KJSEmbed::createVariant( exec, "QColor", tmp );
+        imp->setValue(qVariantFromValue(value)); 
+        return result; 
     }
 
     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list \
for QBrush.color");  @@ -186,10 +186,10 @@
     QBrush value = imp->value<QBrush>();
     if (args.size() == 0 )
     {
-            const QGradient * tmp = value.gradient();
-            result = KJSEmbed::createObject( exec, "const QGradient *", tmp );
-            imp->setValue(qVariantFromValue(value)); 
-            return result; 
+        const QGradient * tmp = value.gradient();
+        result = KJSEmbed::createValue( exec, "const QGradient *", tmp );
+        imp->setValue(qVariantFromValue(value)); 
+        return result; 
     }
 
     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list \
for QBrush.gradient");  @@ -207,10 +207,10 @@
     QBrush value = imp->value<QBrush>();
     if (args.size() == 0 )
     {
-            bool tmp = value.isOpaque();
-            result = KJSEmbed::createVariant( exec, "bool", tmp );
-            imp->setValue(qVariantFromValue(value)); 
-            return result; 
+        bool tmp = value.isOpaque();
+        result = KJSEmbed::createVariant( exec, "bool", tmp );
+        imp->setValue(qVariantFromValue(value)); 
+        return result; 
     }
 
     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list \
for QBrush.isOpaque"); 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic