mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
remove now redundant utils
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
b3dd5e567b
commit
7c1f7534ab
9 changed files with 0 additions and 1311 deletions
|
@ -661,8 +661,6 @@ if(KATIE_UTILS)
|
|||
add_subdirectory(util/qlalr)
|
||||
add_subdirectory(util/qurl-generateTLDs)
|
||||
add_subdirectory(util/unicode)
|
||||
add_subdirectory(util/xkbdatagen)
|
||||
add_subdirectory(util/generaterun)
|
||||
endif()
|
||||
|
||||
# the macro calls bellow are generted via the incfsck script
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
# add_definitions()
|
||||
set(EXTRA_GENERATERUN_LIBS KtCore)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}/include
|
||||
${CMAKE_BINARY_DIR}/privateinclude
|
||||
${CMAKE_BINARY_DIR}/include/QtCore
|
||||
${CMAKE_BINARY_DIR}/privateinclude/QtCore
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(GENERATERUN_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/codegenerator.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/codegenerator.h
|
||||
)
|
||||
|
||||
katie_setup_target(generaterun ${GENERATERUN_SOURCES})
|
||||
|
||||
add_executable(generaterun ${generaterun_SOURCES})
|
||||
target_link_libraries(generaterun ${EXTRA_GENERATERUN_LIBS})
|
|
@ -1,140 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the tools applications of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "codegenerator.h"
|
||||
#include <qdebug.h>
|
||||
namespace CodeGenerator
|
||||
{
|
||||
|
||||
//Convenience constructor so you can say Item("foo")
|
||||
Item::Item(const char * const text) : generator(Text(QByteArray(text)).generator) {}
|
||||
|
||||
int BaseGenerator::currentCount(GeneratorStack * const stack) const
|
||||
{
|
||||
const int stackSize = stack->count();
|
||||
for (int i = stackSize - 1; i >= 0; --i) {
|
||||
BaseGenerator const * const generator = stack->at(i);
|
||||
switch (generator->type) {
|
||||
case RepeaterType: {
|
||||
RepeaterGenerator const * const repeater = static_cast<RepeaterGenerator const * const>(generator);
|
||||
return repeater->currentRepeat;
|
||||
} break;
|
||||
case GroupType: {
|
||||
GroupGenerator const * const group = static_cast<GroupGenerator const * const>(generator);
|
||||
return group->currentRepeat;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int BaseGenerator::repeatCount(GeneratorStack * const stack) const
|
||||
{
|
||||
const int stackSize = stack->count();
|
||||
for (int i = stackSize - 1; i >= 0; --i) {
|
||||
BaseGenerator const * const generator = stack->at(i);
|
||||
switch (generator->type) {
|
||||
case RepeaterType: {
|
||||
RepeaterGenerator const * const repeater = static_cast<RepeaterGenerator const * const>(generator);
|
||||
return repeater->currentRepeat;
|
||||
} break;
|
||||
/* case GroupType: {
|
||||
GroupGenerator const * const group = static_cast<GroupGenerator const * const>(generator);
|
||||
return group->currentRepeat;
|
||||
} break;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
QByteArray RepeaterGenerator::generate(GeneratorStack * const stack)
|
||||
{
|
||||
GeneratorStacker stacker(stack, this);
|
||||
QByteArray generated;
|
||||
for (int i = repeatOffset; i < repeatCount + repeatOffset; ++i) {
|
||||
currentRepeat = i;
|
||||
generated += childGenerator->generate(stack);
|
||||
}
|
||||
return generated;
|
||||
};
|
||||
|
||||
QByteArray GroupGenerator::generate(GeneratorStack * const stack)
|
||||
{
|
||||
const int repeatCount = currentCount(stack);
|
||||
GeneratorStacker stacker(stack, this);
|
||||
QByteArray generated;
|
||||
|
||||
if (repeatCount > 0)
|
||||
generated += prefix->generate(stack);
|
||||
|
||||
for (int i = 1; i <= repeatCount; ++i) {
|
||||
currentRepeat = i;
|
||||
generated += childGenerator->generate(stack);
|
||||
if (i != repeatCount)
|
||||
generated += separator->generate(stack);
|
||||
}
|
||||
|
||||
if (repeatCount > 0)
|
||||
generated += postfix->generate(stack);
|
||||
|
||||
return generated;
|
||||
};
|
||||
|
||||
const Compound operator+(const Item &a, const Item &b)
|
||||
{
|
||||
return Compound(a, b);
|
||||
}
|
||||
|
||||
const Compound operator+(const Item &a, const char * const text)
|
||||
{
|
||||
return Compound(a, Text(text));
|
||||
}
|
||||
|
||||
const Compound operator+(const char * const text, const Item &b)
|
||||
{
|
||||
return Compound(Text(text), b);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the tools applications of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef CODEGENERATOR_H
|
||||
#define CODEGENERATOR_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QStack>
|
||||
|
||||
namespace CodeGenerator
|
||||
{
|
||||
enum GeneratorType {NoopType, CompoundType, TextType, RepeaterType, CounterType, GroupType};
|
||||
class BaseGenerator;
|
||||
typedef QStack<BaseGenerator *> GeneratorStack;
|
||||
|
||||
template <typename ValueType>
|
||||
class Stacker {
|
||||
public:
|
||||
Stacker(QStack<ValueType> *stack, ValueType value) : stack(stack) { stack->push(value); }
|
||||
~Stacker() { stack->pop();}
|
||||
private:
|
||||
QStack<ValueType> *stack;
|
||||
};
|
||||
typedef Stacker<BaseGenerator *> GeneratorStacker;
|
||||
|
||||
class BaseGenerator
|
||||
{
|
||||
public:
|
||||
BaseGenerator(GeneratorType type = NoopType) : type(type) {}
|
||||
virtual ~BaseGenerator() {};
|
||||
virtual QByteArray generate(GeneratorStack *stack) { Q_UNUSED(stack); return QByteArray(); };
|
||||
int currentCount(GeneratorStack *stack) const;
|
||||
int repeatCount(GeneratorStack *stack) const;
|
||||
GeneratorType type;
|
||||
};
|
||||
|
||||
class Item
|
||||
{
|
||||
public:
|
||||
Item(BaseGenerator * const base) : generator(base) {}
|
||||
Item(const char * const text);
|
||||
QByteArray generate() const
|
||||
{ GeneratorStack stack; return generator->generate(&stack); }
|
||||
// ### TODO: Fix memory leak!
|
||||
// QExplicitlySharedDataPointer<BaseGenerator> generator;
|
||||
BaseGenerator * const generator;
|
||||
};
|
||||
|
||||
class CompoundGenerator : public BaseGenerator
|
||||
{
|
||||
public:
|
||||
CompoundGenerator(BaseGenerator * const a, BaseGenerator * const b)
|
||||
: BaseGenerator(CompoundType), a(a), b(b) {}
|
||||
virtual QByteArray generate(GeneratorStack *stack)
|
||||
{ return a->generate(stack) + b->generate(stack); };
|
||||
protected:
|
||||
BaseGenerator * const a;
|
||||
BaseGenerator * const b;
|
||||
};
|
||||
|
||||
class Compound : public Item
|
||||
{
|
||||
public:
|
||||
Compound(const Item &a, const Item &b) : Item(new CompoundGenerator(a.generator, b.generator)) {}
|
||||
};
|
||||
|
||||
class TextGenerator : public BaseGenerator
|
||||
{
|
||||
public:
|
||||
TextGenerator(const QByteArray &text) : BaseGenerator(TextType), text(text) {}
|
||||
virtual QByteArray generate(GeneratorStack *) { return text; };
|
||||
protected:
|
||||
QByteArray text;
|
||||
};
|
||||
|
||||
class Text : public Item {
|
||||
public:
|
||||
Text(const QByteArray &text) : Item(new TextGenerator(text)) {}
|
||||
Text(const char * const text) : Item(new TextGenerator(QByteArray(text))) {}
|
||||
};
|
||||
|
||||
class RepeaterGenerator : public BaseGenerator
|
||||
{
|
||||
public:
|
||||
RepeaterGenerator(BaseGenerator * const childGenerator)
|
||||
: BaseGenerator(RepeaterType), repeatCount(1), repeatOffset(0), childGenerator(childGenerator) {}
|
||||
virtual QByteArray generate(GeneratorStack *stack);
|
||||
|
||||
int repeatCount;
|
||||
int repeatOffset;
|
||||
int currentRepeat;
|
||||
BaseGenerator * const childGenerator;
|
||||
};
|
||||
|
||||
class Repeater : public Item {
|
||||
public:
|
||||
Repeater(const Item &item) : Item(new RepeaterGenerator(item.generator)) {}
|
||||
void setRepeatCount(int count)
|
||||
{ static_cast<RepeaterGenerator * const>(generator)->repeatCount = count; }
|
||||
void setRepeatOffset(int offset)
|
||||
{ static_cast<RepeaterGenerator * const>(generator)->repeatOffset = offset; }
|
||||
};
|
||||
|
||||
class CounterGenerator : public BaseGenerator
|
||||
{
|
||||
public:
|
||||
CounterGenerator() : BaseGenerator(CounterType), offset(0), increment(1), reverse(false) {}
|
||||
QByteArray generate(GeneratorStack *stack)
|
||||
{
|
||||
if (reverse)
|
||||
return QByteArray::number(repeatCount(stack) - (currentCount(stack) * increment) + offset + 1);
|
||||
else
|
||||
return QByteArray::number((currentCount(stack) * increment) + offset);
|
||||
}
|
||||
int offset;
|
||||
int increment;
|
||||
bool reverse;
|
||||
};
|
||||
|
||||
class Counter : public Item {
|
||||
public:
|
||||
Counter() : Item(new CounterGenerator()) {}
|
||||
Counter(int offset) : Item(new CounterGenerator()) { setOffset(offset); }
|
||||
void setOffset(int offset)
|
||||
{ static_cast<CounterGenerator *>(generator)->offset = offset; }
|
||||
void setIncrement(int increment)
|
||||
{ static_cast<CounterGenerator *>(generator)->increment = increment; }
|
||||
void setReverse(bool reverse)
|
||||
{ static_cast<CounterGenerator *>(generator)->reverse = reverse; }
|
||||
|
||||
};
|
||||
|
||||
class GroupGenerator : public BaseGenerator
|
||||
{
|
||||
public:
|
||||
GroupGenerator(BaseGenerator * const childGenerator)
|
||||
: BaseGenerator(GroupType), currentRepeat(0), childGenerator(childGenerator),
|
||||
separator(new BaseGenerator()), prefix(new BaseGenerator()), postfix(new BaseGenerator()) { }
|
||||
virtual QByteArray generate(GeneratorStack *stack);
|
||||
int currentRepeat;
|
||||
BaseGenerator * const childGenerator;
|
||||
BaseGenerator *separator;
|
||||
BaseGenerator *prefix;
|
||||
BaseGenerator *postfix;
|
||||
};
|
||||
|
||||
class Group : public Item
|
||||
{
|
||||
public:
|
||||
Group(const Item &item) : Item(new GroupGenerator(item.generator)) { setSeparator(", "); }
|
||||
void setSeparator(const Item &separator)
|
||||
{ static_cast<GroupGenerator *>(generator)->separator = separator.generator; }
|
||||
void setPrefix(const Item &prefix)
|
||||
{ static_cast<GroupGenerator *>(generator)->prefix = prefix.generator; }
|
||||
void setPostfix(const Item &postfix)
|
||||
{ static_cast<GroupGenerator *>(generator)->postfix = postfix.generator; }
|
||||
};
|
||||
|
||||
const Compound operator+(const Item &a, const Item &b);
|
||||
const Compound operator+(const Item &a, const char * const text);
|
||||
const Compound operator+(const char * const text, const Item &b);
|
||||
|
||||
} //namespace CodeGenerator
|
||||
|
||||
#endif
|
|
@ -1,399 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the tools applications of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
#include "codegenerator.h"
|
||||
using namespace CodeGenerator;
|
||||
|
||||
const Item argument = "arg" + Counter();
|
||||
const Item argumentRef = "&arg" + Counter();
|
||||
const Item argumentType = "Arg" + Counter();
|
||||
const Item constArgumentType = "const Arg" + Counter();
|
||||
const Item parameterType = "Param" + Counter();
|
||||
|
||||
Group argumentTypes(argumentType); // expands to ",Arg1, Arg2, ..."
|
||||
Group argumentTypesNoPrefix(argumentType); // expands to "Arg1, Arg2, ..."
|
||||
Group arguments(argument); // expands to ",arg1, arg2, ..."
|
||||
Group argumentsNoPrefix(argument); // expands to "arg1, arg2, ..."
|
||||
Group parameterTypes(parameterType); // expands to ",Param1, Param2, ..."
|
||||
Group parameterTypesNoPrefix(parameterType); // expands to "Param1, Param2, ..."
|
||||
Group typenameTypes("typename " + parameterType + ", typename " + argumentType); // expands to " ,typename Param1, typename Arg1, ..."
|
||||
Group types(parameterType + ", " + argumentType); // expands to ", Param1, Arg1, ..."
|
||||
Group functionParameters(constArgumentType + " " + argumentRef);
|
||||
Group typenameArgumentTypes("typename " + argumentType);
|
||||
|
||||
Group initializers(argument + "(" + argument + ")");
|
||||
Group classData(argumentType +" " + argument + ";");
|
||||
Group arglist(argument);
|
||||
Group typeList(argumentTypes);
|
||||
|
||||
void init()
|
||||
{
|
||||
argumentTypes.setPrefix(", ");
|
||||
arguments.setPrefix(", ");
|
||||
parameterTypes.setPrefix(", ");
|
||||
typenameTypes.setPrefix(", ");
|
||||
types.setPrefix(", ");
|
||||
functionParameters.setPrefix(", ");
|
||||
typenameArgumentTypes.setPrefix(", ");
|
||||
|
||||
initializers.setPrefix(", ");
|
||||
classData.setSeparator(" ");
|
||||
classData.setPrefix(" ");
|
||||
arglist.setPrefix(", ");
|
||||
typeList.setPrefix(", ");
|
||||
}
|
||||
|
||||
|
||||
Item Line(Item item)
|
||||
{
|
||||
return item + "\n";
|
||||
}
|
||||
|
||||
Item generateRunFunctions(int repeats)
|
||||
{
|
||||
Item functionPointerType = "T (*)(" + parameterTypesNoPrefix + ")";
|
||||
|
||||
Item functionPointerParameter = "T (*functionPointer)(" + parameterTypesNoPrefix + ")";
|
||||
|
||||
|
||||
|
||||
// plain functions
|
||||
Repeater functions = Line ("template <typename T" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(" + functionPointerParameter + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredFunctorCall" + Counter() + "<T, " +
|
||||
functionPointerType + argumentTypes + ">::type(functionPointer" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
functions.setRepeatCount(repeats);
|
||||
|
||||
// function objects by value
|
||||
Repeater functionObjects = Line ("template <typename FunctionObject" + typenameArgumentTypes + ">") +
|
||||
Line ("QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredFunctorCall" + Counter() +
|
||||
"<QT_TYPENAME FunctionObject::result_type, FunctionObject" +
|
||||
argumentTypes + ">::type(functionObject" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
functionObjects.setRepeatCount(repeats);
|
||||
|
||||
// function objects by pointer
|
||||
Repeater functionObjectsPointer = Line ("template <typename FunctionObject" + typenameArgumentTypes + ">") +
|
||||
Line ("QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredFunctorPointerCall" + Counter() +
|
||||
"<QT_TYPENAME FunctionObject::result_type, FunctionObject" +
|
||||
argumentTypes + ">::type(functionObject" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
functionObjectsPointer.setRepeatCount(repeats);
|
||||
|
||||
// member functions by value
|
||||
Repeater memberFunction = Line ("template <typename T, typename Class" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(const Class &object, T (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredMemberFunctionCall" + Counter() +
|
||||
"<T, Class" +
|
||||
types + ">::type(fn, object" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
memberFunction.setRepeatCount(repeats);
|
||||
|
||||
// const member functions by value
|
||||
Repeater constMemberFunction = Line ("template <typename T, typename Class" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(const Class &object, T (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredConstMemberFunctionCall" + Counter() +
|
||||
"<T, Class" +
|
||||
types + ">::type(fn, object" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
constMemberFunction.setRepeatCount(repeats);
|
||||
|
||||
// member functions by class pointer
|
||||
Repeater memberFunctionPointer = Line ("template <typename T, typename Class" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(Class *object, T (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredMemberFunctionPointerCall" + Counter() +
|
||||
"<T, Class" +
|
||||
types + ">::type(fn, object" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
memberFunctionPointer.setRepeatCount(repeats);
|
||||
|
||||
// const member functions by class pointer
|
||||
Repeater constMemberFunctionPointer = Line ("template <typename T, typename Class" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(const Class *object, T (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new QT_TYPENAME SelectStoredConstMemberFunctionPointerCall" + Counter() +
|
||||
"<T, Class" +
|
||||
types + ">::type(fn, object" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
constMemberFunctionPointer.setRepeatCount(repeats);
|
||||
|
||||
|
||||
Item interfaceFunctionPointerType = "void (*)(QFutureInterface<T> &" + argumentTypes + ")";
|
||||
Item interfaceFunctionPointerParameter = "void (*functionPointer)(QFutureInterface<T> &" + argumentTypes + ")";
|
||||
/*
|
||||
// QFutureInterface functions
|
||||
Repeater interfaceFunctions = Line ("template <typename T" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(" + interfaceFunctionPointerParameter + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new StoredInterfaceFunctionCall" + Counter() + "<T, " +
|
||||
interfaceFunctionPointerType + typenameArgumentTypes + ">(functionPointer" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
functions.setRepeatCount(repeats);
|
||||
interfaceFunctions.setRepeatCount(repeats);
|
||||
|
||||
// member functions by class pointer
|
||||
Repeater interfaceMemberFunction = Line ("template <typename Class, typename T" + typenameTypes + ">") +
|
||||
Line ("QFuture<T> run(void (Class::*fn)(QFutureInterface<T> &), Class *object" + functionParameters + ")") +
|
||||
Line("{") +
|
||||
Line(" return (new StoredInterfaceMemberFunctionCall" + Counter() +
|
||||
"<T, void (Class::*)(QFutureInterface<T> &), Class" +
|
||||
typenameArgumentTypes + ">(fn, object" + arguments + "))->start();") +
|
||||
Line("}");
|
||||
memberFunctionPointer.setRepeatCount(repeats);
|
||||
*/
|
||||
return functions + Line("") + functionObjects + Line("") + functionObjectsPointer + Line("")
|
||||
+ memberFunction + Line("") + constMemberFunction + Line("")
|
||||
+ memberFunctionPointer + Line("") + constMemberFunctionPointer + Line("")
|
||||
/* + interfaceFunctions + Line("") + interfaceMemberFunction + Line("")*/
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Item functions(Item className, Item functorType, Item callLine)
|
||||
{
|
||||
return
|
||||
Line("template <typename T, typename FunctionPointer" + typenameArgumentTypes + ">") +
|
||||
Line("struct " + className + Counter() +": public RunFunctionTask<T>") +
|
||||
Line("{") +
|
||||
Line(" inline " + className + Counter() + "(" + functorType + " function" + functionParameters +")") +
|
||||
Line(" : function(function)" + initializers + " {}") +
|
||||
Line(" void runFunctor() {" + callLine + argumentsNoPrefix + "); }") +
|
||||
Line(" " + functorType + " function;") +
|
||||
Line( classData) +
|
||||
Line("};") +
|
||||
Line("");
|
||||
}
|
||||
|
||||
Item functionSelector(Item classNameBase)
|
||||
{
|
||||
return
|
||||
Line("template <typename T, typename FunctionPointer" + typenameArgumentTypes + ">") +
|
||||
Line("struct Select" + classNameBase + Counter()) +
|
||||
Line("{") +
|
||||
Line(" typedef typename SelectSpecialization<T>::template") +
|
||||
Line(" Type<" + classNameBase + Counter() + " <T, FunctionPointer" + argumentTypes + ">,") +
|
||||
Line(" Void" + classNameBase + Counter() + "<T, FunctionPointer" + argumentTypes + "> >::type type;") +
|
||||
Line("};");
|
||||
}
|
||||
|
||||
Item memberFunctions(Item className, Item constFunction, Item objectArgument, Item objectMember, Item callLine)
|
||||
{
|
||||
return
|
||||
Line("template <typename T, typename Class" + typenameTypes + ">") +
|
||||
Line("class " + className + Counter() + " : public RunFunctionTask<T>") +
|
||||
Line("{") +
|
||||
Line("public:")+
|
||||
Line(" " + className + Counter() + "(T (Class::*fn)(" + parameterTypesNoPrefix + ") " + constFunction + ", " + objectArgument + functionParameters + ")") +
|
||||
Line(" : fn(fn), object(object)" + initializers + "{ }" ) +
|
||||
Line("")+
|
||||
Line(" void runFunctor()")+
|
||||
Line(" {")+
|
||||
Line(" " + callLine + argumentsNoPrefix + ");")+
|
||||
Line(" }")+
|
||||
Line("private:")+
|
||||
Line(" T (Class::*fn)(" + parameterTypesNoPrefix + ")" + constFunction + ";")+
|
||||
Line(" " + objectMember + ";") +
|
||||
Line( classData) +
|
||||
Line("};");
|
||||
}
|
||||
|
||||
Item memberFunctionSelector(Item classNameBase)
|
||||
{
|
||||
return
|
||||
Line("template <typename T, typename Class" + typenameTypes + ">") +
|
||||
Line("struct Select" + classNameBase + Counter()) +
|
||||
Line("{") +
|
||||
Line(" typedef typename SelectSpecialization<T>::template") +
|
||||
Line(" Type<" + classNameBase + Counter() + " <T, Class" + types + ">,") +
|
||||
Line(" Void" + classNameBase + Counter() + "<T, Class" + types + "> >::type type;") +
|
||||
Line("};");
|
||||
}
|
||||
|
||||
Item generateSFCs(int repeats)
|
||||
{
|
||||
|
||||
Item functionPointerTypedef = "typedef void (*FunctionPointer)(" + argumentTypesNoPrefix + ");";
|
||||
|
||||
Repeater dataStructures =
|
||||
|
||||
// Function objects by value
|
||||
functions(Item("StoredFunctorCall"), Item("FunctionPointer"), Item(" this->result = function(")) +
|
||||
functions(Item("VoidStoredFunctorCall"), Item("FunctionPointer"), Item(" function(")) +
|
||||
functionSelector(Item("StoredFunctorCall")) +
|
||||
|
||||
// Function objects by pointer
|
||||
functions(Item("StoredFunctorPointerCall"), Item("FunctionPointer *"), Item(" this->result =(*function)(")) +
|
||||
functions(Item("VoidStoredFunctorPointerCall"), Item("FunctionPointer *"), Item("(*function)(")) +
|
||||
functionSelector(Item("StoredFunctorPointerCall")) +
|
||||
|
||||
// Member functions by value
|
||||
memberFunctions(Item("StoredMemberFunctionCall"), Item(""), Item("const Class &object"), Item("Class object"), Item("this->result = (object.*fn)(")) +
|
||||
memberFunctions(Item("VoidStoredMemberFunctionCall"), Item(""), Item("const Class &object"), Item("Class object"), Item("(object.*fn)(")) +
|
||||
memberFunctionSelector(Item("StoredMemberFunctionCall")) +
|
||||
|
||||
// Const Member functions by value
|
||||
memberFunctions(Item("StoredConstMemberFunctionCall"), Item("const"), Item("const Class &object"), Item("const Class object"), Item("this->result = (object.*fn)(")) +
|
||||
memberFunctions(Item("VoidStoredConstMemberFunctionCall"), Item("const"), Item("const Class &object"), Item("const Class object"), Item("(object.*fn)(")) +
|
||||
memberFunctionSelector(Item("StoredConstMemberFunctionCall")) +
|
||||
|
||||
// Member functions by pointer
|
||||
memberFunctions(Item("StoredMemberFunctionPointerCall"), Item(""), Item("Class *object"), Item("Class *object"), Item("this->result = (object->*fn)(")) +
|
||||
memberFunctions(Item("VoidStoredMemberFunctionPointerCall"), Item(""), Item("Class *object"), Item("Class *object"), Item("(object->*fn)(")) +
|
||||
memberFunctionSelector(Item("StoredMemberFunctionPointerCall")) +
|
||||
|
||||
// const member functions by pointer
|
||||
memberFunctions(Item("StoredConstMemberFunctionPointerCall"), Item("const"), Item("Class const *object"), Item("Class const *object"), Item("this->result = (object->*fn)(")) +
|
||||
memberFunctions(Item("VoidStoredConstMemberFunctionPointerCall"), Item("const"), Item("Class const *object"), Item("Class const *object"), Item("(object->*fn)(")) +
|
||||
memberFunctionSelector(Item("StoredConstMemberFunctionPointerCall"));
|
||||
|
||||
dataStructures.setRepeatCount(repeats);
|
||||
return dataStructures;
|
||||
}
|
||||
|
||||
void writeFile(QString fileName, QByteArray contents)
|
||||
{
|
||||
QFile runFile(fileName);
|
||||
if (runFile.open(QIODevice::WriteOnly) == false) {
|
||||
qDebug() << "Write to" << fileName << "failed";
|
||||
return;
|
||||
}
|
||||
|
||||
runFile.write(contents);
|
||||
runFile.close();
|
||||
qDebug() << "Write to" << fileName << "Ok";
|
||||
}
|
||||
|
||||
Item dollarQuote(Item item)
|
||||
{
|
||||
return Item("$") + item + Item("$");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const int repeats = 6;
|
||||
init();
|
||||
Item run = (
|
||||
Line("/****************************************************************************") +
|
||||
Line("**") +
|
||||
Line("** Copyright (C) 2015 The Qt Company Ltd.") +
|
||||
Line("** Contact: http://www.qt.io/licensing/") +
|
||||
Line("**") +
|
||||
Line("** This file is part of the Qt Toolkit.") +
|
||||
Line("**") +
|
||||
Line("****************************************************************************/") +
|
||||
Line("") +
|
||||
Line("// Generated code, do not edit! Use generator at tools/qtconcurrent/generaterun/") +
|
||||
Line("#ifndef QTCONCURRENT_RUN_H") +
|
||||
Line("#define QTCONCURRENT_RUN_H") +
|
||||
Line("") +
|
||||
Line("#ifndef QT_NO_CONCURRENT") +
|
||||
Line("") +
|
||||
Line("#include <QtCore/qtconcurrentrunbase.h>") +
|
||||
Line("#include <QtCore/qtconcurrentstoredfunctioncall.h>") +
|
||||
Line("") +
|
||||
Line("QT_BEGIN_HEADER") +
|
||||
Line("QT_BEGIN_NAMESPACE") +
|
||||
Line("") +
|
||||
Line("namespace QtConcurrent {") +
|
||||
Line("") +
|
||||
generateRunFunctions(repeats) +
|
||||
Line("} //namespace QtConcurrent") +
|
||||
Line("") +
|
||||
Line("QT_END_NAMESPACE") +
|
||||
Line("QT_END_HEADER") +
|
||||
Line("") +
|
||||
Line("#endif // QT_NO_CONCURRENT") +
|
||||
Line("") +
|
||||
Line("#endif")
|
||||
);
|
||||
|
||||
writeFile("../src/core/concurrent/qtconcurrentrun.h", run.generate());
|
||||
|
||||
Item storedFunctionCall = (
|
||||
Line("/****************************************************************************") +
|
||||
Line("**") +
|
||||
Line("** Copyright (C) 2015 The Qt Company Ltd.") +
|
||||
Line("** Contact: http://www.qt.io/licensing/") +
|
||||
Line("**") +
|
||||
Line("** This file is part of the Qt Toolkit.") +
|
||||
Line("**") +
|
||||
Line("****************************************************************************/") +
|
||||
Line("") +
|
||||
Line("// Generated code, do not edit! Use generator at tools/qtconcurrent/generaterun/") +
|
||||
Line("#ifndef QTCONCURRENT_STOREDFUNCTIONCALL_H") +
|
||||
Line("#define QTCONCURRENT_STOREDFUNCTIONCALL_H") +
|
||||
Line("") +
|
||||
Line("#include <QtCore/qglobal.h>") +
|
||||
Line("") +
|
||||
Line("#ifndef QT_NO_CONCURRENT") +
|
||||
Line("#include <QtCore/qtconcurrentrunbase.h>") +
|
||||
Line("") +
|
||||
Line("QT_BEGIN_HEADER") +
|
||||
Line("QT_BEGIN_NAMESPACE") +
|
||||
Line("") +
|
||||
Line("namespace QtConcurrent {") +
|
||||
generateSFCs(repeats) +
|
||||
Line("} //namespace QtConcurrent") +
|
||||
Line("") +
|
||||
Line("QT_END_NAMESPACE") +
|
||||
Line("QT_END_HEADER") +
|
||||
Line("") +
|
||||
Line("#endif // QT_NO_CONCURRENT") +
|
||||
Line("") +
|
||||
Line("#endif")
|
||||
);
|
||||
|
||||
writeFile("../src/core/concurrent/qtconcurrentstoredfunctioncall.h", storedFunctionCall.generate());
|
||||
}
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
undef $/;
|
||||
|
||||
foreach $f ( @ARGV ) {
|
||||
if ( open( F, "< $f" ) ) {
|
||||
$i = <F>;
|
||||
close F;
|
||||
$i =~ s/\n/\r\n/g;
|
||||
$i =~ s/\r+/\r/g;
|
||||
if ( open( F, "> $f" ) ) {
|
||||
print F $i;
|
||||
close F;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
# add_definitions()
|
||||
set(EXTRA_XKBDATAGEN_LIBS KtCore KtXml)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}/include
|
||||
${CMAKE_BINARY_DIR}/privateinclude
|
||||
${CMAKE_BINARY_DIR}/include/QtCore
|
||||
${CMAKE_BINARY_DIR}/privateinclude/QtCore
|
||||
${CMAKE_BINARY_DIR}/include/QtXml
|
||||
${CMAKE_BINARY_DIR}/privateinclude/QtXml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(XKBDATAGEN_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
)
|
||||
|
||||
katie_setup_target(xkbdatagen ${XKBDATAGEN_SOURCES})
|
||||
|
||||
add_executable(xkbdatagen ${xkbdatagen_SOURCES})
|
||||
target_link_libraries(xkbdatagen ${EXTRA_XKBDATAGEN_LIBS})
|
|
@ -1 +0,0 @@
|
|||
program used to generate qkeymapper_x11_p.cpp
|
|
@ -1,507 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the utils of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <QtCore>
|
||||
#include <QtXml/qdom.h>
|
||||
|
||||
class XKBLayout
|
||||
{
|
||||
public:
|
||||
QString name;
|
||||
QString description;
|
||||
QStringList variants;
|
||||
};
|
||||
|
||||
QDomElement find(const QString &tagName, const QDomElement &e)
|
||||
{
|
||||
QDomNodeList children = e.childNodes();
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
const QDomNode &n = children.at(i);
|
||||
if (n.isElement()) {
|
||||
QDomElement c = n.toElement();
|
||||
if (c.tagName() == tagName)
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return QDomElement();
|
||||
}
|
||||
|
||||
QString parseVariant(const QDomElement &e)
|
||||
{
|
||||
QDomElement configItem = find("configItem", e);
|
||||
return find("name", configItem).text();
|
||||
}
|
||||
|
||||
QStringList findVariants(const QDomElement &e)
|
||||
{
|
||||
QStringList variants;
|
||||
|
||||
QDomNodeList children = e.childNodes();
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
const QDomNode &n = children.at(i);
|
||||
if (n.isElement())
|
||||
variants += parseVariant(n.toElement());
|
||||
}
|
||||
|
||||
return variants;
|
||||
}
|
||||
|
||||
XKBLayout parseLayout(const QDomElement &e)
|
||||
{
|
||||
QDomElement configItem = find("configItem", e);
|
||||
|
||||
XKBLayout layout;
|
||||
layout.name = find("name", configItem).text();
|
||||
layout.description = find("description", configItem).text();
|
||||
|
||||
QDomElement variantList = find("variantList", e);
|
||||
if (!variantList.isNull())
|
||||
layout.variants = findVariants(variantList);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
QList<XKBLayout> findLayouts(const QDomElement &layoutList)
|
||||
{
|
||||
QList<XKBLayout> layouts;
|
||||
|
||||
QDomNodeList children = layoutList.childNodes();
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
const QDomNode &n = children.at(i);
|
||||
if (n.isElement())
|
||||
layouts += parseLayout(n.toElement());
|
||||
}
|
||||
|
||||
return layouts;
|
||||
}
|
||||
|
||||
QString mapCountry(const QString &v)
|
||||
{
|
||||
static QMap<QString, QString> map;
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
map["U.S. English"] = "UnitedStates";
|
||||
map["PC-98xx Series"] = "Japan";
|
||||
map["Bosnia and Herzegovina"] = "BosniaAndHerzegowina";
|
||||
map["Czechia"] = "CzechRepublic";
|
||||
map["Faroe Islands"] = "FaroeIslands";
|
||||
map["Laos"] = "Lao";
|
||||
map["Latin American"] = "Mexico";
|
||||
map["Russia"] = "RussianFederation";
|
||||
map["Syria"] = "SyrianArabRepublic";
|
||||
map["Sri Lanka"] = "SriLanka";
|
||||
map["United Kingdom"] = "UnitedKingdom";
|
||||
map["Vietnam"] = "VietNam";
|
||||
map["Macedonian"] = "Macedonia";
|
||||
map["Serbian"] = "SerbiaAndMontenegro";
|
||||
map["Turkish "] = "Turkey";
|
||||
map["Maori"] = "NewZealand";
|
||||
map["Arabic"] = "UnitedArabEmirates";
|
||||
initialized = true;
|
||||
}
|
||||
return map.value(v, v);
|
||||
}
|
||||
|
||||
QString mapLanguage(const QString &v)
|
||||
{
|
||||
static QMap<QString, QString> map;
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
map["us"] = "English";
|
||||
map["us:intl"] = "English";
|
||||
map["us:alt-intl"] = "English";
|
||||
map["us:dvorak"] = "English";
|
||||
map["us:rus"] = "Russian";
|
||||
map["ara"] = "Arabic";
|
||||
map["ara:azerty"] = "Arabic";
|
||||
map["ara:azerty_digits"] = "Arabic";
|
||||
map["ara:digits"] = "Arabic";
|
||||
map["ara:qwerty"] = "Arabic";
|
||||
map["ara:qwerty_digits"] = "Arabic";
|
||||
map["al"] = "Albanian";
|
||||
map["am"] = "Armenian";
|
||||
map["am:phonetic"] = "Armenian";
|
||||
map["az"] = "Azerbaijani";
|
||||
map["az:cyrillic"] = "Azerbaijani";
|
||||
map["by"] = "Byelorussian";
|
||||
map["by:winkeys"] = "Byelorussian";
|
||||
map["be"] = "Dutch";
|
||||
map["be:iso-alternate"] = "Dutch";
|
||||
map["be:nodeadkeys"] = "Dutch";
|
||||
map["be:sundeadkeys"] = "Dutch";
|
||||
map["bd"] = "Bengali";
|
||||
map["bd:probhat"] = "Bengali";
|
||||
map["in"] = "Hindi";
|
||||
map["in:ben"] = "Bengali";
|
||||
map["in:ben_probhat"] = "Bengali";
|
||||
map["in:guj"] = "Gujarati";
|
||||
map["in:guru"] = "Punjabi";
|
||||
map["in:kan"] = "Kannada";
|
||||
map["in:mal"] = "Malayalam";
|
||||
map["in:ori"] = "Oriya";
|
||||
map["in:tam_unicode"] = "Tamil";
|
||||
map["in:tam_TAB"] = "Tamil";
|
||||
map["in:tam_TSCII"] = "Tamil";
|
||||
map["in:tam"] = "Tamil";
|
||||
map["in:tel"] = "Telugu";
|
||||
map["in:urd"] = "Urdu";
|
||||
map["ba"] = "Bosnian";
|
||||
map["br"] = "Portuguese";
|
||||
map["br:nodeadkeys"] = "Portuguese";
|
||||
map["bg"] = "Bulgarian";
|
||||
map["bg:phonetic"] = "Bulgarian";
|
||||
map["mm"] = "Burmese";
|
||||
map["ca"] = "English";
|
||||
map["ca:fr-dvorak"] = "French";
|
||||
map["ca:fr-legacy"] = "French";
|
||||
map["ca:multi"] = "English";
|
||||
map["ca:multi-2gr"] = "English";
|
||||
map["ca:ike"] = "Inuktitut";
|
||||
map["hr"] = "Croatian";
|
||||
map["hr:us"] = "Croatian";
|
||||
map["cz"] = "Czech";
|
||||
map["cz:bksl"] = "Czech";
|
||||
map["cz:qwerty"] = "Czech";
|
||||
map["cz:qwerty_bksl"] = "Czech";
|
||||
map["dk"] = "Danish";
|
||||
map["dk:nodeadkeys"] = "Danish";
|
||||
map["nl"] = "Dutch";
|
||||
map["bt"] = "Bhutani";
|
||||
map["ee"] = "Estonian";
|
||||
map["ee:nodeadkeys"] = "Estonian";
|
||||
map["ir"] = "Persian";
|
||||
map["fo"] = "Faroese";
|
||||
map["fo:nodeadkeys"] = "Faroese";
|
||||
map["fi"] = "Finnish";
|
||||
map["fi:nodeadkeys"] = "Finnish";
|
||||
map["fi:smi"] = "Finnish";
|
||||
map["fr"] = "French";
|
||||
map["fr:nodeadkeys"] = "French";
|
||||
map["fr:sundeadkeys"] = "French";
|
||||
map["fr:latin9"] = "French";
|
||||
map["fr:latin9_nodeadkeys"] = "French";
|
||||
map["fr:latin9_sundeadkeys"] = "French";
|
||||
map["fr:dvorak"] = "French";
|
||||
map["ge"] = "Georgian";
|
||||
map["ge:ru"] = "Russian";
|
||||
map["de"] = "German";
|
||||
map["de:deadacute"] = "German";
|
||||
map["de:deadgraveacute"] = "German";
|
||||
map["de:nodeadkeys"] = "German";
|
||||
map["de:ro"] = "Romanian";
|
||||
map["de:ro_nodeadkeys"] = "Romanian";
|
||||
map["de:dvorak"] = "German";
|
||||
map["gr"] = "Greek";
|
||||
map["gr:extended"] = "Greek";
|
||||
map["gr:nodeadkeys"] = "Greek";
|
||||
map["gr:polytonic"] = "Greek";
|
||||
map["hu"] = "Hungarian";
|
||||
map["hu:standard"] = "Hungarian";
|
||||
map["hu:nodeadkeys"] = "Hungarian";
|
||||
map["hu:qwerty"] = "Hungarian";
|
||||
map["hu:101_qwertz_comma_dead"] = "Hungarian";
|
||||
map["hu:101_qwertz_comma_nodead"] = "Hungarian";
|
||||
map["hu:101_qwertz_dot_dead"] = "Hungarian";
|
||||
map["hu:101_qwertz_dot_nodead"] = "Hungarian";
|
||||
map["hu:101_qwerty_comma_dead"] = "Hungarian";
|
||||
map["hu:101_qwerty_comma_nodead"] = "Hungarian";
|
||||
map["hu:101_qwerty_dot_dead"] = "Hungarian";
|
||||
map["hu:101_qwerty_dot_nodead"] = "Hungarian";
|
||||
map["hu:102_qwertz_comma_dead"] = "Hungarian";
|
||||
map["hu:102_qwertz_comma_nodead"] = "Hungarian";
|
||||
map["hu:102_qwertz_dot_dead"] = "Hungarian";
|
||||
map["hu:102_qwertz_dot_nodead"] = "Hungarian";
|
||||
map["hu:102_qwerty_comma_dead"] = "Hungarian";
|
||||
map["hu:102_qwerty_comma_nodead"] = "Hungarian";
|
||||
map["hu:102_qwerty_dot_dead"] = "Hungarian";
|
||||
map["hu:102_qwerty_dot_nodead"] = "Hungarian";
|
||||
map["is"] = "Icelandic";
|
||||
map["is:Sundeadkeys"] = "Icelandic";
|
||||
map["is:nodeadkeys"] = "Icelandic";
|
||||
map["il"] = "Hebrew";
|
||||
map["il:lyx"] = "Hebrew";
|
||||
map["il:si1452"] = "Hebrew";
|
||||
map["il:phonetic"] = "Hebrew";
|
||||
map["it"] = "Italian";
|
||||
map["it:nodeadkeys"] = "Italian";
|
||||
map["jp"] = "Japanese";
|
||||
map["kg"] = "Kirghiz";
|
||||
map["la"] = "Laothian";
|
||||
map["latam"] = "Spanish";
|
||||
map["latam:nodeadkeys"] = "Spanish";
|
||||
map["latam:sundeadkeys"] = "Spanish";
|
||||
map["lt"] = "Lithuanian";
|
||||
map["lt:std"] = "Lithuanian";
|
||||
map["lt:us"] = "Lithuanian";
|
||||
map["lv"] = "Latvian";
|
||||
map["lv:apostrophe"] = "Latvian";
|
||||
map["lv:tilde"] = "Latvian";
|
||||
map["lv:fkey"] = "Latvian";
|
||||
map["mao"] = "Maori";
|
||||
map["mkd"] = "Macedonian";
|
||||
map["mkd:nodeadkeys"] = "Macedonian";
|
||||
map["mt"] = "Maltese";
|
||||
map["mt:us"] = "Maltese";
|
||||
map["mn"] = "Mongolian";
|
||||
map["no"] = "Norwegian";
|
||||
map["no:nodeadkeys"] = "Norwegian";
|
||||
map["no:dvorak"] = "Norwegian";
|
||||
map["no:smi"] = "Norwegian";
|
||||
map["no:smi_nodeadkeys"] = "Norwegian";
|
||||
map["pl"] = "Polish";
|
||||
map["pl:qwertz"] = "Polish";
|
||||
map["pl:dvorak"] = "Polish";
|
||||
map["pl:dvorak_quotes"] = "Polish";
|
||||
map["pl:dvorak_altquotes"] = "Polish";
|
||||
map["pt"] = "Portuguese";
|
||||
map["pt:nodeadkeys"] = "Portuguese";
|
||||
map["pt:sundeadkeys"] = "Portuguese";
|
||||
map["ro"] = "Romanian";
|
||||
map["ro:us"] = "English";
|
||||
map["ro:de"] = "German";
|
||||
map["ru"] = "Russian";
|
||||
map["ru:phonetic"] = "Russian";
|
||||
map["ru:typewriter"] = "Russian";
|
||||
map["ru:winkeys"] = "Russian";
|
||||
map["srp"] = "Serbian";
|
||||
map["srp:yz"] = "Serbian";
|
||||
map["srp:latin"] = "Serbian";
|
||||
map["srp:latinunicode"] = "Serbian";
|
||||
map["srp:latinyz"] = "Serbian";
|
||||
map["srp:latinunicodeyz"] = "Serbian";
|
||||
map["srp:alternatequotes"] = "Serbian";
|
||||
map["srp:latinalternatequotes"] = "Serbian";
|
||||
map["si"] = "Slovenian";
|
||||
map["sk"] = "Slovak";
|
||||
map["sk:bksl"] = "Slovak";
|
||||
map["sk:qwerty"] = "Slovak";
|
||||
map["sk:qwerty_bksl"] = "Slovak";
|
||||
map["es"] = "Spanish";
|
||||
map["es:nodeadkeys"] = "Spanish";
|
||||
map["es:sundeadkeys"] = "Spanish";
|
||||
map["es:dvorak"] = "Spanish";
|
||||
map["se"] = "Swedish";
|
||||
map["se:nodeadkeys"] = "Swedish";
|
||||
map["se:dvorak"] = "Swedish";
|
||||
map["se:rus"] = "Russian";
|
||||
map["se:rus_nodeadkeys"] = "Russian";
|
||||
map["se:smi"] = "Swedish";
|
||||
map["ch"] = "German";
|
||||
map["ch:de_nodeadkeys"] = "German";
|
||||
map["ch:de_sundeadkeys"] = "German";
|
||||
map["ch:fr"] = "French";
|
||||
map["ch:fr_nodeadkeys"] = "French";
|
||||
map["ch:fr_sundeadkeys"] = "French";
|
||||
map["sy"] = "Arabic";
|
||||
map["sy:syc"] = "Arabic";
|
||||
map["sy:syc_phonetic"] = "Arabic";
|
||||
map["tj"] = "Tajik";
|
||||
map["lk"] = "Singhalese";
|
||||
map["lk:tam_unicode"] = "Tamil";
|
||||
map["lk:tam_TAB"] = "Tamil";
|
||||
map["lk:tam_TSCII"] = "Tamil";
|
||||
map["lk:sin_phonetic"] = "Singhalese";
|
||||
map["th"] = "Thai";
|
||||
map["th:tis"] = "Thai";
|
||||
map["th:pat"] = "Thai";
|
||||
map["tr"] = "Turkish";
|
||||
map["tr:f"] = "Turkish";
|
||||
map["tr:alt"] = "Turkish";
|
||||
map["ua"] = "Ukrainian";
|
||||
map["ua:phonetic"] = "Ukrainian";
|
||||
map["ua:typewriter"] = "Ukrainian";
|
||||
map["ua:winkeys"] = "Ukrainian";
|
||||
map["ua:rstu"] = "Ukrainian";
|
||||
map["ua:rstu_ru"] = "Ukrainian";
|
||||
map["gb"] = "English";
|
||||
map["gb:intl"] = "English";
|
||||
map["gb:dvorak"] = "English";
|
||||
map["uz"] = "Uzbek";
|
||||
map["vn"] = "Vietnamese";
|
||||
map["nec_vndr/jp"] = "Japanese";
|
||||
map["ie"] = "Irish";
|
||||
map["ie:CloGaelach"] = "Gaelic";
|
||||
map["ie:UnicodeExpert"] = "Irish";
|
||||
map["ie:ogam"] = "Gaelic";
|
||||
map["ie:ogam_is434"] = "Gaelic";
|
||||
map["pk"] = "Urdu";
|
||||
initialized = true;
|
||||
}
|
||||
return map.value(v, v);
|
||||
}
|
||||
|
||||
QString mapDirection(const QString &v)
|
||||
{
|
||||
static QMap<QString, QString> map;
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
// 1. xkbdata-X11R7.0-1.0.1/symbols% grep -l '\([Hh]ebrew\|[Aa]rabic\)' **/*
|
||||
map["Arabic"] = "Qt::RightToLeft";
|
||||
map["Persian"] = "Qt::RightToLeft";
|
||||
map["Urdu"] = "Qt::RightToLeft";
|
||||
initialized = true;
|
||||
}
|
||||
return map.value(v, "Qt::LeftToRight");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s <xml input file>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QFile file;
|
||||
file.setFileName(argv[1]);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
fprintf(stderr, "cannot open %s: %s\n", qPrintable(file.fileName()), qPrintable(file.errorString()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
QDomDocument dom;
|
||||
dom.setContent(&file);
|
||||
|
||||
if (dom.documentElement().tagName() != QLatin1String("xkbConfigRegistry")) {
|
||||
fprintf(stderr, "cannot parse %s, this is not an XKB config file\n", qPrintable(file.fileName()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
QDomElement layoutList = find("layoutList", dom.documentElement());
|
||||
if (layoutList.isNull()) {
|
||||
fprintf(stderr, "cannot parse %s, this is not an XKB config file\n", qPrintable(file.fileName()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
QList<XKBLayout> layouts = findLayouts(layoutList);
|
||||
|
||||
// copyright and stuff
|
||||
printf("/****************************************************************************\n"
|
||||
"**\n"
|
||||
"** Copyright (C) 2015 The Qt Company Ltd.\n"
|
||||
"** Contact: http://www.qt.io/licensing/\n"
|
||||
"**\n"
|
||||
"** This file is part of the QtGui module of the Qt Toolkit.\n"
|
||||
"**\n"
|
||||
"** $QT_BEGIN_LICENSE:LGPL$\n"
|
||||
"** Commercial License Usage\n"
|
||||
"** Licensees holding valid commercial Qt licenses may use this file in\n"
|
||||
"** accordance with the commercial license agreement provided with the\n"
|
||||
"** Software or, alternatively, in accordance with the terms contained in\n"
|
||||
"** a written agreement between you and The Qt Company. For licensing terms\n"
|
||||
"** and conditions see http://www.qt.io/terms-conditions. For further\n"
|
||||
"** information use the contact form at http://www.qt.io/contact-us.\n"
|
||||
"**\n"
|
||||
"** GNU Lesser General Public License Usage\n"
|
||||
"** Alternatively, this file may be used under the terms of the GNU Lesser\n"
|
||||
"** General Public License version 2.1 or version 3 as published by the Free\n"
|
||||
"** Software Foundation and appearing in the file LICENSE.LGPLv21 and\n"
|
||||
"** LICENSE.LGPLv3 included in the packaging of this file. Please review the\n"
|
||||
"** following information to ensure the GNU Lesser General Public License\n"
|
||||
"** requirements will be met: https://www.gnu.org/licenses/lgpl.html and\n"
|
||||
"** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n"
|
||||
"**\n"
|
||||
"** As a special exception, The Qt Company gives you certain additional\n"
|
||||
"** rights. These rights are described in The Qt Company LGPL Exception\n"
|
||||
"** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n"
|
||||
"**\n"
|
||||
"** GNU General Public License Usage\n"
|
||||
"** Alternatively, this file may be used under the terms of the GNU\n"
|
||||
"** General Public License version 3.0 as published by the Free Software\n"
|
||||
"** Foundation and appearing in the file LICENSE.GPL included in the\n"
|
||||
"** packaging of this file. Please review the following information to\n"
|
||||
"** ensure the GNU General Public License version 3.0 requirements will be\n"
|
||||
"** met: http://www.gnu.org/copyleft/gpl.html.\n"
|
||||
"**\n"
|
||||
"** $QT_END_LICENSE$\n"
|
||||
"**\n"
|
||||
"****************************************************************************/\n"
|
||||
"\n"
|
||||
"// This file is auto-generated, do not edit!\n"
|
||||
"// (Generated using util/xkbdatagen)\n"
|
||||
"\n");
|
||||
|
||||
// data structure
|
||||
printf("static struct {\n"
|
||||
" const char *layout;\n"
|
||||
" const char *variant; // 0 means any variant\n"
|
||||
" Qt::LayoutDirection direction;\n"
|
||||
" QLocale::Language language;\n"
|
||||
" QLocale::Country country;\n"
|
||||
"} xkbLayoutData[] = {\n");
|
||||
|
||||
// contents
|
||||
foreach (const XKBLayout &l, layouts) {
|
||||
const QString country = mapCountry(l.description);
|
||||
QString lang = mapLanguage(l.name);
|
||||
if (lang.isEmpty())
|
||||
lang = "C";
|
||||
printf(" // name = %s, description = %s\n"
|
||||
" { \"%s\", \"\", %s, QLocale::%s, QLocale::%s },\n",
|
||||
l.name.toAscii().constData(),
|
||||
l.description.toAscii().constData(),
|
||||
l.name.toAscii().constData(),
|
||||
mapDirection(lang).toAscii().constData(),
|
||||
lang.toAscii().constData(),
|
||||
country.toAscii().constData());
|
||||
foreach (const QString &v, l.variants) {
|
||||
QString vlang = mapLanguage(l.name + ":" + v);
|
||||
if (vlang.isEmpty())
|
||||
vlang = "C";
|
||||
printf(" // name = %s:%s, description = %s\n"
|
||||
" { \"%s\", \"%s\", %s, QLocale::%s, QLocale::%s },\n",
|
||||
l.name.toAscii().constData(),
|
||||
v.toAscii().constData(),
|
||||
l.description.toAscii().constData(),
|
||||
l.name.toAscii().constData(),
|
||||
v.toAscii().constData(),
|
||||
mapDirection(vlang).toAscii().constData(),
|
||||
vlang.toAscii().constData(),
|
||||
country.toAscii().constData());
|
||||
}
|
||||
}
|
||||
|
||||
// wrapping up
|
||||
printf(" { 0, 0, Qt::LeftToRight, QLocale::C, QLocale::AnyCountry }\n"
|
||||
"};\n");
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue