[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdesupport/cpptoxml
From: Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date: 2011-02-28 17:05:29
Message-ID: 20110228170529.CDC67AC8C0 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1223144 by apol:
Sync with lqt's fork.
M +52 -23 main.cpp
M +12 -11 parser/binder.cpp
M +13 -2 parser/codemodel.cpp
M +5 -1 parser/codemodel.h
M +2 -2 parser/declarator_compiler.cpp
M +2 -2 parser/include/stdarg.h
M +0 -5 parser/rpp-allocator.h
M +2 -0 parser/rpp/pp-engine-bits.h
M +1 -0 parser/rpp/pp-engine.h
M +2 -2 parser/tokens.cpp
--- trunk/kdesupport/cpptoxml/main.cpp #1223143:1223144
@@ -40,13 +40,23 @@
#define ID_STR(i) (QString('_').append(QString::number(i->creationId())))
-#define ATTR_STR(n, v) ( QString(' ') + n + QString("=\"") + v + QString('\"') )
+#define ATTR_STR(n, v) ( QString(' ') + escape_chars(n) + QString("=\"") + \
escape_chars(v) + QString('\"') ) #define ATTR_NUM(n, v) ( \
(QString::number(v)).prepend(" " n "=\"").append('\"') ) #define ATTR_TRUE(n) ( \
ATTR_NUM(n, 1) )
using namespace std;
+QString escape_chars (QString s) {
+ QString ret = s;
+ ret.replace('&', "&");
+ ret.replace('"', """);
+ ret.replace('\'', "'");
+ ret.replace('>', ">");
+ ret.replace('<', "<");
+ return ret;
+}
+
class XMLVisitor {
private:
bool resolve_types;
@@ -100,8 +110,8 @@
(void)scope;
if (!resolve_types) return t;
TypeInfo tt(t);
- for (QList<CodeModelItem>::const_iterator i=current_scope.constBegin();
- i<current_scope.constEnd();
+ for (QList<CodeModelItem>::const_iterator i=current_scope.begin();
+ i<current_scope.end();
i++) {
TypeInfo ttt = tt;
//qDebug() << tt.toString() << ttt.toString();
@@ -127,16 +137,9 @@
}
//if (oldt!=tt.toString()) qDebug() << oldt << " -> " << tt.toString();
- QString ret(" type_name=\"");
-
- QString typeName=tt.toString();
- typeName=typeName.replace(">>", "> >");
- ret += typeName+'\"';
- ret += " type_base=\"";
-
- QString qualifiedName=tt.qualifiedName().join("::");
- qualifiedName=qualifiedName.replace(">>", "> >");
- ret += qualifiedName + '\"';
+ QString ret;
+ ret += ATTR_STR("type_name", tt.toString().replace(">>", "> >"));
+ ret += ATTR_STR("type_base", tt.qualifiedName().join("::").replace(">>", "> \
>")); if (tt.isConstant()) ret += ATTR_TRUE("type_constant");
if (tt.isVolatile()) ret += ATTR_TRUE("type_volatile");
if (tt.isReference()) ret += ATTR_TRUE("type_reference");
@@ -146,7 +149,7 @@
QString tmp = arr.join(",");
if (!tmp.isEmpty()) ret += " array=\"" + tmp + '\"';
- if (tt.isFunctionPointer()) ret += " function_pointer=\"1\"";
+ if (tt.isFunctionPointer()) ret += ATTR_TRUE("function_pointer");
return ret;
}
@@ -251,7 +254,7 @@
ret += visit(m->type(), m->scope());
QString tp = templateParametersToString(m->templateParameters());
- if (!tp.isEmpty()) ret += ATTR_STR("member_template_parameters", tp);
+ if (tp!=QString()) ret += ATTR_STR("member_template_parameters", tp);
}
if (FunctionModelItem f = model_dynamic_cast<FunctionModelItem>(i)) {
if (f->isVirtual()) ret += ATTR_TRUE("virtual");
@@ -279,9 +282,27 @@
}
}
if (ClassModelItem c = model_dynamic_cast<ClassModelItem>(i)) {
+ switch (c->accessPolicy()) {
+ case CodeModel::Public:
+ ret += ATTR_STR("access", "public");
+ break;
+ case CodeModel::Private:
+ ret += ATTR_STR("access", "private");
+ break;
+ case CodeModel::Protected:
+ ret += ATTR_STR("access", "protected");
+ break;
+ };
+
if (c->baseClasses().size()>0) {
+ QStringList fullBases;
ret += ATTR_STR("bases", c->baseClasses().join(";").append(";"));
+ Q_ASSERT (c->baseClasses().size() == c->baseModifiers().size());
+ for (int j=0;j<c->baseClasses().size();j++) {
+ fullBases.append(c->baseModifiers().at(j) + " " + c->baseClasses().at(j));
}
+ ret += ATTR_STR("bases_with_attributes", fullBases.join(";").append(";"));
+ }
switch(c->classType()) {
case CodeModel::Class:
ret += ATTR_STR("class_type", QString("class"));
@@ -294,7 +315,7 @@
break;
}
QString tp = templateParametersToString(c->templateParameters());
- if (!tp.isEmpty()) ret += ATTR_STR("member_template_parameters", tp);
+ if (tp!=QString()) ret += ATTR_STR("member_template_parameters", tp);
// TODO also list propertyDeclarations (maybe in content?)
}
if (EnumModelItem e = model_dynamic_cast<EnumModelItem>(i)) {
@@ -311,7 +332,7 @@
};
}
if (EnumeratorModelItem e = model_dynamic_cast<EnumeratorModelItem>(i)) {
- ret += e->value().prepend(" value=\"").append('\"');
+ ret += ATTR_STR("value", e->value());
}
if (TypeAliasModelItem t = model_dynamic_cast<TypeAliasModelItem>(i)) {
ret += visit(t->type(), t->scope());
@@ -351,15 +372,15 @@
if (EnumModelItem e = model_dynamic_cast<EnumModelItem>(i)) {
QString last = QChar('0');
foreach(EnumeratorModelItem n, \
model_dynamic_cast<EnumModelItem>(i)->enumerators()) {
- if ((n->value()).isEmpty())
+ if (n->value() == QString())
n->setValue(last.append("+1")); //FIXME: Is there a reason for not putting the \
value itself? :S children += visit(model_static_cast<CodeModelItem>(n));
last = n->value();
}
}
- ret.replace('&', "&");
- ret.replace('>', ">");
- ret.replace('<', "<");
+ //ret.replace('&', "&");
+ //ret.replace('>', ">");
+ //ret.replace('<', "<");
// TODO fix lua binding generator
if(false && children.isEmpty())
@@ -467,9 +488,17 @@
}
if (separed)
i++;
- } else
+ } else {
+#ifdef Q_OS_MAC
+ if (sourceName.isEmpty())
sourceName = QString::fromLatin1(argv[i]);
+ else
+ qtdir = QString::fromLatin1(argv[i]);
+#else
+ sourceName = QString::fromLatin1(argv[i]);
+#endif
}
+ }
if (qtdir.isEmpty())
qtdir = QDir::fromNativeSeparators(getenv("QT_INCLUDE"));
@@ -479,7 +508,7 @@
}
QString frameworkDir = "/Library/Frameworks";
- if (!QFileInfo(sourceName).exists()) {
+ if (!QFileInfo(sourceName).exists() || QFileInfo(sourceName).isDir()) {
QString qtincludefile = \
QDir::fromNativeSeparators(qtdir+'/'+sourceName+'/'+sourceName); QString \
macincludefile = QString("%1/%2.framework/Headers/%2").arg(frameworkDir).arg(sourceName);
if (QFileInfo(qtincludefile).exists()) {
--- trunk/kdesupport/cpptoxml/parser/binder.cpp #1223143:1223144
@@ -46,13 +46,13 @@
name_cc(this),
decl_cc(this)
{
- _M_qualified_types["char"].clear();
- _M_qualified_types["double"].clear();
- _M_qualified_types["float"].clear();
- _M_qualified_types["int"].clear();
- _M_qualified_types["long"].clear();
- _M_qualified_types["short"].clear();
- _M_qualified_types["void"].clear();
+ _M_qualified_types["char"] = QString();
+ _M_qualified_types["double"] = QString();
+ _M_qualified_types["float"] = QString();
+ _M_qualified_types["int"] = QString();
+ _M_qualified_types["long"] = QString();
+ _M_qualified_types["short"] = QString();
+ _M_qualified_types["void"] = QString();
}
Binder::~Binder()
@@ -546,7 +546,7 @@
typeAlias->setName (alias_name);
typeAlias->setType (qualifyType (typeInfo, currentScope ()->qualifiedName \
())); typeAlias->setScope (typedefScope->qualifiedName());
- _M_qualified_types[typeAlias->qualifiedName().join(".")].clear();
+ _M_qualified_types[typeAlias->qualifiedName().join(".")] = QString();
currentScope ()->addTypeAlias (typeAlias);
}
while (it != end);
@@ -605,7 +605,7 @@
return;
ScopeModelItem scope = currentScope();
- _M_qualified_types[(scope->qualifiedName() + name_cc.qualifiedName()).join(".") \
].clear(); + _M_qualified_types[(scope->qualifiedName() + \
name_cc.qualifiedName()).join(".") ] = QString(); }
void Binder::visitClassSpecifier(ClassSpecifierAST *node)
@@ -651,6 +651,7 @@
_M_current_class->setBaseModifiers(baseModifiers);
_M_current_class->setClassType(decode_class_type(node->class_key));
_M_current_class->setTemplateParameters(_M_current_template_parameters);
+ _M_current_class->setAccessPolicy(_M_current_access);
if (! _M_current_template_parameters.isEmpty())
{
@@ -672,7 +673,7 @@
CodeModel::FunctionType oldFunctionType = \
changeCurrentFunctionType(CodeModel::Normal);
_M_current_class->setScope(scope->qualifiedName());
- _M_qualified_types[_M_current_class->qualifiedName().join(".")].clear();
+ _M_qualified_types[_M_current_class->qualifiedName().join(".")] = QString();
scope->addClass(_M_current_class);
@@ -720,7 +721,7 @@
_M_current_enum->setName(name);
_M_current_enum->setScope(enumScope->qualifiedName());
- _M_qualified_types[_M_current_enum->qualifiedName().join(".")].clear();
+ _M_qualified_types[_M_current_enum->qualifiedName().join(".")] = QString();
enumScope->addEnum(_M_current_enum);
--- trunk/kdesupport/cpptoxml/parser/codemodel.cpp #1223143:1223144
@@ -151,6 +151,7 @@
}
if (TypeAliasModelItem __alias = model_dynamic_cast<TypeAliasModelItem> \
(__item)) + if (__alias->type().qualifiedName() != otherType.qualifiedName())
return resolveType (TypeInfo::combine (__alias->type (), otherType), \
__scope);
return otherType;
@@ -394,7 +395,17 @@
_M_propertyDeclarations << propertyDeclaration;
}
+CodeModel::AccessPolicy _ClassModelItem::accessPolicy() const
+{
+ return _M_accessPolicy;
+}
+void _ClassModelItem::setAccessPolicy(CodeModel::AccessPolicy accessPolicy)
+{
+ _M_accessPolicy = accessPolicy;
+}
+
+
// ---------------------------------------------------------------------------
FunctionModelItem _ScopeModelItem::declaredFunction(FunctionModelItem item)
{
@@ -722,12 +733,12 @@
// Qt
bool _FunctionModelItem::isInvokable() const
{
- return f._M_isInvokable;
+ return _M_isInvokable;
}
void _FunctionModelItem::setInvokable(bool isInvokable)
{
- f._M_isInvokable = isInvokable;
+ _M_isInvokable = isInvokable;
}
// ---------------------------------------------------------------------------
--- trunk/kdesupport/cpptoxml/parser/codemodel.h #1223143:1223144
@@ -349,6 +349,9 @@
void addPropertyDeclaration(const QString &propertyDeclaration);
QStringList propertyDeclarations() const { return _M_propertyDeclarations; }
+ CodeModel::AccessPolicy accessPolicy() const;
+ void setAccessPolicy(CodeModel::AccessPolicy accessPolicy);
+
protected:
_ClassModelItem(CodeModel *model, int kind = __node_kind)
: _ScopeModelItem(model, kind), _M_classType(CodeModel::Class) {}
@@ -361,6 +364,7 @@
QStringList _M_propertyDeclarations;
+ CodeModel::AccessPolicy _M_accessPolicy;
private:
_ClassModelItem(const _ClassModelItem &other);
void operator = (const _ClassModelItem &other);
@@ -575,7 +579,7 @@
uint _M_isExplicit: 1;
uint _M_isVariadics: 1;
uint _M_isInvokable : 1; // Qt
- } f;
+ };
uint _M_flags;
};
--- trunk/kdesupport/cpptoxml/parser/declarator_compiler.cpp #1223143:1223144
@@ -135,13 +135,13 @@
const Token &end = _M_token_stream->token((int) node->expression->end_token);
int length = (int) (end.position - start.position);
- p.defaultValueExpression.clear();
+ p.defaultValueExpression = QString();
QString source = QString::fromUtf8(&start.text[start.position], \
length).trimmed(); QStringList list = source.split("\n");
for (int i=0; i<list.size(); ++i) {
- if (!list.at(i).startsWith(QLatin1String("#")))
+ if (!list.at(i).startsWith("#"))
p.defaultValueExpression += list.at(i).trimmed();
}
--- trunk/kdesupport/cpptoxml/parser/include/stdarg.h #1223143:1223144
@@ -12,8 +12,8 @@
****************************************************************************/
-#ifndef CPPTOXML_STDARG
-#define CPPTOXML_STDARG
+#ifndef __STDARG
+#define __STDARG
#if !defined(_VA_LIST) && !defined(__VA_LIST_DEFINED)
#define _VA_LIST
--- trunk/kdesupport/cpptoxml/parser/rpp-allocator.h #1223143:1223144
@@ -21,9 +21,4 @@
**
****************************************************************************/
-#ifndef CPPTOXML_RPPALLOCATOR_H
-#define CPPTOXML_RPPALLOCATOR_H
-
#include "rxx_allocator.h"
-
-#endif
--- trunk/kdesupport/cpptoxml/parser/rpp/pp-engine-bits.h #1223143:1223144
@@ -190,6 +190,8 @@
case 7:
if (__directive[0] == 'i' && !strcmp (__directive, "include"))
return PP_INCLUDE;
+ else if (__directive[0] == 'w' && !strcmp (__directive, "warning"))
+ return PP_WARNING;
break;
case 12:
--- trunk/kdesupport/cpptoxml/parser/rpp/pp-engine.h #1223143:1223144
@@ -138,6 +138,7 @@
PP_IFNDEF,
PP_UNDEF,
PP_PRAGMA,
+ PP_WARNING,
PP_ERROR
};
--- trunk/kdesupport/cpptoxml/parser/tokens.cpp #1223143:1223144
@@ -23,10 +23,10 @@
****************************************************************************/
+#include <QtCore/qglobal.h>
+
#include "tokens.h"
-#include <QtCore/qglobal.h>
-
static char const * const _S_token_names[] = {
"K_DCOP",
"Q_OBJECT",
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic