Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
2f8abc0
Fix buffer overrun processing macro definitions
mwoehlke-kitware Oct 15, 2013
0490b30
Only use fields in PyTypeObject when defining types
jpe Nov 12, 2013
faa44f3
Fix compilation issue on OS X 10.9
jensenb Oct 26, 2013
a527dd5
Fix for containers with 'const' values
mwoehlke-kitware Dec 31, 2013
cb06719
doc: Stop requiring sphinx.ext.refcounting.
rakuco Dec 25, 2013
5b39f7f
Fix building with python 3.3 and 3.4.
Mar 26, 2014
35d006a
Fix function rejections (i.e. support overloads)
mwoehlke-kitware Nov 10, 2013
ebf3ba5
Add parsing of 'noexcept' keyword
mwoehlke-kitware Apr 16, 2014
bca7c11
Remove protected from samblebinding test
jpe Apr 16, 2014
e2897e1
Remove rejection lines that cause the sample_list test to fail
jcummings2 Apr 17, 2014
4e00312
Version bump
jpe Apr 22, 2014
4978122
Return enums in declaration order (order added)
mwoehlke-kitware Feb 17, 2015
0fd6bc3
Process global enums in declaration order
mwoehlke-kitware Feb 17, 2015
aa39374
Don't ignore classes in topology
mwoehlke-kitware Feb 20, 2015
64b024f
Start implementing template class support
mwoehlke-kitware Aug 6, 2013
228a918
(Partly) implement wrappers for instantiations
mwoehlke-kitware Aug 6, 2013
87c6001
Implement type look-up for template instantiatons
mwoehlke-kitware Aug 6, 2013
8d1dfc2
Implement instantiation resolutions
mwoehlke-kitware Aug 6, 2013
e04cb82
Fix adding functions to instantiations
mwoehlke-kitware Aug 6, 2013
faaffc5
Test resolution of typedefs of type-templates
mwoehlke-kitware Aug 28, 2013
3166291
Fix container argument resolution corner case
mwoehlke-kitware Aug 29, 2013
8b8163e
Fix scoped resolution of instantiations
mwoehlke-kitware Aug 29, 2013
ea8820b
Fix type alias creation for instantiations
mwoehlke-kitware Aug 29, 2013
b794b3d
Fix resolution of instantiation arguments
mwoehlke-kitware Sep 4, 2013
0212dde
Fix instantiation naming
mwoehlke-kitware Sep 4, 2013
888df1e
Omit redirections for protected members
mwoehlke-kitware Sep 4, 2013
8a920a3
Always sanitize name of wrapper classes
mwoehlke-kitware Sep 4, 2013
5f9ac1a
Use qualified name for wrapper class name
mwoehlke-kitware Sep 5, 2013
e7ee10a
Support type-template function modifications
mwoehlke-kitware Sep 16, 2013
5cac414
Remove unneeded code
mwoehlke-kitware Sep 17, 2013
fadb8c8
Fix type resolution for type-template functions
mwoehlke-kitware Sep 17, 2013
a3a2ada
Fix type template function additions
mwoehlke-kitware Sep 17, 2013
60673f5
Fix late resolution of instantiation arguments
mwoehlke-kitware Sep 19, 2013
40d167c
Reject container types with unknown arguments
mwoehlke-kitware Sep 19, 2013
48462f9
Fix redirections of base class methods
mwoehlke-kitware Sep 19, 2013
6db96db
Fix creation of duplicate redirections
mwoehlke-kitware Sep 20, 2013
76854ee
Improve pointer-like template wrapping
mathstuf Sep 16, 2013
a6fdc41
Add a 'const' in the reinterpret_cast
mathstuf Sep 18, 2013
ad050f9
Add conversion to python None in the C++ to Python copy conversion fu…
johnkit Sep 23, 2013
9f68e94
Add test for wraps-pointer-as inheritance
mathstuf Oct 1, 2013
5912b32
Support adding a base class to a metaclass
mathstuf Oct 2, 2013
77b0af4
Store the pointer argument index
mathstuf Oct 2, 2013
5948139
Output base class information piecemeal
mathstuf Oct 2, 2013
24daa88
Make wraps-pointer-as inherit over the wrapped type
mathstuf Sep 26, 2013
1f52db3
Check the baseClasses variable for its size
mathstuf Oct 2, 2013
2a39906
Set the base class if it is not already set
mathstuf Oct 8, 2013
3444020
Use the qualified name of the base class
mathstuf Oct 8, 2013
b3cd806
Mark a metaclass which has injected dependencies
mathstuf Oct 8, 2013
5315776
Sort classes with injected dependencies
mathstuf Oct 8, 2013
eac1bab
Look up full names when sorting
mathstuf Oct 8, 2013
86477e5
fix a compilation error in mac
judajake Sep 25, 2013
bc7152b
Remove output to cerr that looks to be left over debugging code.
Aug 29, 2013
9348940
Correctly assign m_handle to ptr.
Aug 15, 2013
c4c3219
Correct forward declare of SbkObject to be of type struct.
Aug 15, 2013
32b682c
add setting install_name_dir property
judajake Oct 17, 2013
549528f
add rpath so libshiboken can be found when in same dir
judajake Oct 24, 2013
2bb6524
add control and protection
judajake Oct 24, 2013
a997bb0
Fix for Mavericks (and other systems using libc++).
vibraphone Nov 11, 2013
abc5a7b
Eliminate warnings in headers and generated code.
vibraphone Dec 7, 2013
32fdeee
Generate code that generates fewer warnings.
vibraphone Dec 17, 2013
9469d27
Fix broken file-existence tests.
vibraphone Feb 20, 2014
db11f04
Provide a way to skip parsing statements.
vibraphone Sep 9, 2014
ea007f9
shiboken: support response files
mathstuf Apr 15, 2015
d2d421c
cmake: provide PYTHONPATH component needed to use the module
mathstuf Apr 23, 2015
acd0c97
cmake: ensure forward slashes in the python path
mathstuf Apr 27, 2015
c09e3f8
operators: skip nullary operators
mathstuf Jun 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 327 additions & 39 deletions ApiExtractor/abstractmetabuilder.cpp

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions ApiExtractor/abstractmetabuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TypeDatabase;
class AbstractMetaBuilder
{
public:
typedef QHash<int, AbstractMetaType *> IntAbstractMetaHash;
enum RejectReason {
NotInTypeSystem,
GenerationDisabled,
Expand Down Expand Up @@ -102,6 +103,9 @@ class AbstractMetaBuilder
void figureOutDefaultEnumArguments();

void addAbstractMetaClass(AbstractMetaClass *cls);
AbstractMetaClass *createInstantiationMetaClass(ComplexTypeEntry *entry);
void traverseInstantiation(ComplexTypeEntry *entry, AbstractMetaClass *metaClass);
void addRedirections(ComplexTypeEntry *entry, AbstractMetaClass* metaClass, AbstractMetaClass* fromClass, const QString &accessor);
AbstractMetaClass *traverseTypeAlias(TypeAliasModelItem item);
AbstractMetaClass *traverseClass(ClassModelItem item);
AbstractMetaClass* currentTraversedClass(ScopeModelItem item);
Expand All @@ -117,8 +121,8 @@ class AbstractMetaBuilder
void traverseFields(ScopeModelItem item, AbstractMetaClass *parent);
void traverseStreamOperator(FunctionModelItem functionItem);
void traverseOperatorFunction(FunctionModelItem item);
AbstractMetaFunction* traverseFunction(const AddedFunction& addedFunc);
AbstractMetaFunction* traverseFunction(const AddedFunction& addedFunc, AbstractMetaClass* metaClass);
AbstractMetaFunction* traverseFunction(const AddedFunction& addedFunc, AbstractMetaClass* metaClass = 0,
const IntAbstractMetaHash &templateArgs = IntAbstractMetaHash());
AbstractMetaFunction *traverseFunction(FunctionModelItem function);
AbstractMetaField *traverseField(VariableModelItem field, const AbstractMetaClass *cls);
void checkFunctionModifications();
Expand Down Expand Up @@ -148,6 +152,7 @@ class AbstractMetaBuilder
AbstractMetaFunction *fnc, AbstractMetaClass *,
int argumentIndex);
AbstractMetaType* translateType(double vr, const AddedFunction::TypeInfo& typeInfo);
AbstractMetaType* translateType(double vr, const AddedFunction::TypeInfo& typeInfo, const QHash<int, AbstractMetaType *> &templateArgs);
AbstractMetaType *translateType(const TypeInfo &type, bool *ok, bool resolveType = true, bool resolveScope = true);

int findOutValueFromString(const QString& stringValue, bool& ok);
Expand All @@ -166,7 +171,7 @@ class AbstractMetaBuilder

AbstractMetaClass *findTemplateClass(const QString& name, const AbstractMetaClass *context,
TypeParser::Info *info = 0, ComplexTypeEntry **baseContainerType = 0) const;
AbstractMetaClassList getBaseClasses(const AbstractMetaClass* metaClass) const;
AbstractMetaClassList getBaseClasses(const AbstractMetaClass* metaClass, bool useTemplate = true) const;
bool ancestorHasPrivateCopyConstructor(const AbstractMetaClass* metaClass) const;

bool inheritTemplate(AbstractMetaClass *subclass,
Expand Down
17 changes: 16 additions & 1 deletion ApiExtractor/abstractmetalang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,10 +1469,25 @@ bool AbstractMetaClass::hasSignal(const AbstractMetaFunction *other) const
return false;
}

QString AbstractMetaClass::canonicalizeInstantiationName(QString name)
{
name.replace(QRegExp("\\s+"), " ");
name.replace(QRegExp("<([^ ])"), "< \\1");
name.replace(QRegExp("([^ ])>"), "\\1 >");
return name;
}

QString AbstractMetaClass::name() const
{
return QString(m_typeEntry->targetLangName()).split("::").last();
const QString& tlName = m_typeEntry->targetLangName();
QStringList templateParts = tlName.split('<');
if (templateParts.count() > 1) {
QString& templateBaseName = templateParts[0];
templateBaseName = templateBaseName.split("::").last();
return canonicalizeInstantiationName(templateParts.join("<"));
} else {
return QString(tlName).split("::").last();
}
}

void AbstractMetaClass::setBaseClass(AbstractMetaClass *baseClass)
Expand Down
39 changes: 36 additions & 3 deletions ApiExtractor/abstractmetalang.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,17 @@ class AbstractMetaType
}
QString name() const
{
if (m_name.isNull())
m_name = m_typeEntry->targetLangName().split("::").last();
if (m_name.isNull()) {
const QString& tlName = m_typeEntry->targetLangName();
QStringList templateParts = tlName.split('<');
if (templateParts.count() > 1) {
QString& templateBaseName = templateParts[0];
templateBaseName = templateBaseName.split("::").last();
m_name = templateParts.join("<");
} else {
m_name = QString(tlName).split("::").last();
}
}
return m_name;
}
QString fullName() const
Expand Down Expand Up @@ -1419,7 +1428,8 @@ class AbstractMetaClass : public AbstractMetaAttributes
m_extractedInterface(0),
m_primaryInterfaceImplementor(0),
m_typeEntry(0),
m_stream(false)
m_stream(false),
m_hasInjectedDependencies(false)
{
}

