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

List:       kde-commits
Subject:    kdesupport/cpptoxml/parser
From:       Peter Kümmel <syntheticpp () yahoo ! com>
Date:       2009-03-06 22:11:37
Message-ID: 1236377497.859532.4685.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 936073 by kuemmel:

sync with lqt master git

 M  +16 -2     binder.cpp  
 M  +22 -1     class_compiler.cpp  
 M  +2 -0      class_compiler.h  
 M  +41 -6     codemodel.cpp  
 M  +17 -2     codemodel.h  
 M  +17 -0     lexer.cpp  
 M  +1 -1      parser.cpp  
 M  +36 -5     rpp/pp-engine-bits.h  
 M  +0 -1      rpp/pp-qt-configuration  
 M  +1 -13     rpp/preprocessor.cpp  
 M  +1 -1      rpp/preprocessor.h  
 M  +1 -0      tokens.h  


--- trunk/kdesupport/cpptoxml/parser/binder.cpp #936072:936073
@@ -417,7 +417,8 @@
 {
     const ListNode<TemplateParameterAST*> *it = node->template_parameters;
     if (it == 0) {
-        // needed for template specialisation (template<> class K<void>)
+        // QtScript: we want to visit the declaration still, so that
+        // e.g. QMetaTypeId<Foo> is added to the code model
         visit(node->declaration);
         return;
     }
@@ -612,6 +613,12 @@
   ClassCompiler class_cc(this);
   class_cc.run(node);
 
+  if (class_cc.name().endsWith('>') && !class_cc.name().contains('<'))
+    {
+      // TODO parser/lexer bug in case of template<> Class<8>
+      return;
+    }
+
   if (class_cc.name().endsWith('>') && !class_cc.name().contains('<')) {
 	  // TODO parser bug in case of template<> Class<8>
 	  return;
@@ -631,7 +638,9 @@
   updateItemPosition (_M_current_class->toItem(), node);
   _M_current_class->setName(class_cc.name());
 
-  QStringList baseClasses = class_cc.baseClasses(); TypeInfo info;
+  TypeInfo info;
+  QStringList baseClasses = class_cc.baseClasses();
+  QStringList baseModifiers = class_cc.baseModifiers();
   for (int i=0; i<baseClasses.size(); ++i)
     {
         info.setQualifiedName(baseClasses.at(i).split("::"));
@@ -639,6 +648,7 @@
     }
 
   _M_current_class->setBaseClasses(baseClasses);
+  _M_current_class->setBaseModifiers(baseModifiers);
   _M_current_class->setClassType(decode_class_type(node->class_key));
   _M_current_class->setTemplateParameters(_M_current_template_parameters);
 
@@ -840,6 +850,10 @@
           case Token_explicit:
             item->setExplicit(true);
             break;
+
+          case Token_Q_INVOKABLE:
+            item->setInvokable(true);
+            break;
         }
       it = it->next;
     }
--- trunk/kdesupport/cpptoxml/parser/class_compiler.cpp #936072:936073
@@ -26,6 +26,7 @@
 #include "class_compiler.h"
 #include "lexer.h"
 #include "binder.h"
+#include "tokens.h"
 
 ClassCompiler::ClassCompiler(Binder *binder)
   : _M_binder (binder),
@@ -57,9 +58,29 @@
 {
   name_cc.run(node->name);
   QString name = name_cc.name();
+  QString modifier = "";
 
-  if (! name.isEmpty())
+  if (! name.isEmpty()) {
     _M_base_classes.append(name);
+    switch (_M_token_stream->kind(node->access_specifier)) {
+	    case Token_public:
+		    modifier = modifier.prepend("public");
+		    break;
+	    case Token_private:
+		    modifier = modifier.prepend("private");
+		    break;
+	    case Token_protected:
+		    modifier = modifier.prepend("protected");
+		    break;
+	    default:
+		    modifier = modifier.prepend("private");
+		    break;
+    }
+    if (_M_token_stream->kind(node->virt)==Token_virtual) {
+      modifier = modifier.prepend("virtual ");
+    }
+    _M_base_classes_mod.append(modifier);
+  }
 }
 
 
--- trunk/kdesupport/cpptoxml/parser/class_compiler.h #936072:936073
@@ -44,6 +44,7 @@
 
   inline QString name() const { return _M_name; }
   inline QStringList baseClasses() const { return _M_base_classes; }
+  inline QStringList baseModifiers() const { return _M_base_classes_mod; }
 
   void run(ClassSpecifierAST *node);
 
@@ -56,6 +57,7 @@
   TokenStream *_M_token_stream;
   QString _M_name;
   QStringList _M_base_classes;
+  QStringList _M_base_classes_mod;
   NameCompiler name_cc;
   TypeCompiler type_cc;
 };
--- trunk/kdesupport/cpptoxml/parser/codemodel.cpp #936072:936073
@@ -198,10 +198,8 @@
 
 bool TypeInfo::operator==(const TypeInfo &other)
 {
-  if (arrayElements() != other.arrayElements())
-    return false;
-  if (arguments() != other.arguments())
-    return false;
+  if (arrayElements().count() != other.arrayElements().count())
+      return false;
 
 #if defined (RXX_CHECK_ARRAY_ELEMENTS) // ### it'll break
   for (int i=0; i<arrayElements().count(); ++i)
@@ -328,8 +326,31 @@
 void _ClassModelItem::setBaseClasses(const QStringList &baseClasses)
 {
   _M_baseClasses = baseClasses;
+  _M_baseModifiers = QStringList();
+  while (_M_baseModifiers.size()>_M_baseClasses.size()) {
+	  _M_baseModifiers.pop_back();
+  }
+  while (_M_baseModifiers.size()<_M_baseClasses.size()) {
+	  _M_baseModifiers.push_back(QString());
+  }
 }
 
+QStringList _ClassModelItem::baseModifiers() const
+{
+  return _M_baseModifiers;
+}
+
+void _ClassModelItem::setBaseModifiers(const QStringList &baseModifiers)
+{
+  _M_baseModifiers = baseModifiers;
+  while (_M_baseModifiers.size()>_M_baseClasses.size()) {
+	  _M_baseModifiers.pop_back();
+  }
+  while (_M_baseModifiers.size()<_M_baseClasses.size()) {
+	  _M_baseModifiers.push_back(QString());
+  }
+}
+
 TemplateParameterList _ClassModelItem::templateParameters() const
 {
   return _M_templateParameters;
@@ -340,14 +361,17 @@
   _M_templateParameters = templateParameters;
 }
 
-void _ClassModelItem::addBaseClass(const QString &baseClass)
+void _ClassModelItem::addBaseClass(const QString &baseClass, const QString &baseModifier)
 {
   _M_baseClasses.append(baseClass);
+  _M_baseModifiers.append(baseModifier);
 }
 
 void _ClassModelItem::removeBaseClass(const QString &baseClass)
 {
-  _M_baseClasses.removeAt(_M_baseClasses.indexOf(baseClass));
+  int index = _M_baseClasses.indexOf(baseClass);
+  _M_baseClasses.removeAt(index);
+  _M_baseModifiers.removeAt(index);
 }
 
 bool _ClassModelItem::extendsClass(const QString &name) const
@@ -695,6 +719,17 @@
   f._M_isAbstract = isAbstract;
 }
 
