public static void WriteDictKeyValue(StringBuilder sb, string key, PBXElement value, int indent, bool compact, PropertyCommentChecker checker, GUIDToCommentMap comments) { if (!compact) { sb.Append("\n"); sb.Append(GetIndent(indent)); } WriteStringImpl(sb, key, checker.CheckKeyInDict(key), comments); sb.Append(" = "); if (value is PBXElementString) { WriteStringImpl(sb, value.AsString(), checker.CheckStringValueInDict(key, value.AsString()), comments); } else if (value is PBXElementDict) { WriteDict(sb, value.AsDict(), indent, compact, checker.NextLevel(key), comments); } else if (value is PBXElementArray) { WriteArray(sb, value.AsArray(), indent, compact, checker.NextLevel(key), comments); } sb.Append(";"); if (compact) { sb.Append(" "); } }
public static PBXElementDict ParseTreeAST(TreeAST ast, TokenList tokens, string text) { var el = new PBXElementDict(); foreach (var kv in ast.values) { PBXElementString key = ParseIdentifierAST(kv.key, tokens, text); PBXElement value = ParseValueAST(kv.value, tokens, text); el[key.value] = value; } return(el); }
public void ReadFromStream(TextReader sr) { this.Clear(); this.m_RootElements = PBXProjectData.ParseContent(sr.ReadToEnd()); if (!this.m_RootElements.Contains("objects")) { throw new Exception("Invalid PBX project file: no objects element"); } PBXElementDict pbxElementDict1 = this.m_RootElements["objects"].AsDict(); this.m_RootElements.Remove("objects"); this.m_RootElements.SetString("objects", "OBJMARKER"); if (this.m_RootElements.Contains("objectVersion")) { this.m_ObjectVersion = this.m_RootElements["objectVersion"].AsString(); this.m_RootElements.Remove("objectVersion"); } List <string> allGuids = new List <string>(); string prevSectionName = (string)null; foreach (KeyValuePair <string, PBXElement> keyValuePair in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1.values) { allGuids.Add(keyValuePair.Key); PBXElement pbxElement = keyValuePair.Value; if (!(pbxElement is PBXElementDict) || !pbxElement.AsDict().Contains("isa")) { this.m_UnknownObjects.values.Add(keyValuePair.Key, pbxElement); } else { PBXElementDict pbxElementDict2 = pbxElement.AsDict(); string index1 = pbxElementDict2["isa"].AsString(); if (this.m_Section.ContainsKey(index1)) { this.m_Section[index1].AddObject(keyValuePair.Key, pbxElementDict2); } else { KnownSectionBase <PBXObjectData> knownSectionBase; if (this.m_UnknownSections.ContainsKey(index1)) { knownSectionBase = this.m_UnknownSections[index1]; } else { knownSectionBase = new KnownSectionBase <PBXObjectData>(index1); this.m_UnknownSections.Add(index1, knownSectionBase); } knownSectionBase.AddObject(keyValuePair.Key, pbxElementDict2); if (!this.m_SectionOrder.Contains(index1)) { int index2 = 0; if (prevSectionName != null) { index2 = this.m_SectionOrder.FindIndex((Predicate <string>)(x => x == prevSectionName)) + 1; } this.m_SectionOrder.Insert(index2, index1); } } prevSectionName = index1; } } this.RepairStructure(allGuids); this.RefreshAuxMaps(); }
public void ReadFromStream(TextReader sr) { this.Clear(); this.m_RootElements = PBXProjectData.ParseContent(sr.ReadToEnd()); if (!this.m_RootElements.Contains("objects")) { throw new Exception("Invalid PBX project file: no objects element"); } PBXElementDict pbxElementDict1 = this.m_RootElements["objects"].AsDict(); this.m_RootElements.Remove("objects"); this.m_RootElements.SetString("objects", "OBJMARKER"); if (this.m_RootElements.Contains("objectVersion")) { this.m_ObjectVersion = this.m_RootElements["objectVersion"].AsString(); this.m_RootElements.Remove("objectVersion"); } List <string> allGuids = new List <string>(); // ISSUE: reference to a compiler-generated field string prevSectionName = null; foreach (KeyValuePair <string, PBXElement> keyValuePair in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1.values) { allGuids.Add(keyValuePair.Key); PBXElement pbxElement = keyValuePair.Value; if (!(pbxElement is PBXElementDict) || !pbxElement.AsDict().Contains("isa")) { this.m_UnknownObjects.values.Add(keyValuePair.Key, pbxElement); } else { PBXElementDict pbxElementDict2 = pbxElement.AsDict(); string index1 = pbxElementDict2["isa"].AsString(); if (this.m_Section.ContainsKey(index1)) { this.m_Section[index1].AddObject(keyValuePair.Key, pbxElementDict2); } else { KnownSectionBase <PBXObjectData> knownSectionBase; if (this.m_UnknownSections.ContainsKey(index1)) { knownSectionBase = this.m_UnknownSections[index1]; } else { knownSectionBase = new KnownSectionBase <PBXObjectData>(index1); this.m_UnknownSections.Add(index1, knownSectionBase); } knownSectionBase.AddObject(keyValuePair.Key, pbxElementDict2); if (!this.m_SectionOrder.Contains(index1)) { int pos = 0; if (prevSectionName != null) { // this never fails, because we already added any previous unknown sections // to m_SectionOrder pos = m_SectionOrder.FindIndex(x => x == prevSectionName); pos += 1; } m_SectionOrder.Insert(pos, index1); } } // ISSUE: reference to a compiler-generated field prevSectionName = index1; } } this.RepairStructure(allGuids); this.RefreshAuxMaps(); }