mirror of https://github.com/procxx/kepka.git
Fix generator
This commit is contained in:
parent
0c4399431a
commit
af4cfd8a41
|
@ -236,8 +236,7 @@ bool Generator::writeSource() {
|
||||||
|
|
||||||
if (module_.hasVariables()) {
|
if (module_.hasVariables()) {
|
||||||
source_->pushNamespace().newline();
|
source_->pushNamespace().newline();
|
||||||
source_->stream() << R"code(
|
source_->stream() << R"code(bool inited = false;
|
||||||
bool inited = false;
|
|
||||||
|
|
||||||
class Module_)code" << baseName_<< R"code( : public style::internal::ModuleBase {
|
class Module_)code" << baseName_<< R"code( : public style::internal::ModuleBase {
|
||||||
public:
|
public:
|
||||||
|
@ -443,8 +442,7 @@ bool Generator::writeHeaderStyleNamespace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Generator::writePaletteDefinition() {
|
bool Generator::writePaletteDefinition() {
|
||||||
header_->stream() << R"code(
|
header_->stream() << R"code(class palette {
|
||||||
class palette {
|
|
||||||
public:
|
public:
|
||||||
palette() = default;
|
palette() = default;
|
||||||
palette(const palette &other) = delete;
|
palette(const palette &other) = delete;
|
||||||
|
@ -489,7 +487,6 @@ public:
|
||||||
|
|
||||||
auto count = indexInPalette;
|
auto count = indexInPalette;
|
||||||
header_->stream() << R"code(
|
header_->stream() << R"code(
|
||||||
|
|
||||||
palette &operator=(const palette &other) {
|
palette &operator=(const palette &other) {
|
||||||
auto wasReady = _ready;
|
auto wasReady = _ready;
|
||||||
for (int i = 0; i != kCount; ++i) {
|
for (int i = 0; i != kCount; ++i) {
|
||||||
|
@ -574,8 +571,7 @@ private:
|
||||||
for (int i = 0; i != count; ++i) {
|
for (int i = 0; i != count; ++i) {
|
||||||
header_->stream() << "\t\tdata(" << i << "),\n";
|
header_->stream() << "\t\tdata(" << i << "),\n";
|
||||||
}
|
}
|
||||||
header_->stream() << R"code(
|
header_->stream() << R"code( };
|
||||||
};
|
|
||||||
Status _status[kCount] = { Status::Initial };
|
Status _status[kCount] = { Status::Initial };
|
||||||
bool _ready = false;
|
bool _ready = false;
|
||||||
|
|
||||||
|
@ -592,14 +588,15 @@ void reset();
|
||||||
int indexOfColor(color c);
|
int indexOfColor(color c);
|
||||||
|
|
||||||
struct row {
|
struct row {
|
||||||
QLatin1String name;
|
QLatin1String name;
|
||||||
QLatin1String value;
|
QLatin1String value;
|
||||||
QLatin1String fallback;
|
QLatin1String fallback;
|
||||||
QLatin1String description;
|
QLatin1String description;
|
||||||
};
|
};
|
||||||
QList<row> data();
|
QList<row> data();
|
||||||
|
|
||||||
} // namespace main_palette)code";
|
} // namespace main_palette
|
||||||
|
)code";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -821,8 +818,7 @@ void palette::finalize() {
|
||||||
auto count = indexInPalette;
|
auto count = indexInPalette;
|
||||||
auto checksum = hashCrc32(checksumString.constData(), checksumString.size());
|
auto checksum = hashCrc32(checksumString.constData(), checksumString.size());
|
||||||
|
|
||||||
source_->stream() << R"code(
|
source_->stream() << R"code(}
|
||||||
}
|
|
||||||
|
|
||||||
qint32 palette::Checksum() {
|
qint32 palette::Checksum() {
|
||||||
return )code" << checksum
|
return )code" << checksum
|
||||||
|
@ -830,12 +826,11 @@ qint32 palette::Checksum() {
|
||||||
}\n";
|
}\n";
|
||||||
|
|
||||||
source_->newline().pushNamespace().newline();
|
source_->newline().pushNamespace().newline();
|
||||||
source_->stream() << R"code(
|
source_->stream() << R"code(int getPaletteIndex(QLatin1String name) {
|
||||||
int getPaletteIndex(QLatin1String name) {
|
|
||||||
auto size = name.size();
|
auto size = name.size();
|
||||||
auto data = name.data();
|
auto data = name.data();
|
||||||
)code";
|
)code";
|
||||||
|
// TODO(Randl)
|
||||||
auto tabs = [](int size) { return QString(size, '\t'); };
|
auto tabs = [](int size) { return QString(size, '\t'); };
|
||||||
|
|
||||||
enum class UsedCheckType {
|
enum class UsedCheckType {
|
||||||
|
@ -969,20 +964,18 @@ int getPaletteIndex(QLatin1String name) {
|
||||||
finishChecksTillKey(QString());
|
finishChecksTillKey(QString());
|
||||||
|
|
||||||
source_->stream() << R"code(
|
source_->stream() << R"code(
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
)code";
|
)code";
|
||||||
|
|
||||||
source_->newline().popNamespace().newline();
|
source_->newline().popNamespace().newline();
|
||||||
source_->stream() << R"code(
|
source_->stream() << R"code(QByteArray palette::save() const {
|
||||||
QByteArray palette::save() const {
|
|
||||||
if (!_ready) const_cast<palette*>(this)->finalize();
|
if (!_ready) const_cast<palette*>(this)->finalize();
|
||||||
|
|
||||||
auto result = QByteArray("
|
auto result = QByteArray()code"
|
||||||
<< (count * 4) << ", Qt::Uninitialized);
|
<< (count * 4) << R"code(, Qt::Uninitialized);
|
||||||
for (auto i = 0, index = 0; i != )code"
|
for (auto i = 0, index = 0; i != )code"
|
||||||
<< count << R"code("; ++i) {
|
<< count << R"code(; ++i) {
|
||||||
result[index++] = static_cast<uchar>(data(i)->c.red());
|
result[index++] = static_cast<uchar>(data(i)->c.red());
|
||||||
result[index++] = static_cast<uchar>(data(i)->c.green());
|
result[index++] = static_cast<uchar>(data(i)->c.green());
|
||||||
result[index++] = static_cast<uchar>(data(i)->c.blue());
|
result[index++] = static_cast<uchar>(data(i)->c.blue());
|
||||||
|
@ -1066,7 +1059,6 @@ QList<row> data() {
|
||||||
<< R"code();
|
<< R"code();
|
||||||
|
|
||||||
)code" << dataRows << R"code(
|
)code" << dataRows << R"code(
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,11 +1153,11 @@ bool Generator::writePxValuesInit() {
|
||||||
for (auto i = pxValues_.cbegin(), e = pxValues_.cend(); i != e; ++i) {
|
for (auto i = pxValues_.cbegin(), e = pxValues_.cend(); i != e; ++i) {
|
||||||
source_->stream() << "int " << pxValueName(i.key()) << " = " << i.key() << ";\n";
|
source_->stream() << "int " << pxValueName(i.key()) << " = " << i.key() << ";\n";
|
||||||
}
|
}
|
||||||
source_->stream() << R"code(
|
source_->stream() << R"code(void initPxValues() {
|
||||||
void initPxValues() {
|
|
||||||
if (cRetina()) return;
|
if (cRetina()) return;
|
||||||
|
|
||||||
switch (cScale()) {)code";
|
switch (cScale()) {
|
||||||
|
)code";
|
||||||
for (int i = 1, scalesCount = _scales.size(); i < scalesCount; ++i) {
|
for (int i = 1, scalesCount = _scales.size(); i < scalesCount; ++i) {
|
||||||
source_->stream() << "\tcase " << _scaleNames.at(i) << ":\n";
|
source_->stream() << "\tcase " << _scaleNames.at(i) << ":\n";
|
||||||
for (auto it = pxValues_.cbegin(), e = pxValues_.cend(); it != e; ++it) {
|
for (auto it = pxValues_.cbegin(), e = pxValues_.cend(); it != e; ++it) {
|
||||||
|
|
Loading…
Reference in New Issue