+// Qt
+bool _FunctionModelItem::isInvokable() const
+{
+    return _M_isInvokable;
+}
+
+void _FunctionModelItem::setInvokable(bool isInvokable)
+{
+    _M_isInvokable = isInvokable;
+}
+
 // ---------------------------------------------------------------------------
 TypeInfo _TypeAliasModelItem::type() const
 {
--- trunk/kdesupport/cpptoxml/parser/codemodel.h #936072:936073
@@ -330,11 +330,14 @@
 
 public:
   QStringList baseClasses() const;
+  QStringList baseModifiers() const;
 
   void setBaseClasses(const QStringList &baseClasses);
-  void addBaseClass(const QString &baseClass);
+  void addBaseClass(const QString &baseClass, const QString &baseModifier = QString());
   void removeBaseClass(const QString &baseClass);
 
+  void setBaseModifiers(const QStringList &baseModifiers);
+
   TemplateParameterList templateParameters() const;
   void setTemplateParameters(const TemplateParameterList &templateParameters);
 
@@ -352,6 +355,7 @@
 
 private:
   QStringList _M_baseClasses;
+  QStringList _M_baseModifiers;
   TemplateParameterList _M_templateParameters;
   CodeModel::ClassType _M_classType;
 
@@ -490,6 +494,8 @@
   TemplateParameterList _M_templateParameters;
   TypeInfo _M_type;
   CodeModel::AccessPolicy _M_accessPolicy;
+
+public:
   union
   {
     struct
@@ -502,6 +508,11 @@
       uint _M_isRegister: 1;
       uint _M_isExtern: 1;
       uint _M_isMutable: 1;
+      uint _M_isVariadics: 1;
+      uint _M_isVirtual: 1;
+      uint _M_isExplicit: 1;
+      uint _M_isInline: 1;
+      uint _M_isAbstract: 1;
     } f;
     uint _M_flags;
   };
@@ -533,6 +544,9 @@
   bool isExplicit() const;
   void setExplicit(bool isExplicit);
 
+  bool isInvokable() const; // Qt
+  void setInvokable(bool isInvokable); // Qt
+
   bool isAbstract() const;
   void setAbstract(bool isAbstract);
 
@@ -560,7 +574,8 @@
       uint _M_isAbstract: 1;
       uint _M_isExplicit: 1;
       uint _M_isVariadics: 1;
-    } f;
+      uint _M_isInvokable : 1; // Qt
+    };
     uint _M_flags;
   };
 
--- trunk/kdesupport/cpptoxml/parser/lexer.cpp #936072:936073
@@ -1718,6 +1718,23 @@
 {
   switch (*cursor)
     {
+    case 'Q':
+      if (*(cursor + 1) == '_' &&
+	  *(cursor + 2) == 'I' &&
+	  *(cursor + 3) == 'N' &&
+	  *(cursor + 4) == 'V' &&
+	  *(cursor + 5) == 'O' &&
+	  *(cursor + 6) == 'K' &&
+	  *(cursor + 7) == 'A' &&
+	  *(cursor + 8) == 'B' &&
+	  *(cursor + 9) == 'L' &&
+	  *(cursor + 10) == 'E')
+	{
+	  token_stream[(int) index++].kind = Token_Q_INVOKABLE;
+	  return;
+	}
+      break;
+
     case 's':
       if (*(cursor + 1) == 't' &&
 	  *(cursor + 2) == 'a' &&
--- trunk/kdesupport/cpptoxml/parser/parser.cpp #936072:936073
@@ -1558,7 +1558,7 @@
   int tk;
   while (0 != (tk = token_stream.lookAhead())
          && (tk == Token_inline || tk == Token_virtual
-             || tk == Token_explicit))
+             || tk == Token_explicit || tk == Token_Q_INVOKABLE))
     {
       node = snoc(node, token_stream.cursor(), _M_pool);
       token_stream.nextToken();
--- trunk/kdesupport/cpptoxml/parser/rpp/pp-engine-bits.h #936072:936073
@@ -279,8 +279,39 @@
 
       if (file_exists (*__filepath) && !file_isdir(*__filepath))
         return fopen (__filepath->c_str(), "r");
+
+
+
+#ifdef Q_OS_MAC
+      // try in Framework path on Mac, if there is a path in front
+      // ### what about escaped slashes?
+      size_t slashPos = __input_filename.find('/');
+      if (slashPos != std::string::npos) {
+          __filepath->assign (*it);
+          __filepath->append (__input_filename.substr(0, slashPos));
+          __filepath->append (".framework/Headers/");
+          __filepath->append (__input_filename.substr(slashPos+1, std::string::npos));
+          //std::cerr << *__filepath << "\n";
+
+          if (file_exists (*__filepath) && !file_isdir(*__filepath)) {
+            return fopen (__filepath->c_str(), "r");
+            }
+            
+        __filepath->assign("/Library/Frameworks/");
+        __filepath->append (__input_filename.substr(0, slashPos));
+        __filepath->append (".framework/Headers/");
+        __filepath->append (__input_filename.substr(slashPos+1, std::string::npos));
+        //std::cerr << __input_filename << ": " << *__filepath << "\n";
+        if (file_exists (*__filepath) && !file_isdir(*__filepath)) {
+            return fopen (__filepath->c_str(), "r");
+            }
+            
+      }
+#endif // Q_OS_MAC
     }
-
+  if (__input_filename.find('/') != std::string::npos)
+    std::cerr << "pp::find_include_file:  could not find '" << __input_filename << "'\n";
+	
   return 0;
 }
 
