[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-05 4:42:21
Message-ID: 1160023341.924979.11327.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 592535 by bunce:

Make include and library actually return the results of the action.
Including thrown exceptions.  
Add more headers to copyHeaders.sh and make it verbose.
Seperate handling of global vs. compound specific enums.  
Restore proper use of extractInteger<> for integer types (for ECMA 262
r3).
Add short/long to data_types assoc array.
Handle bool and integer results appropriately.
Use compound name for header file name.
Add Flags support to Doxyfile.



 M  +5 -5      autobind/shared/util.js  
 M  +2 -1      autobind/values/Doxyfile  
 M  +2 -2      autobind/values/copyHeaders.sh  
 M  +3 -4      autobind/values/generate.js  
 M  +38 -9     autobind/values/generatebinding.js  
 M  +43 -6     kjsembed/builtins.cpp  


--- trunk/KDE/kdelibs/kjsembed/autobind/shared/util.js #592534:592535
@@ -88,8 +88,8 @@
      "qreal" : 5, "float" : 5, "qint8" : 6, "quint8" : 6, "qint16" : 6, "quint16" : \
6,   "qint32" : 6, "quint32" : 6, "qint64" : 6, "quint64" : 6, 
      "qulonglong" : 6,
-     "char" : 6, "uchar" : 6, "ushort" : 6, "ulong" : 6
-    
+     "char" : 6, "uchar" : 6, "ushort" : 6, "ulong" : 6, 
+    "short" : 6, "long" : 6, 
 };
 
 // function isVariant( paramType )
@@ -161,9 +161,9 @@
 //   paramType - The parameter type to check (preferably sans embellishments).
 //   compoundEnums - Associative array of enum types to containing objects
 // Returns true if the paramType is any known enum type.
-function isEnum( paramType, compoundEnums )
+function isEnum( paramType, globalEnums, compoundEnums )
 {
-    return ((paramType.indexOf('Qt::') != -1) || // it is a Qt enum
-            (compoundEnums[paramType]));
+    return (globalEnums[paramType] || // it is a Qt enum
+            compoundEnums[paramType]);
 }
 
--- trunk/KDE/kdelibs/kjsembed/autobind/values/Doxyfile #592534:592535
@@ -997,7 +997,8 @@
 # instead of the = operator.
 
 PREDEFINED             = Q_SLOTS="slots" \
-                         Q_SIGNALS="signals" 
+                         Q_SIGNALS="signals" \
+                         "Q_DECLARE_FLAGS(Flags, Enum)=enum Flags {};"
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded. 
--- trunk/KDE/kdelibs/kjsembed/autobind/values/copyHeaders.sh #592534:592535
@@ -8,11 +8,11 @@
          qpolygon.h    qregion.h     qstring.h      qbrush.h
          qcolor.h      qfont.h       qkeysequence.h qmatrix.h
          qpixmap.h     qrect.h       qsize.h        qtextformat.h
-         qmatrix.h"
+         qmatrix.h qnamespace.h qglobal.h"
 
 for header in $HEADERS
 do
-    cp $QTDIR/include/Qt/$header ./input
+    cp -Lv $QTDIR/include/Qt/$header ./input
 done
 
 
--- trunk/KDE/kdelibs/kjsembed/autobind/values/generate.js #592534:592535
@@ -52,7 +52,7 @@
     compound.memberList = compound.def.elementsByTagName( "memberdef" );
 
     // Store the cached enum types with our compound object.
-    compound.enums = enum_array;
+    compound.globalEnums = enum_array;
 
     // choose the bindings (TODO: Add ObjectBinding and QObjectBinding).
     if (isVariant( compound.name ))
@@ -126,7 +126,7 @@
 {
     var compoundElement = nodeList.item(x).toElement();
     var compoundKind = compoundElement.attribute('kind');
-    if ( compoundKind == 'class' )
+    if (( compoundKind == 'class' ) || (compoundKind == 'namespace'))
     {
         var classRootElement = process_class( compoundElement );
         var compoundDef = \
classRootElement.firstChildElement('compounddef').toElement(); @@ -140,8 +140,7 @@
             {
                 var enumName = \
memberElement.firstChildElement('name').toElement().toString();  var qualifiedEnum = \
                compoundName + "::" + enumName;
-                enum_array[enumName] = compoundName;
-                enum_array[qualifiedEnum] = 1;
+                enum_array[qualifiedEnum] = true;
                 println("   Added enum " + qualifiedEnum);
  
 /*
--- trunk/KDE/kdelibs/kjsembed/autobind/values/generatebinding.js #592534:592535
@@ -50,8 +50,20 @@
             '       bool ok = KJSEmbed::extractBool(exec, args, ' + paramIdx;
     }
 */
+    else if ( isInteger(coreParamType) )  // integer value
+    {
+	extracted +=
+	    '        ' + coreParamType + ' ' + paramVar + ' = KJSEmbed::extractInteger<' + \
coreParamType + '>(exec, args, ' + paramIdx; 	             '       bool ok = \
KJSEmbed::extractBool(exec, args, ' + paramIdx; +        
+        if (!paramDefault.isNull()) 	 
+            extracted += ', ' + paramDefault.toString() + ');\n'; 	 
+        else 	 
+            extracted += ');\n'; 	 
+        
+        return extracted;    
+    }
     else if ( isNumber(coreParamType) )  // integral value
-    {
+	{
         extracted +=
             '        ' + coreParamType + ' ' + paramVar + ' = \
KJSEmbed::extractNumber<' + coreParamType + '>(exec, args, ' + paramIdx;  
@@ -64,9 +76,7 @@
     }
     else if ( compound.enums[paramType] )  // Enum Value
     {
-        var enumHeading = "";
-        if (compound.enums[paramType] != 1)
-            enumHeading = compound.enums[paramType] + "::";
+        var enumHeading = compound.enums[paramType] + '::';
 
         extracted +=
             '       ' + enumHeading + paramType + ' ' + paramVar + ' = \
KJSEmbed::extractInteger<' + enumHeading + paramType + '>(exec, args, ' + paramIdx; \
@@ -78,6 +88,18 @@  
         return extracted;
     }
+    else if ( compound.globalEnums[paramType] )  // Enum Value
+    {
+        extracted +=
+            '       ' + paramType + ' ' + paramVar + ' = KJSEmbed::extractInteger<' \
+ paramType + '>(exec, args, ' + paramIdx; +
+        if (!paramDefault.isNull())
+            extracted += ', ' + paramDefault.toString() + ');\n';
+        else
+            extracted += ');\n';
+
+        return extracted;
+    }
     else if (coreParamType == 'QString')
     {
         extracted +=
@@ -167,13 +189,13 @@
             if (isBool(coreParamType))
                 params += 'object'+argIdx+' && object'+argIdx+'->isBoolean()';
             else if ( isNumber(coreParamType) || 
-                      isEnum(coreParamType, compound.enums ) )
+                      isEnum(coreParamType, compound.globalEnums, compound.enums ) )
                 params += 'object'+argIdx+' && object'+argIdx+'->isNumber()';
             else if (coreParamType == 'QString' ||
                     contains(coreParamType, 'uchar') ||
                     contains(coreParamType, 'char'))
                 params += 'object'+argIdx+' && object'+argIdx+'->isString()';
-            else //if(isVariant(paramType))
+            else 
             {
                 if (coreParamType != compound.name)
                     compound.externalBindings[coreParamType] = true;
@@ -344,7 +366,7 @@
             funcCallStart = 
                 'value.' + memberName + '(';
         }
-        else if (compound.enums[coreMethodType]) 
+        else if (compound.enums[coreMethodType]) // local scope enum value
         {
             funcCallStart +=
                 compound.enums[coreMethodType] + '::' + coreMethodType + ' tmp = \
value.' + memberName + '('; @@ -355,11 +377,17 @@
         {
             funcCallStart +=
                 methodType + ' tmp = value.' + memberName + '(';
-            if ( coreMethodType.indexOf('Qt::') != -1 ) // Enum Value
+            if ( compound.globalEnums[coreMethodType] ||  // Enum Value
+		 isInteger(coreMethodType) )
             {
                 funcCallEnd += indent +
                     '        result = KJS::Number( tmp );\n';
             }
+            else if (isBool(coreMethodType))
+            {
+                funcCallEnd += indent +
+                    '        result = KJS::Boolean( tmp );\n';
+            }
             else if (isVariant(coreMethodType))
             {
                 funcCallEnd += indent +
@@ -607,6 +635,7 @@
     var ctor = '';
     var methodLut = '';
 
+    compound.enums = {};
     compound.externalBindings = {};
     compound.memberList = compound.def.elementsByTagName( "memberdef" );
 
@@ -671,7 +700,7 @@
     {
         println('    ' + i);
         includes += '#include "' + i + '_bind.h"\n';
-        includes += '#include <' + i.toLowerCase() + '.h>\n'; 
+        includes += '#include <' + i + '>\n'; 
     }
 
     bindingFile.writeln( includes );
--- trunk/KDE/kdelibs/kjsembed/kjsembed/builtins.cpp #592534:592535
@@ -63,11 +63,27 @@
     {
         KJS::UString filename = args[0]->toString(exec);
         qDebug() << "include: " << filename.qstring();
+
         KJS::Completion c = Engine::runFile( exec->dynamicInterpreter(), filename );
-        qDebug("\tCompletionType: %d", c.complType());
-
-        if (c.isValueCompletion())
-            return c.value();
+        
+        if ( c.complType() == KJS::Normal )
+            return KJS::Null();
+        
+        if (c.complType() == KJS::ReturnValue)
+        {
+            if (c.isValueCompletion())
+                return c.value();
+            
+            return KJS::Null();
+        }
+        
+        if (c.complType() == KJS::Throw)
+        {
+            QString message = c.value()->toString(exec).qstring();
+            int line = c.value()->toObject(exec)->get(exec, "line")->toUInt32(exec);
+            return throwError(exec, KJS::EvalError, 
+                              i18n("Error seen while processing include '%1' line \
%2: %3", filename.qstring(), line, message)); +        }
     }
     else
     {
@@ -88,14 +104,35 @@
         KJS::UString filename = args[0]->toString(exec);
         QString qualifiedFilename = KStandardDirs::locate( "scripts", \
filename.qstring() );  if ( !qualifiedFilename.isEmpty() )
-            Engine::runFile( exec->dynamicInterpreter(), qualifiedFilename );
+        {
+            KJS::Completion c = Engine::runFile( exec->dynamicInterpreter(), \
qualifiedFilename ); +            if ( c.complType() == KJS::Normal )
+                return KJS::Null();
+            
+            if (c.complType() == KJS::ReturnValue)
+            {
+                if (c.isValueCompletion())
+                    return c.value();
+                
+                return KJS::Null();
+            }
+            
+            if (c.complType() == KJS::Throw)
+            {
+                QString message = c.value()->toString(exec).qstring();
+                int line = c.value()->toObject(exec)->get(exec, \
"line")->toUInt32(exec); +                return throwError(exec, KJS::EvalError, 
+                                  i18n("Error seen while processing include '%1' \
line %2: %3", filename.qstring(), line, message)); +            }
+        }
         else {
             QString msg = i18n( "File %1 not found.", filename.qstring() );
             return throwError( exec, KJS::URIError, msg );
         }
     }
     else {
-        
+        return throwError(exec, KJS::URIError, 
+                          i18n("library only takes 1 argument, not %1.", \
args.size()));  }
 
     return KJS::Null();


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

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