Alien-SmokeQt

 view release on metacpan or  search on metacpan

cmake/modules/FindQwt5.cmake  view on Meta::CPAN

# Qwt5_Qt3_LIBRARY - The Qwt5 library linked against Qt4 (if it exists)
# Qwt5_Qt4_FOUND   - Qwt5 was found and uses Qt4
# Qwt5_Qt3_FOUND   - Qwt5 was found and uses Qt3
# Qwt5_FOUND - Set to TRUE if Qwt5 was found (linked either to Qt3 or Qt4)

# Copyright (c) 2007, Pau Garcia i Quiles, <pgquiles@elpauer.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

# Condition is "(A OR B) AND C", CMake does not support parentheses but it evaluates left to right
IF(Qwt5_Qt4_LIBRARY OR Qwt5_Qt3_LIBRARY AND Qwt5_INCLUDE_DIR)
    SET(Qwt5_FIND_QUIETLY TRUE)
ENDIF(Qwt5_Qt4_LIBRARY OR Qwt5_Qt3_LIBRARY AND Qwt5_INCLUDE_DIR)

IF(NOT QT4_FOUND)
	FIND_PACKAGE( Qt4 REQUIRED QUIET )
ENDIF(NOT QT4_FOUND)

IF( QT4_FOUND )
	# Is Qwt5 installed? Look for header files

generator/deptool/main.cpp  view on Meta::CPAN

bool smokeModuleLessThan(Smoke* a, Smoke* b) {
    return qstrcmp(a->moduleName(), b->moduleName()) < 0;
}

#define PRINT_USAGE() \
    qDebug() << "Usage:" << argv[0] << "[--xml] <smoke lib> [more smoke libs..]"

int main(int argc, char** argv)
{
    bool generateXml = false;
    QHash<Smoke*, QSet<Smoke*> > parents;

    if (argc == 1) {
        PRINT_USAGE();
        return 0;
    }

    for (int i = 1; i < argc; i++) {
        if (QLatin1String(argv[i]) == "--xml") {
            generateXml = true;
            continue;
        } else if (QLatin1String(argv[i]) == "--help" || QLatin1String(argv[i]) == "-h") {
            PRINT_USAGE();
            continue;
        }

        parents[loadSmokeModule(QFileInfo(argv[i]))] = QSet<Smoke*>();
    }

    for (QHash<Smoke*, QSet<Smoke*> >::iterator iter = parents.begin(); iter != parents.end(); iter++) {
        for (short i = 1; i <= iter.key()->numClasses; i++) {
            Smoke::Class *klass = iter.key()->classes + i;

            for (short* idx = iter.key()->inheritanceList + klass->parents; *idx; idx++) {
                Smoke::Class *parentClass = iter.key()->classes + *idx;
                if (!parentClass->external)
                    continue;

                Smoke* parentModule = 0;
                if ((parentModule = iter.key()->findClass(parentClass->className).smoke)) {
                    iter.value().insert(parentModule);
                } else {
                    qWarning() << "WARNING: missing parent module for class" << parentClass->className;
                }
            }
        }
    }

    for (QHash<Smoke*, QSet<Smoke*> >::iterator iter = parents.begin(); iter != parents.end(); iter++) {
        // remove dependencies that are already covered by other parent modules
        foreach (Smoke* smoke, iter.value()) {
            iter.value() -= parents[smoke];
        }
    }

    QTextStream qOut(stdout);
    QList<Smoke*> smokeModules = parents.keys();
    qSort(smokeModules.begin(), smokeModules.end(), smokeModuleLessThan);
    foreach(Smoke* smoke, smokeModules) {
        qDebug() << "parent modules for" << smoke->moduleName();

        QList<Smoke*> sortedList = parents[smoke].toList();
        qSort(sortedList.begin(), sortedList.end(), smokeModuleLessThan);

        if (generateXml) {
            qOut << "    <parentModules>" << endl;
            foreach (Smoke* parent, sortedList) {
                qOut << "        <module>" << parent->moduleName() << "</module>" << endl;
            }
            qOut << "    </parentModules>" << endl;
        } else {
            foreach (Smoke* parent, sortedList) {
                qOut << "  * " << parent->moduleName() << endl;
            }
        }
    }

    foreach (Smoke* smoke, parents.keys())
        delete smoke;

    return 0;
}

generator/generators/smoke/generator_smoke.cpp  view on Meta::CPAN


#include "globals.h"
#include "../../options.h"

QDir Options::outputDir = QDir::current();
QList<QFileInfo> Options::headerList;
QStringList Options::classList;

int Options::parts = 20;
QString Options::module = "qt";
QStringList Options::parentModules;
QStringList Options::scalarTypes;
QStringList Options::voidpTypes;
bool Options::qtMode = false;
QList<QRegExp> Options::excludeExpressions;
QList<QRegExp> Options::includeFunctionNames;
QList<QRegExp> Options::includeFunctionSignatures;

static void showUsage()
{
    std::cout <<
    "Usage: generator -g smoke [smoke generator options] [other generator options] -- <headers>" << std::endl <<
    "    -m <module name> (default: 'qt')" << std::endl <<
    "    -p <parts> (default: 20)" << std::endl <<
    "    -pm <comma-seperated list of parent modules>" << std::endl <<
    "    -st <comma-seperated list of types that should be munged to scalars>" << std::endl <<
    "    -vt <comma-seperated list of types that should be mapped to Smoke::t_voidp>" << std::endl;
}

extern "C" Q_DECL_EXPORT
int generate()
{
    Options::headerList = ParserOptions::headerList;
    
    QFileInfo smokeConfig;

generator/generators/smoke/generator_smoke.cpp  view on Meta::CPAN

        } else if (args[i] == "-m") {
            Options::module = args[++i];
        } else if (args[i] == "-p") {
            bool ok = false;
            Options::parts = args[++i].toInt(&ok);
            if (!ok) {
                qCritical() << "generator_smoke: couldn't parse argument for option" << args[i - 1];
                return EXIT_FAILURE;
            }
        } else if (args[i] == "-pm") {
            Options::parentModules = args[++i].split(',');
        } else if (args[i] == "-st") {
            Options::scalarTypes = args[++i].split(',');
        } else if (args[i] == "-vt") {
            Options::voidpTypes = args[++i].split(',');
        } else if (args[i] == "-smokeconfig") {
            smokeConfig = QFileInfo(args[++i]);
        } else if (args[i] == "-o") {
            Options::outputDir = QDir(args[++i]);
        } else if (args[i] == "-h" || args[i] == "--help") {
            showUsage();

generator/generators/smoke/generator_smoke.cpp  view on Meta::CPAN

            if (elem.isNull()) {
                node = node.nextSibling();
                continue;
            }
            if (elem.tagName() == "outputDir") {
                Options::outputDir = QDir(elem.text());
            } else if (elem.tagName() == "moduleName") {
                Options::module = elem.text();
            } else if (elem.tagName() == "parts") {
                Options::parts = elem.text().toInt();
            } else if (elem.tagName() == "parentModules") {
                QDomNode parent = elem.firstChild();
                while (!parent.isNull()) {
                    QDomElement elem = parent.toElement();
                    if (elem.isNull()) {
                        parent = parent.nextSibling();
                        continue;
                    }
                    if (elem.tagName() == "module") {
                        Options::parentModules << elem.text();
                    }
                    parent = parent.nextSibling();
                }
            } else if (elem.tagName() == "scalarTypes") {
                QDomNode typeName = elem.firstChild();
                while (!typeName.isNull()) {
                    QDomElement elem = typeName.toElement();
                    if (elem.isNull()) {
                        typeName = typeName.nextSibling();
                        continue;
                    }
                    if (elem.tagName() == "typeName") {

generator/generators/smoke/globals.h  view on Meta::CPAN

class Member;
class Method;
class Field;
class Type;

struct Options
{
    static QDir outputDir;
    static int parts;
    static QString module;
    static QStringList parentModules;
    static QStringList scalarTypes;
    static QStringList voidpTypes;
    static QList<QFileInfo> headerList;
    static QStringList classList;
    static bool qtMode;
    
    static QList<QRegExp> excludeExpressions;
    static QList<QRegExp> includeFunctionNames;
    static QList<QRegExp> includeFunctionSignatures;
    

generator/generators/smoke/helpers.cpp  view on Meta::CPAN

        // gcc doesn't like this function... for whatever reason
        if (fn.name() == "_IO_ftrylockfile"
            // functions in named namespaces are covered by the class list - only check for top-level functions here
            || (fn.nameSpace().isEmpty() && !Options::functionNameIncluded(fn.qualifiedName()) && !Options::functionSignatureIncluded(fnString))
            || Options::typeExcluded(fnString))
        {
            // we don't want that function...
            continue;
        }
        
        Class* parent = &globalSpace;
        if (!fn.nameSpace().isEmpty()) {
            parent = &classes[fn.nameSpace()];
            if (parent->name().isEmpty()) {
                parent->setName(fn.nameSpace());
                parent->setKind(Class::Kind_Class);
                parent->setIsNameSpace(true);
            }
        }
        
        Method meth = Method(parent, fn.name(), fn.type(), Access_public, fn.parameters());
        meth.setFlag(Method::Static);
        parent->appendMethod(meth);
        // map this method to the function, so we can later retrieve the header it was defined in
        globalFunctionMap[&parent->methods().last()] = &fn;
        
        int methIndex = parent->methods().size() - 1;
        addOverloads(meth);
        // handle the methods appended by addOverloads()
        for (int i = parent->methods().size() - 1; i > methIndex; --i)
            globalFunctionMap[&parent->methods()[i]] = &fn;

        (*usedTypes) << meth.type();
        foreach (const Parameter& param, meth.parameters())
            (*usedTypes) << param.type();
    }
    
    // all enums that don't have a parent are put under QGlobalSpace, too
    for (QHash<QString, Enum>::iterator it = enums.begin(); it != enums.end(); it++) {
        Enum& e = it.value();
        if (!e.parent()) {
            Class* parent = &globalSpace;
            if (!e.nameSpace().isEmpty()) {
                parent = &classes[e.nameSpace()];
                if (parent->name().isEmpty()) {
                    parent->setName(e.nameSpace());
                    parent->setKind(Class::Kind_Class);
                    parent->setIsNameSpace(true);
                }
            }

            Type *t = 0;
            if (e.name().isEmpty()) {
                // unnamed enum
                Type longType = Type("long");
                longType.setIsIntegral(true);
                t = Type::registerType(longType);
            } else {
                t = Type::registerType(Type(&e));
            }
            (*usedTypes) << t;
            parent->appendChild(&e);
        }
    }
    
    foreach (const QString& key, keys) {
        Class& klass = classes[key];
        foreach (const Class::BaseClassSpecifier base, klass.baseClasses()) {
            superClasses->insert(base.baseClass);
        }
        if (!klass.isNameSpace()) {
            addDefaultConstructor(&klass);

generator/generators/smoke/helpers.cpp  view on Meta::CPAN

        if (meth.isConstructor() && meth.parameters().count() == 1) {
            const Type* type = meth.parameters()[0].type();
            // c'tor should be Foo(const Foo& copy)
            if (type->isConst() && type->isRef() && type->getClass() == klass) {
                privateCopyCtorFound = true;
                break;
            }
        }
    }
    
    bool parentCanBeCopied = true;
    foreach (const Class::BaseClassSpecifier& base, klass->baseClasses()) {
        if (!canClassBeCopied(base.baseClass)) {
            parentCanBeCopied = false;
            break;
        }
    }
    
    // if the parent can be copied and we didn't find a private copy c'tor, the class is copiable
    bool ret = (parentCanBeCopied && !privateCopyCtorFound);
    cache[klass] = ret;
    return ret;
}

bool Util::hasClassVirtualDestructor(const Class* klass)
{
    static QHash<const Class*, bool> cache;
    if (cache.contains(klass))
        return cache[klass];

generator/generators/smoke/helpers.cpp  view on Meta::CPAN

            const Type* type = meth.parameters()[0].type();
            // found a copy c'tor? then there's nothing to do
            if (type->isRef() && type->getClass() == klass)
                return;
        } else if (meth.isDestructor() && meth.access() == Access_private) {
            // private destructor, so we can't create instances of that class
            return;
        }
    }
    
    // if the parent can't be copied, a copy c'tor is of no use
    foreach (const Class::BaseClassSpecifier& base, klass->baseClasses()) {
        if (!canClassBeCopied(base.baseClass))
            return;
    }
    
    Type t = Type(klass);
    t.setPointerDepth(1);
    Method meth = Method(klass, klass->name(), Type::registerType(t));
    meth.setIsConstructor(true);
    // parameter is a constant reference to another object of the same types

generator/generators/smoke/helpers.cpp  view on Meta::CPAN

    }
}

// checks if method meth is overriden in class klass or any of its superclasses
const Method* Util::isVirtualOverriden(const Method& meth, const Class* klass)
{
    // is the method virtual at all?
    if (!(meth.flags() & Method::Virtual) && !(meth.flags() & Method::PureVirtual))
        return 0;
    
    // if the method is defined in klass, it can't be overriden there or in any parent class
    if (meth.getClass() == klass)
        return 0;
    
    foreach (const Method& m, klass->methods()) {
        if (!(m.flags() & Method::Static) && m == meth)
            // the method m overrides meth
            return &m;
    }
    
    foreach (const Class::BaseClassSpecifier& base, klass->baseClasses()) {

generator/generators/smoke/writeClasses.cpp  view on Meta::CPAN

    const Enum* e = 0;
    bool enumFound = false;
    foreach (const BasicTypeDeclaration* decl, klass->children()) {
        if (!(e = dynamic_cast<const Enum*>(decl)))
            continue;
        if (e->access() == Access_private)
            continue;
        
        foreach (const EnumMember& member, e->members()) {
            switchOut << "        case " << xcall_index << ": " << smokeClassName <<  "::x_" << xcall_index << "(args);\tbreak;\n";
            if (e->parent())
                generateEnumMemberCall(out, className, member.name(), xcall_index++);
            else
                generateEnumMemberCall(out, e->nameSpace(), member.name(), xcall_index++);
        }
        
        // only generate the xenum_call if the enum has a valid name
        if (e->name().isEmpty())
            continue;
        
        enumFound = true;

generator/generators/smoke/writeSmokeDataFile.cpp  view on Meta::CPAN

            _unsigned = true;
        }
        typeName.replace("signed ", "");
        typeName = Util::typeMap.value(typeName, typeName);
        if (_unsigned)
            typeName.prepend('u');

        flags += typeName;
    } else if (t->getEnum()) {
        flags += "|Smoke::t_enum";
        if (t->getEnum()->parent()) {
            *classIdx = classIndex.value(t->getEnum()->parent()->toString(), 0);
        } else if (!t->getEnum()->nameSpace().isEmpty()) {
            *classIdx = classIndex.value(t->getEnum()->nameSpace(), 0);
        } else {
            *classIdx = classIndex.value("QGlobalSpace", 0);
        }
    } else {
        flags += "|Smoke::t_voidp";
    }

    if (t->isRef())

generator/generators/smoke/writeSmokeDataFile.cpp  view on Meta::CPAN

    out << "};\n\n";
    
    // xenum functions
    out << "// These are the xenum functions for manipulating enum pointers\n";
    QSet<QString> enumClassesHandled;
    for (QHash<QString, Enum>::const_iterator it = enums.constBegin(); it != enums.constEnd(); it++) {
        if (!it.value().isValid())
            continue;
        
        QString smokeClassName;
        if (it.value().parent()) {
            smokeClassName = it.value().parent()->toString();
        } else {
            smokeClassName = it.value().nameSpace();
        }
        
        if (!smokeClassName.isEmpty() && includedClasses.contains(smokeClassName) && it.value().access() != Access_private) {
            if (enumClassesHandled.contains(smokeClassName) || Options::voidpTypes.contains(smokeClassName))
                continue;
            enumClassesHandled << smokeClassName;
            smokeClassName.replace("::", "__");
            out << "void xenum_" << smokeClassName << "(Smoke::EnumOperation, Smoke::Index, void*&, long&);\n";

generator/generators/smoke/writeSmokeDataFile.cpp  view on Meta::CPAN

            methodMapCount++;
        }
    }

    out << "};\n\n";

    out << "}\n\n";

    out << "extern \"C\" {\n\n";

    for (int j = 0; j < Options::parentModules.count(); j++) {
        out << "SMOKE_IMPORT void init_" << Options::parentModules[j] << "_Smoke();\n";
        if (j == Options::parentModules.count() - 1)
            out << "\n";
    }

    out << "static bool initialized = false;\n";
    out << "Smoke *" << Options::module << "_Smoke = 0;\n\n";
    out << "// Create the Smoke instance encapsulating all the above.\n";
    out << "void init_" << Options::module << "_Smoke() {\n";
    foreach (const QString& str, Options::parentModules) {
        out << "    init_" << str << "_Smoke();\n";
    }
    out << "    if (initialized) return;\n";
    out << "    " << Options::module << "_Smoke = new Smoke(\n";
    out << "        \"" << Options::module << "\",\n";
    out << "        " << smokeNamespaceName << "::classes, " << classCount << ",\n";
    out << "        " << smokeNamespaceName << "::methods, " << methodCount << ",\n";
    out << "        " << smokeNamespaceName << "::methodMaps, " << methodMapCount << ",\n";
    out << "        " << smokeNamespaceName << "::methodNames, " << methodNames.count() << ",\n";
    out << "        " << smokeNamespaceName << "::types, " << typeIndex.count() << ",\n";

generator/generatorvisitor.cpp  view on Meta::CPAN

    }
    foreach (const QStringList& list, usingTypes) {
        foreach (const QString& string, list) {
            QString complete = string + rest;
            if (string.endsWith(first)) {
                returnOnExistence(complete);
            }
        }
    }

    // check for the name in parent namespaces
    QStringList nspace = this->nspace;
    do {
        nspace.push_back(name);
        QString n = nspace.join("::");
        returnOnExistence(n);
        nspace.pop_back();
        if (!nspace.isEmpty())
            nspace.pop_back();
    } while (!nspace.isEmpty());

generator/generatorvisitor.cpp  view on Meta::CPAN

        // try to resolve the first part - if that works simply append the last part.
        BasicTypeDeclaration* decl = resolveType(parts.takeFirst());
        if (!decl)
            return 0;
        parts.prepend(decl->toString());
        name = parts.join("::");
        returnOnExistence(name);
    } else {
        // maybe it's an enum value (as used for template args in phonon)
        
        // look through all the enums of the parent classes
        if (!klass.isEmpty()) {
            const Class* clazz = klass.top();
            while (clazz) {
                foreach (BasicTypeDeclaration* decl, klass.top()->children()) {
                    Enum* e = 0;
                    if (!(e = dynamic_cast<Enum*>(decl)))
                        continue;
                    foreach (const EnumMember& member, e->members()) {
                        if (member.name() == name) {
                            name.prepend(klass.top()->toString() + "::");
                            return 0;
                        }
                    }
                }
                clazz = clazz->parent();
            }
        }
        
        // look through all global enums in our namespace
        QStringList nspace = this->nspace;
        do {
            QString n = nspace.join("::");
            foreach (const Enum& e, enums.values()) {
                if (e.parent())
                    continue;
                
                if (e.nameSpace() == n) {
                    foreach (const EnumMember& member, e.members()) {
                        if (member.name() == name) {
                            name.prepend(n + "::");
                            return 0;
                        }
                    }
                }

generator/generatorvisitor.cpp  view on Meta::CPAN

            if (!nspace.isEmpty())
                nspace.pop_back();
        } while (!nspace.isEmpty());
    }

    return 0;
}