@@ -570,10 +601,10 @@
 
   while (__first != __last && *__first != '\n')
     {
-	if (*__first == '/') {
-	    __first = skip_comment_or_divop(__first, __last);
-	    env.current_line += skip_comment_or_divop.lines;
-	}
+    if (*__first == '/') {
+        __first = skip_comment_or_divop(__first, __last);
+        env.current_line += skip_comment_or_divop.lines;
+    }
 
       if (*__first == '\\')
         {
--- trunk/kdesupport/cpptoxml/parser/rpp/pp-qt-configuration #936072:936073
@@ -15,7 +15,6 @@
 #define Q_GADGET
 #define Q_OVERRIDE(a)
 #define Q_OS_OS2
-#define ULONG_MAX Integer.MAX_VALUE
 #define Q_NO_USING_KEYWORD
 
 // There are symbols in Qt that exist in Debug but
--- trunk/kdesupport/cpptoxml/parser/rpp/preprocessor.cpp #936072:936073
@@ -58,23 +58,11 @@
     delete d;
 }
 
-void Preprocessor::processFile(const QString &fileName, const QString& configName)
+void Preprocessor::processFile(const QString &fileName)
 {
     pp proc(d->env);
     d->initPP(proc);
 
-		QFile configFile(configName);
-		if (configFile.exists()) {
-				if (!configFile.open(QFile::ReadOnly)) {
-								// ERROR!
-								return;
-				}
-				QByteArray ba = configFile.readAll();
-				configFile.close();
-				proc.operator() (ba.constData(), ba.constData() + ba.size(), rpp::pp_null_output_iterator());
-		} else {
-		}
-
     d->result.reserve(d->result.size() + 20 * 1024);
 
     d->result += "# 1 \"" + fileName.toLatin1() + "\"\n"; // ### REMOVE ME
--- trunk/kdesupport/cpptoxml/parser/rpp/preprocessor.h #936072:936073
@@ -28,7 +28,7 @@
     Preprocessor();
     ~Preprocessor();
 
-    void processFile(const QString &fileName, const QString& configFile = QString());
+    void processFile(const QString &fileName);
     void processString(const QByteArray &str);
 
     void addIncludePaths(const QStringList &includePaths);
--- trunk/kdesupport/cpptoxml/parser/tokens.h #936072:936073
@@ -134,6 +134,7 @@
     Token_xor,
     Token_xor_eq,
     Token_Q_ENUMS,
+    Token_Q_INVOKABLE,
 
     TOKEN_KIND_COUNT
 };
[prev in list] [next in list] [prev in thread] [next in thread] 

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