2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Members block in group conversation view finished (except Xcode project).

This commit is contained in:
John Preston
2016-06-20 14:31:12 +03:00
parent f0a8356ff0
commit 7db7b177c0
19 changed files with 304 additions and 19 deletions

View File

@@ -646,6 +646,10 @@ bool Generator::collectUniqueValues() {
int iconMaskIndex = 0;
std::function<bool(const Variable&)> collector = [this, &collector, &fontFamilyIndex, &iconMaskIndex](const Variable &variable) {
auto value = variable.value;
if (!value.copyOf().isEmpty()) {
return true;
}
switch (value.type().tag) {
case Tag::Invalid:
case Tag::Int:

View File

@@ -52,7 +52,7 @@ const Struct *Module::findStruct(const FullName &name) const {
return result;
}
for (const auto &module : included_) {
if (auto result = findStructInModule(name, *module)) {
if (auto result = module->findStruct(name)) {
return result;
}
}
@@ -68,12 +68,14 @@ bool Module::addVariable(const Variable &value) {
return true;
}
const Variable *Module::findVariable(const FullName &name) const {
const Variable *Module::findVariable(const FullName &name, bool *outFromThisModule) const {
if (auto result = findVariableInModule(name, *this)) {
if (outFromThisModule) *outFromThisModule = true;
return result;
}
for (const auto &module : included_) {
if (auto result = findVariableInModule(name, *module)) {
if (auto result = module->findVariable(name)) {
if (outFromThisModule) *outFromThisModule = false;
return result;
}
}

View File

@@ -75,7 +75,7 @@ public:
// Returns false if there is a variable with such name already.
bool addVariable(const Variable &value);
// Returns nullptr if there is no such variable in result_ or any of included modules.
const Variable *findVariable(const FullName &name) const;
const Variable *findVariable(const FullName &name, bool *outFromThisModule = nullptr) const;
bool hasVariables() const {
return !variables_.isEmpty();
}

View File

@@ -43,6 +43,7 @@ constexpr int kErrorUnknownField = 803;
constexpr int kErrorIdentifierNotFound = 804;
constexpr int kErrorAlreadyDefined = 805;
constexpr int kErrorBadString = 806;
constexpr int kErrorIconDuplicate = 807;
QString findInputFile(const Options &options) {
for (const auto &dir : options.includePaths) {
@@ -351,7 +352,8 @@ structure::Value ParsedFile::defaultConstructedStruct(const structure::FullName
}
void ParsedFile::applyStructParent(structure::Value &result, const structure::FullName &parentName) {
if (auto parent = module_->findVariable(parentName)) {
bool fromTheSameModule = false;
if (auto parent = module_->findVariable(parentName, &fromTheSameModule)) {
if (parent->value.type() != result.type()) {
logErrorTypeMismatch() << "parent '" << logFullName(parentName) << "' has type '" << logType(parent->value.type()) << "' while child value has type " << logType(result.type());
return;
@@ -374,6 +376,22 @@ void ParsedFile::applyStructParent(structure::Value &result, const structure::Fu
const auto &srcValue(srcField.variable.value);
auto &dstValue(dstField.variable.value);
logAssert(srcValue.type() == dstValue.type()) << "struct field type check failed";
// Optimization: don't let the style files to contain unnamed inherited
// icons from the other (included) style files, because they will
// duplicate the binary data across different style c++ source files.
//
// Example:
// a.style has "A: Struct { icon: icon { ..file.. } };" and
// b.style has "B: Struct(A) { .. };" with non-overriden icon field.
// Then both style_a.cpp and style_b.cpp will contain binary data of "file".
if (!fromTheSameModule
&& srcValue.type().tag == structure::TypeTag::Icon
&& !srcValue.Icon().parts.empty()
&& srcValue.copyOf().isEmpty()) {
logError(kErrorIconDuplicate) << "an unnamed icon field '" << logFullName(srcField.variable.name) << "' is inherited from parent '" << logFullName(parentName) << "'";
return;
}
dstValue = srcValue;
dstField.status = Status::Implicit;
}