QString GeneratorVisitor::resolveEnumMember(const QString& name)
{
    QString parent, member;
    int idx = -1;
    if ((idx = name.lastIndexOf("::")) != -1) {
        parent = name.mid(0, idx);
        member = name.mid(idx + 2);
    } else {
        member = name;
    }
    return resolveEnumMember(parent, member);
}

// TODO: This doesn't look for the enum in superclasses and parent classes yet - but it suffices for the moment.
QString GeneratorVisitor::resolveEnumMember(const QString& parent, const QString& name)
{
    // is 'parent' a know class?
    if (!parent.isEmpty()) {
        BasicTypeDeclaration* decl = resolveType(parent);
        if (decl)
            return decl->toString() + "::" + name;
    }
    
    // doesn't seem to be a class, so it's probably a part of a namespace name
    QStringList nspace = this->nspace;
    do {
        QString n = nspace.join("::");
        if (!n.isEmpty() && !parent.isEmpty()) n += "::";
        n += parent;
        
        foreach (const Enum& e, enums.values()) {
            if (e.parent())
                continue;
            
            if (e.nameSpace() == n) {
                foreach (const EnumMember& member, e.members()) {
                    if (member.name() == name) {
                        QString ret = n;
                        if (!ret.isEmpty())
                            ret += "::";
                        return ret + name;
                    }
                }
            }
        }
        
        if (!nspace.isEmpty())
            nspace.pop_back();
    } while (!nspace.isEmpty());

    QStack<Class*> parentStack = klass;
    while (!parentStack.isEmpty()) {
        const Class* clazz = parentStack.pop();
        foreach (const BasicTypeDeclaration* decl, clazz->children()) {
            const Enum *e = 0;
            if (!(e = dynamic_cast<const Enum*>(decl)))
                continue;
            foreach (const EnumMember& member, e->members()) {
                if (member.name() == name) {
                    return clazz->toString() + "::" + name;
                }
            }
        }

generator/generatorvisitor.cpp  view on Meta::CPAN

    else
        access.push(Access_public);
    inSignals.push(false);
    inSlots.push(false);
    inClass++;
    q_properties.push(QList<QProperty>());
    
    klass.top()->setFileName(m_header);
    klass.top()->setIsForwardDecl(false);
    if (klass.count() > 1) {
        // get the element before the last element, which is the parent
        Class* parent = klass[klass.count() - 2];
        parent->appendChild(klass.top());
    }
    DefaultVisitor::visitClassSpecifier(node);
    q_properties.pop();
    access.pop();
    inSignals.pop();
    inSlots.pop();
    inClass--;
}

// defined later on

generator/generatorvisitor.cpp  view on Meta::CPAN

        nc->run(node->sub_declarator->id);
    else
        nc->run(node->id);
    const QString declName = nc->name();

    if (createTypedef) {
        if (!typeCreated)
            return;
        // we've just created the type that the typedef points to
        // so we just need to get the new name and store it
        Class* parent = klass.isEmpty() ? 0 : klass.top();
        Typedef tdef = Typedef(currentTypeRef, declName, nspace.join("::"), parent);
        tdef.setFileName(m_header);
        QString name = tdef.toString();
        if (!typedefs.contains(name)) {
            QHash<QString, Typedef>::iterator it = typedefs.insert(name, tdef);
            if (parent)
                parent->appendChild(&it.value());
        }
        createTypedef = false;
        return;
    }

    // we don't care about methods with ellipsis paramaters (i.e. 'foo(const char*, ...)') for now..
    if (node->parameter_declaration_clause && node->parameter_declaration_clause->ellipsis)
        return;

    // only run this if we're not in a method. only checking for parameter_declaration_clause

generator/generatorvisitor.cpp  view on Meta::CPAN

void GeneratorVisitor::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST* node)
{
    tc->run(node);
    createType = true;
    DefaultVisitor::visitElaboratedTypeSpecifier(node);
}