Expand Down Expand Up @@ -1565,6 +1575,8 @@ class AbstractMetaClass : public AbstractMetaAttributes
return package() + "." + name();
}

static QString canonicalizeInstantiationName(QString);

/**
* Retrieves the class name without any namespace/scope information.
* /return the class name without scope information
Expand Down Expand Up @@ -1689,6 +1701,21 @@ class AbstractMetaClass : public AbstractMetaAttributes
*/
bool hasProtectedMembers() const;

/**
* Tells if this class has dependencies injected by the metabuilder.
* \return true if the class has injected dependencies.
*/
bool hasInjectedDependencies() const
{
return m_hasInjectedDependencies;
}
/**
* Tell the metaclass that it has injected dependencies.
*/
void setHasInjectedDependencies()
{
m_hasInjectedDependencies = true;
}

QList<TypeEntry *> templateArguments() const
{
Expand All @@ -1708,6 +1735,11 @@ class AbstractMetaClass : public AbstractMetaAttributes
return m_baseClassNames;
}

void addBaseClassName(const QString &name)
{
m_baseClassNames.append(name);
}

void setBaseClassNames(const QStringList &names)
{
m_baseClassNames = names;
Expand Down Expand Up @@ -1955,6 +1987,7 @@ class AbstractMetaClass : public AbstractMetaAttributes
// FunctionModelItem m_qDebugStreamFunction;

bool m_stream;
bool m_hasInjectedDependencies;
static int m_count;
};

Expand Down
65 changes: 52 additions & 13 deletions ApiExtractor/parser/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "dumptree.h"

#include <iostream>
#include <QDebug>

Binder::Binder(CodeModel *__model, LocationManager &__location, Control *__control)
: _M_model(__model),
Expand All @@ -45,13 +44,13 @@ Binder::Binder(CodeModel *__model, LocationManager &__location, Control *__contr
name_cc(this),
decl_cc(this)
{
_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();
_M_qualified_types.insert("char");
_M_qualified_types.insert("double");
_M_qualified_types.insert("float");
_M_qualified_types.insert("int");
_M_qualified_types.insert("long");
_M_qualified_types.insert("short");
_M_qualified_types.insert("void");
}

Binder::~Binder()
Expand Down Expand Up @@ -521,7 +520,7 @@ void Binder::visitTypedef(TypedefAST *node)
typeAlias->setName(alias_name);
typeAlias->setType(qualifyType(typeInfo, currentScope()->qualifiedName()));
typeAlias->setScope(typedefScope->qualifiedName());
_M_qualified_types[typeAlias->qualifiedName().join(".")] = QString();
addQualifiedType(typeAlias->qualifiedName());
currentScope()->addTypeAlias(typeAlias);
} while (it != end);
}
Expand Down Expand Up @@ -574,7 +573,7 @@ void Binder::visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *no
return;

