2016-04-16 17:51:25 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-16 17:51:25 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-16 17:51:25 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2017-02-21 17:34:19 +00:00
|
|
|
#include <map>
|
|
|
|
#include <functional>
|
2016-04-16 17:51:25 +00:00
|
|
|
#include <QtCore/QString>
|
2016-04-18 20:33:43 +00:00
|
|
|
#include <QtCore/QSet>
|
|
|
|
#include "codegen/common/cpp_file.h"
|
|
|
|
#include "codegen/style/structure_types.h"
|
2016-04-16 17:51:25 +00:00
|
|
|
|
|
|
|
namespace codegen {
|
|
|
|
namespace style {
|
2016-04-17 09:30:14 +00:00
|
|
|
namespace structure {
|
2016-04-18 20:33:43 +00:00
|
|
|
class Module;
|
2016-04-17 09:30:14 +00:00
|
|
|
} // namespace structure
|
2016-04-16 17:51:25 +00:00
|
|
|
|
|
|
|
class Generator {
|
|
|
|
public:
|
2016-10-28 12:44:28 +00:00
|
|
|
Generator(const structure::Module &module, const QString &destBasePath, const common::ProjectInfo &project, bool isPalette);
|
2016-04-16 17:51:25 +00:00
|
|
|
Generator(const Generator &other) = delete;
|
|
|
|
Generator &operator=(const Generator &other) = delete;
|
|
|
|
|
2016-04-18 20:33:43 +00:00
|
|
|
bool writeHeader();
|
|
|
|
bool writeSource();
|
2016-04-16 17:51:25 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-18 20:33:43 +00:00
|
|
|
QString typeToString(structure::Type type) const;
|
|
|
|
QString typeToDefaultValue(structure::Type type) const;
|
|
|
|
QString valueAssignmentCode(structure::Value value) const;
|
|
|
|
|
|
|
|
bool writeHeaderStyleNamespace();
|
2016-07-11 18:05:46 +00:00
|
|
|
bool writeStructsForwardDeclarations();
|
2016-04-18 20:33:43 +00:00
|
|
|
bool writeStructsDefinitions();
|
2016-10-28 12:44:28 +00:00
|
|
|
bool writePaletteDefinition();
|
2016-04-18 20:33:43 +00:00
|
|
|
bool writeRefsDeclarations();
|
|
|
|
|
|
|
|
bool writeIncludesInSource();
|
|
|
|
bool writeVariableDefinitions();
|
|
|
|
bool writeRefsDefinition();
|
2016-10-28 12:44:28 +00:00
|
|
|
bool writeSetPaletteColor();
|
2016-04-18 20:33:43 +00:00
|
|
|
bool writeVariableInit();
|
2016-04-21 17:57:29 +00:00
|
|
|
bool writePxValuesInit();
|
|
|
|
bool writeFontFamiliesInit();
|
|
|
|
bool writeIconValues();
|
|
|
|
bool writeIconsInit();
|
2016-04-18 20:33:43 +00:00
|
|
|
|
|
|
|
bool collectUniqueValues();
|
|
|
|
|
|
|
|
const structure::Module &module_;
|
|
|
|
QString basePath_, baseName_;
|
|
|
|
const common::ProjectInfo &project_;
|
|
|
|
std::unique_ptr<common::CppFile> source_, header_;
|
2016-10-28 12:44:28 +00:00
|
|
|
bool isPalette_ = false;
|
2016-04-17 09:30:14 +00:00
|
|
|
|
2016-04-18 20:33:43 +00:00
|
|
|
QMap<int, bool> pxValues_;
|
2016-04-21 17:57:29 +00:00
|
|
|
QMap<std::string, int> fontFamilies_;
|
|
|
|
QMap<QString, int> iconMasks_; // icon file -> index
|
2017-02-21 17:34:19 +00:00
|
|
|
std::map<QString, int, std::greater<QString>> paletteIndices_;
|
2016-04-17 09:30:14 +00:00
|
|
|
|
2016-04-16 17:51:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace style
|
|
|
|
} // namespace codegen
|