void GeneratorVisitor::visitEnumSpecifier(EnumSpecifierAST* node)
{
    nc->run(node->name);
    Class* parent = klass.isEmpty() ? 0 : klass.top();
    currentEnum = Enum(nc->name(), nspace.join("::"), parent);
    Access a = (access.isEmpty() ? Access_public : access.top());
    currentEnum.setAccess(a);
    currentEnum.setFileName(m_header);
    QHash<QString, Enum>::iterator it = enums.insert(currentEnum.toString(), currentEnum);
    currentEnumRef = &it.value();
    visitNodes(this, node->enumerators);
    if (parent)
        parent->appendChild(currentEnumRef);
}

void GeneratorVisitor::visitEnumerator(EnumeratorAST* node)
{
    currentEnumRef->appendMember(EnumMember(currentEnumRef, token(node->id).symbolString(), QString()));
//     DefaultVisitor::visitEnumerator(node);
}

void GeneratorVisitor::visitFunctionDefinition(FunctionDefinitionAST* node)
{

generator/generatorvisitor.cpp  view on Meta::CPAN

    int _kind = token(node->start_token).kind;
    if (_kind == Token_class) {
        kind = Class::Kind_Class;
    } else if (_kind == Token_struct) {
        kind = Class::Kind_Struct;
    }
    if (_kind == Token_class || _kind == Token_struct) {
        tc->run(node->type_specifier);
        if (tc->qualifiedName().isEmpty()) return;
        // for nested classes
        Class* parent = klass.isEmpty() ? 0 : klass.top();
        Class _class = Class(tc->qualifiedName().last(), nspace.join("::"), parent, kind);
        Access a = (access.isEmpty() ? Access_public : access.top());
        _class.setAccess(a);
        QString name = _class.toString();
        // This class has already been parsed.
        if (classes.contains(name) && !classes[name].isForwardDecl())
            return;
        QHash<QString, Class>::iterator item = classes.insert(name, _class);
        if (inTemplate) {
            item.value().setIsTemplate(true);
            return;

generator/generatorvisitor.h  view on Meta::CPAN


class GeneratorVisitor : public DefaultVisitor
{
public:
    GeneratorVisitor(ParseSession *session, const QString& header = QString());
    virtual ~GeneratorVisitor();
    BasicTypeDeclaration* resolveTypeInSuperClasses(const Class* klass, const QString& name);
    BasicTypeDeclaration* resolveType(const QString& name);
    BasicTypeDeclaration* resolveType(QString& name);
    QString resolveEnumMember(const QString& name);
    QString resolveEnumMember(const QString& parent, const QString& name);
    QPair<bool, bool> parseCv(const ListNode<std::size_t> *cv);

protected:
    inline const Token& token(std::size_t token) { return m_session->token_stream->token(token); }

    virtual void visitAccessSpecifier(AccessSpecifierAST* node);
    virtual void visitBaseSpecifier(BaseSpecifierAST* node);
    virtual void visitClassSpecifier(ClassSpecifierAST* node);
    virtual void visitDeclarator(DeclaratorAST* node);
    virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST* node);

generator/parser/rpp/pp-environment.cpp  view on Meta::CPAN


  Q_ASSERT(!m_blocks.isEmpty());
  m_blocks.top()->elseBlock = ret;

  m_blocks.pop();
  m_blocks.push(ret);

  return ret;
}

void Environment::swapMacros( Environment* parentEnvironment ) {
  EnvironmentMap oldEnvironment = m_environment;
  m_environment = parentEnvironment->m_environment;
  parentEnvironment->m_environment = oldEnvironment;
  
  if(!parentEnvironment->currentBlock()) {
    
    if(currentBlock()) {
      foreach(pp_macro* macro, m_environment)
        currentBlock()->macros.append(macro);
    }
  }else{
    //If both sides have a macro-block, it should be the same one, else the macros can not be safely swapped
    Q_ASSERT(parentEnvironment->firstBlock() == firstBlock());
  }
}

void Environment::leaveBlock()
{
  m_blocks.pop();
}

void Environment::clear()
{

generator/parser/rpp/pp-environment.h  view on Meta::CPAN

  virtual void setMacro(pp_macro* macro);

  virtual pp_macro* retrieveMacro(const IndexedString& name, bool isImportant) const;
  
  //Returns macros that are really stored locally(retrieveMacro may be overridden to perform more complex actions)
  pp_macro* retrieveStoredMacro(const IndexedString& name) const;
  
  QList<pp_macro*> allMacros() const;

  //Take the set of environment-macros from the given environment
  virtual void swapMacros( Environment* parentEnvironment );

  //Faster access then allMacros(..), because nothing is copied
  const EnvironmentMap& environment() const; //krazy:exclude=constref

  LocationTable* locationTable() const;
  LocationTable* takeLocationTable();

private:
  EnvironmentMap m_environment;

generator/smoke.h  view on Meta::CPAN

    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef WIN32
  // Define this when building a smoke lib that doesn't have any parents - else Smoke::classMap is not exported.
  #ifdef BASE_SMOKE_BUILDING
    #define BASE_SMOKE_EXPORT __declspec(dllexport)
  #else
    #define BASE_SMOKE_EXPORT __declspec(dllimport)
  #endif
  // Define this when building a smoke lib.
  #ifdef SMOKE_BUILDING
    #define SMOKE_EXPORT __declspec(dllexport)
  #else
    #define SMOKE_EXPORT __declspec(dllimport)

generator/smoke.h  view on Meta::CPAN

        cf_virtual = 0x04,      // has virtual destructor
        cf_namespace = 0x08,    // is a namespace
        cf_undefined = 0x10     // defined elsewhere
    };
    /**
     * Describe one class.
     */
    struct Class {
	const char *className;	// Name of the class
	bool external;		// Whether the class is in another module
	Index parents;		// Index into inheritanceList
	ClassFn classFn;	// Calls any method in the class
	EnumFn enumFn;		// Handles enum pointers
        unsigned short flags;   // ClassFlags
        unsigned int size;
    };

    enum MethodFlags {
        mf_static = 0x01,
        mf_const = 0x02,
        mf_copyctor = 0x04,  // Copy constructor

generator/smoke.h  view on Meta::CPAN

    Index numMethodNames;

    /**
     * List of all types needed by the methods (arguments and return values)
     */
    Type *types;
    Index numTypes;

    /**
     * Groups of Indexes (0 separated) used as super class lists.
     * For classes with super classes: Class.parents = index into this array.
     */
    Index *inheritanceList;
    /**
     * Groups of type IDs (0 separated), describing the types of argument for a method.
     * Method.args = index into this array.
     */
    Index *argumentList;
    /**
     * Groups of method prototypes with the same number of arguments, but different types.
     * Used to resolve overloading.

generator/smoke.h  view on Meta::CPAN

    }

    inline ModuleIndex findMethodName(const char *c, const char *m) {
	ModuleIndex mni = idMethodName(m);
	if (mni.index) return mni;

	ModuleIndex cmi = findClass(c);
	if (cmi.smoke && cmi.smoke != this) {
	    return cmi.smoke->findMethodName(c, m);
	} else if (cmi.smoke == this) {
	    if (!classes[cmi.index].parents) return NullModuleIndex;
	    for (Index p = classes[cmi.index].parents; inheritanceList[p]; p++) {
		Index ci = inheritanceList[p];
		const char* cName = className(ci);
		ModuleIndex mi = classMap[cName].smoke->findMethodName(cName, m);
		if (mi.index) return mi;
	    }
	}
	return NullModuleIndex;
    }

    inline ModuleIndex idMethod(Index c, Index name) {

generator/smoke.h  view on Meta::CPAN

    inline ModuleIndex findMethod(ModuleIndex c, ModuleIndex name) {
        if (!c.index || !name.index) {
            return NullModuleIndex;
        } else if (name.smoke == this && c.smoke == this) {
            ModuleIndex mi = idMethod(c.index, name.index);
            if (mi.index) return mi;
        } else if (c.smoke != this) {
            return c.smoke->findMethod(c, name);
        }

        for (Index *i = inheritanceList + classes[c.index].parents; *i; ++i) {
            const char *cName = className(*i);
            ModuleIndex ci = findClass(cName);
            if (!ci.smoke)
                return NullModuleIndex;
            ModuleIndex ni = ci.smoke->findMethodName(cName, name.smoke->methodNames[name.index]);
            ModuleIndex mi = ci.smoke->findMethod(ci, ni);
            if (mi.index) return mi;
        }
        return NullModuleIndex;
    }

generator/smoke.h  view on Meta::CPAN

    static inline bool isDerivedFrom(const ModuleIndex& classId, const ModuleIndex& baseClassId) {
        return isDerivedFrom(classId.smoke, classId.index, baseClassId.smoke, baseClassId.index);
    }
    
    static inline bool isDerivedFrom(Smoke *smoke, Index classId, Smoke *baseSmoke, Index baseId) {
	if (!classId || !baseId || !smoke || !baseSmoke)
	    return false;
	if (smoke == baseSmoke && classId == baseId)
	    return true;
	
	for(Index p = smoke->classes[classId].parents; smoke->inheritanceList[p]; p++) {
	    Class& cur = smoke->classes[smoke->inheritanceList[p]];
	    if (cur.external) {
		ModuleIndex mi = findClass(cur.className);
		if (isDerivedFrom(mi.smoke, mi.index, baseSmoke, baseId))
		    return true;
	    }
	    if (isDerivedFrom(smoke, smoke->inheritanceList[p], baseSmoke, baseId))
		return true;
	}
	return false;

generator/smokeapi/main.cpp  view on Meta::CPAN

    
    return result;
}

static QList<ClassEntry>
getAllParents(const Smoke::ModuleIndex& classId, int indent)
{
    Smoke* smoke = classId.smoke;
    QList<ClassEntry> result;
    
    for (   Smoke::Index * parent = smoke->inheritanceList + smoke->classes[classId.index].parents; 
            *parent != 0; 
            parent++ ) 
    {
        Smoke::ModuleIndex parentId = Smoke::findClass(smoke->classes[*parent].className);
        Q_ASSERT(parentId != Smoke::NullModuleIndex);
        result << getAllParents(parentId, indent + 1);
    }
    
    result << ClassEntry(classId, indent);
    return result;
}

static void
showClass(const Smoke::ModuleIndex& classId, int indent)
{
    if (showClassNamesOnly) {

generator/smokeapi/main.cpp  view on Meta::CPAN

            return 0;
        } else if (arguments[i] == QLatin1String("-r") || arguments[i] == QLatin1String("--require")) {
            i++;
            if (i < arguments.length()) {
                smokeModules << loadSmokeModule(arguments[i]);
            }
            i++;
        } else if (arguments[i] == QLatin1String("-c") || arguments[i] == QLatin1String("--classes")) {
            showClassNamesOnly = true;
            i++;
        } else if (arguments[i] == QLatin1String("-p") || arguments[i] == QLatin1String("--parents")) {
            showParents = true;
            i++;
        } else if (arguments[i] == QLatin1String("-i") || arguments[i] == QLatin1String("--insensitive")) {
            caseInsensitive = true;
            i++;
        } else if (arguments[i] == QLatin1String("-m") || arguments[i] == QLatin1String("--match")) {
            i++;
            if (i < arguments.length()) {
                targetPattern = QRegExp(arguments[i]);
                matchPattern = true;

generator/smokeapi/main.cpp  view on Meta::CPAN

    
    while (i < arguments.length()) {
        QString className = arguments[i];

        Smoke::ModuleIndex classId = Smoke::findClass(className.toLatin1());
        if (classId == Smoke::NullModuleIndex) {
            qFatal("Error: class '%s' not found", className.toLatin1().constData());
        }
        
        if (showParents) {
            QList<ClassEntry> parents = getAllParents(classId, 0);
            foreach (ClassEntry parent, parents) {
                showClass(parent.first, parent.second);
            }
        } else {
            showClass(classId, 0);
        }
        
        i++;
    }
    
    return 0;
}

generator/type.cpp  view on Meta::CPAN

QHash<QString, Class> classes;
QHash<QString, Typedef> typedefs;
QHash<QString, Enum> enums;
QHash<QString, Function> functions;
QHash<QString, GlobalVar> globals;
QHash<QString, Type> types;

QString BasicTypeDeclaration::toString() const
{
    QString ret;
    Class* parent = m_parent;
    while (parent) {
        ret.prepend(parent->name() + "::");
        parent = parent->parent();
    }
    if (!m_nspace.isEmpty())
        ret.prepend(m_nspace + "::");
    ret += m_name;
    return ret;
}

QString Member::toString(bool withAccess, bool withClass) const
{
    QString ret;

generator/type.cpp  view on Meta::CPAN

    ret += m_type->toString() + " ";
    if (withClass)
        ret += m_typeDecl->toString() + "::";
    ret += m_name;
    return ret;
}

QString EnumMember::toString() const
{
    QString ret;
    if (m_typeDecl->parent())
        ret += m_typeDecl->parent()->toString();
    else
        ret += m_typeDecl->nameSpace();
    return ret + "::" + name();
}

QString Parameter::toString() const
{
    return m_type->toString();
}

generator/type.h  view on Meta::CPAN

    BasicTypeDeclaration() : m_access(Access_public) {}
    virtual ~BasicTypeDeclaration() {}
    virtual bool isValid() const { return !m_name.isEmpty(); }
    
    void setName(const QString& name) { m_name = name; }
    QString name() const { return m_name; }
    
    void setNameSpace(const QString& nspace) { m_nspace = nspace; }
    QString nameSpace() const { return m_nspace; }

    void setParent(Class* parent) { m_parent = parent; }
    Class* parent() const { return m_parent; }

    void setAccess(Access access) { m_access = access; }
    Access access() const { return m_access; }

    void setFileName(const QString& fileName) { m_file = fileName; }
    QString fileName() const { return m_file; }

    QString toString() const;

protected:
    BasicTypeDeclaration(const QString& name, const QString& nspace = QString(), Class* parent = 0)
        : m_name(name), m_nspace(nspace), m_parent(parent) {}

    QString m_name;
    QString m_nspace;
    Class* m_parent;
    QString m_file;
    Access m_access;
};

class GENERATOR_EXPORT Class : public BasicTypeDeclaration
{
public:
    enum Kind {
        Kind_Class,
        Kind_Struct,
        Kind_Union
    };
    
    struct BaseClassSpecifier {
        Class *baseClass;
        Access access;
        bool isVirtual;
    };
    
    Class(const QString& name = QString(), const QString nspace = QString(), Class* parent = 0, Kind kind = Kind_Class, bool isForward = true)
          : BasicTypeDeclaration(name, nspace, parent), m_kind(kind), m_forward(isForward), m_isNamespace(false), m_isTemplate(false) {}
    virtual ~Class() {}
    
    void setKind(Kind kind) { m_kind = kind; }
    Kind kind() const { return m_kind; }
    
    void setIsForwardDecl(bool forward) { m_forward = forward; }
    bool isForwardDecl() const { return m_forward; }
    
    void setIsNameSpace(bool isNamespace) { m_isNamespace = isNamespace; }
    bool isNameSpace() const { return m_isNamespace; }

generator/type.h  view on Meta::CPAN

    bool m_isTemplate;
    QList<Method> m_methods;
    QList<Field> m_fields;
    QList<BaseClassSpecifier> m_bases;
    QList<BasicTypeDeclaration*> m_children;
};

class GENERATOR_EXPORT Typedef : public BasicTypeDeclaration
{
public:
    Typedef(Type* type = 0, const QString& name = QString(), const QString nspace = QString(), Class* parent = 0)
            : BasicTypeDeclaration(name, nspace, parent), m_type(type) {}
    virtual ~Typedef() {}

    virtual bool isValid() const { return (!m_name.isEmpty() && m_type); }

    void setType(Type* type) { m_type = type; }
    Type* type() const { return m_type; }

    Type resolve() const;

private:
    Type* m_type;
};

class EnumMember;

class GENERATOR_EXPORT Enum : public BasicTypeDeclaration
{
public:
    Enum(const QString& name = QString(), const QString nspace = QString(), Class* parent = 0)
         : BasicTypeDeclaration(name, nspace, parent) {}
    virtual ~Enum() {}

    const QList<EnumMember>& members() const { return m_members; }
    QList<EnumMember>& membersRef() { return m_members; }
    void appendMember(const EnumMember& member) { m_members.append(member); }

private:
    QList<EnumMember> m_members;
};

smoke/qt/phonon/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>phonon</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>10</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qsci/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qsci</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>10</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qt3support/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qt3support</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
        <module>qtsql</module>
        <module>qtxml</module>
        <module>qtnetwork</module>
    </parentModules>
    <parts>20</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar ($) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtdbus/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtdbus</moduleName>
    <parentModules>
        <module>qtcore</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
        <typeName>QDBusObjectPath</typeName>
        <typeName>QDBusSignature</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>

smoke/qt/qtdeclarative/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtdeclarative</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtgui/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtgui</moduleName>
    <parentModules>
        <module>qtcore</module>
    </parentModules>
    <parts>20</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qthelp/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qthelp</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
        <module>qtsql</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtmultimedia/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtmultimedia</moduleName>
    <parentModules>
        <module>qtcore</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtnetwork/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtnetwork</moduleName>
    <parentModules>
        <module>qtcore</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtopengl/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtopengl</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtscript/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtscript</moduleName>
    <parentModules>
        <module>qtcore</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtsql/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtsql</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtsvg/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtsvg</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qttest/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qttest</moduleName>
    <parentModules>
        <module>qtcore</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>

smoke/qt/qtuitools/smokeconfig.xml  view on Meta::CPAN

<config>
    <moduleName>qtuitools</moduleName>
    <parentModules>
        <module>qtcore</module>
        <module>qtgui</module>
    </parentModules>
    <parts>1</parts>
    <scalarTypes>
        <!-- QString is a class, but represented as a scalar (#) in munged names -->
        <typeName>QString</typeName>
    </scalarTypes>
    <voidpTypes>
        <!-- both are classes, but they are represented as Smoke::t_voidp -->
        <typeName>QStringList</typeName>
        <typeName>QString</typeName>
    </voidpTypes>



( run in 0.416 second using v1.01-cache-2.11-cpan-4d50c553e7e )