ScopeModelItem scope = currentScope();
_M_qualified_types[(scope->qualifiedName() + name_cc.qualifiedName()).join(".")] = QString();
addQualifiedType((scope->qualifiedName() + name_cc.qualifiedName()));
}

void Binder::visitClassSpecifier(ClassSpecifierAST *node)
Expand Down Expand Up @@ -624,7 +623,7 @@ void Binder::visitClassSpecifier(ClassSpecifierAST *node)
CodeModel::FunctionType oldFunctionType = changeCurrentFunctionType(CodeModel::Normal);

_M_current_class->setScope(scope->qualifiedName());
_M_qualified_types[_M_current_class->qualifiedName().join(".")] = QString();
addQualifiedType(_M_current_class->qualifiedName());

scope->addClass(_M_current_class);

Expand Down Expand Up @@ -673,7 +672,7 @@ void Binder::visitEnumSpecifier(EnumSpecifierAST *node)
_M_current_enum->setAnonymous(isAnonymous);
_M_current_enum->setScope(enumScope->qualifiedName());

_M_qualified_types[_M_current_enum->qualifiedName().join(".")] = QString();
addQualifiedType(_M_current_enum->qualifiedName());

enumScope->addEnum(_M_current_enum);

Expand Down Expand Up @@ -806,6 +805,33 @@ void Binder::applyFunctionSpecifiers(const ListNode<std::size_t> *it, FunctionMo
} while (it != end);
}

static QString normalizeInstantiationName(const QString &name)
{
const int n = name.indexOf('<');
if (n < 0)
return name;

// Convert template arguments into a 'standard' placeholder. This isn't perfect
// because it can't hope to understand '<' / '>' used as an operator in an
// argument (assuming we don't already fall apart on those elsewhere), but should
// suffice to handle most cases.
QString result = name;

// First remove any nested instantiation names
QRegExp nested("<([^<>]+)>");
int i;
while ((i = nested.lastIndexIn(result)) != n) {
result.replace(i, nested.matchedLength(), "_");
}

// Now rebuild the name with the template arguments replaced with placeholders
QStringList args = result.split(',');
result = args[0].left(n + 1) + "_1";
for (int a = 1; a < args.count(); ++a)
result += QString(", _%1").arg(a + 1);
return result + ">";
}

TypeInfo Binder::qualifyType(const TypeInfo &type, const QStringList &context) const
{
// ### Potentially improve to use string list in the name table to
Expand All @@ -817,7 +843,9 @@ TypeInfo Binder::qualifyType(const TypeInfo &type, const QStringList &context) c
} else {
QStringList expanded = context;
expanded << type.qualifiedName();
if (_M_qualified_types.contains(expanded.join("."))) {
QStringList normalized = expanded;
normalized.last() = normalizeInstantiationName(normalized.last());
if (_M_qualified_types.contains(normalized.join("."))) {
TypeInfo modified_type = type;
modified_type.setQualifiedName(expanded);
return modified_type;
Expand All @@ -843,6 +871,17 @@ TypeInfo Binder::qualifyType(const TypeInfo &type, const QStringList &context) c
}
}

void Binder::addQualifiedType(const QStringList &name)
{
_M_qualified_types.insert(name.join("."));

if (name.last().contains('<')) {
QStringList normalized = name;
normalized.last() = normalizeInstantiationName(normalized.last());
_M_qualified_types.insert(normalized.join("."));
}
}

void Binder::updateItemPosition(CodeModelItem item, AST *node)
{
QString filename;
Expand Down
6 changes: 5 additions & 1 deletion ApiExtractor/parser/binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "name_compiler.h"
#include "declarator_compiler.h"

#include <QtCore/QSet>

class TokenStream;
class LocationManager;
class Control;
Expand Down Expand Up @@ -98,6 +100,8 @@ class Binder: protected DefaultVisitor

void updateItemPosition(CodeModelItem item, AST *node);

void addQualifiedType(const QStringList &name);

private:
CodeModel *_M_model;
LocationManager &_M_location;
Expand All @@ -113,7 +117,7 @@ class Binder: protected DefaultVisitor
EnumModelItem _M_current_enum;
QStringList _M_context;
TemplateParameterList _M_current_template_parameters; // ### check me
QHash<QString, QString> _M_qualified_types;
QSet<QString> _M_qualified_types;
QHash<QString, int> _M_anonymous_enums;

protected:
Expand Down
11 changes: 9 additions & 2 deletions ApiExtractor/parser/codemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ FunctionDefinitionList _ScopeModelItem::functionDefinitions() const

EnumList _ScopeModelItem::enums() const
{
return _M_enums.values();
EnumList result;
foreach (const QString& name, _M_enumNames)
result.append(_M_enums.value(name));
return result;
}

void _ScopeModelItem::addClass(ClassModelItem item)
Expand Down Expand Up @@ -440,7 +443,9 @@ void _ScopeModelItem::addTypeAlias(TypeAliasModelItem item)

void _ScopeModelItem::addEnum(EnumModelItem item)
{
_M_enumNames.removeOne(item->name());
_M_enums.insert(item->name(), item);
_M_enumNames.append(item->name());
}

void _ScopeModelItem::removeClass(ClassModelItem item)
Expand Down Expand Up @@ -499,8 +504,10 @@ void _ScopeModelItem::removeEnum(EnumModelItem item)
{
QHash<QString, EnumModelItem>::Iterator it = _M_enums.find(item->name());

if (it != _M_enums.end() && it.value() == item)
if (it != _M_enums.end() && it.value() == item) {
_M_enumNames.removeOne(item->name());
_M_enums.erase(it);
}
}

ClassModelItem _ScopeModelItem::findClass(const QString &name) const
Expand Down
1 change: 1 addition & 0 deletions ApiExtractor/parser/codemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class _ScopeModelItem: public _CodeModelItem
_ScopeModelItem(const _ScopeModelItem &other);
void operator = (const _ScopeModelItem &other);

QStringList _M_enumNames;
QStringList _M_enumsDeclarations;
};

Expand Down
13 changes: 13 additions & 0 deletions ApiExtractor/parser/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,19 @@ void Lexer::scanKeyword8()
}
break;

case 'n':
if (*(cursor + 1) == 'o' &&
*(cursor + 2) == 'e' &&
*(cursor + 3) == 'x' &&
*(cursor + 4) == 'c' &&
*(cursor + 5) == 'e' &&
*(cursor + 6) == 'p' &&
*(cursor + 7) == 't') {
token_stream[(int) index++].kind = Token_noexcept;
return;
}
break;

case 'o':
if (*(cursor + 1) == 'p' &&
*(cursor + 2) == 'e' &&
Expand Down
9 changes: 9 additions & 0 deletions ApiExtractor/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node)
token_stream.nextToken(); // skip ')'

parseCvQualify(ast->fun_cv);
parseNoExcept();
parseExceptionSpecification(ast->exception_spec);

if (token_stream.lookAhead() == Token___attribute__)
Expand Down Expand Up @@ -1863,6 +1864,14 @@ bool Parser::parseElaboratedTypeSpecifier(TypeSpecifierAST *&node)
return false;
}

bool Parser::parseNoExcept()
{
// right now we only accept 'noexcept' with no conditional
CHECK(Token_noexcept);

return true;
}

bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node)
{
std::size_t start = token_stream.cursor();
Expand Down
Loading