OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/xcode_object.h" | 5 #include "tools/gn/xcode_object.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 buffer << '"'; | 89 buffer << '"'; |
90 return buffer.str(); | 90 return buffer.str(); |
91 } | 91 } |
92 | 92 |
93 struct SourceTypeForExt { | 93 struct SourceTypeForExt { |
94 const char* ext; | 94 const char* ext; |
95 const char* source_type; | 95 const char* source_type; |
96 }; | 96 }; |
97 | 97 |
98 const SourceTypeForExt kSourceTypeForExt[] = { | 98 const SourceTypeForExt kSourceTypeForExt[] = { |
99 {".a", "archive.ar"}, | 99 {"a", "archive.ar"}, |
100 {".app", "wrapper.application"}, | 100 {"app", "wrapper.application"}, |
101 {".appex", "wrapper.app-extension"}, | 101 {"appex", "wrapper.app-extension"}, |
102 {".bdic", "file"}, | 102 {"bdic", "file"}, |
103 {".bundle", "wrapper.cfbundle"}, | 103 {"bundle", "wrapper.cfbundle"}, |
104 {".c", "sourcecode.c.c"}, | 104 {"c", "sourcecode.c.c"}, |
105 {".cc", "sourcecode.cpp.cpp"}, | 105 {"cc", "sourcecode.cpp.cpp"}, |
106 {".cpp", "sourcecode.cpp.cpp"}, | 106 {"cpp", "sourcecode.cpp.cpp"}, |
107 {".css", "text.css"}, | 107 {"css", "text.css"}, |
108 {".cxx", "sourcecode.cpp.cpp"}, | 108 {"cxx", "sourcecode.cpp.cpp"}, |
109 {".dart", "sourcecode"}, | 109 {"dart", "sourcecode"}, |
110 {".dylib", "compiled.mach-o.dylib"}, | 110 {"dylib", "compiled.mach-o.dylib"}, |
111 {".framework", "wrapper.framework"}, | 111 {"framework", "wrapper.framework"}, |
112 {".h", "sourcecode.c.h"}, | 112 {"h", "sourcecode.c.h"}, |
113 {".hxx", "sourcecode.cpp.h"}, | 113 {"hxx", "sourcecode.cpp.h"}, |
114 {".icns", "image.icns"}, | 114 {"icns", "image.icns"}, |
115 {".java", "sourcecode.java"}, | 115 {"java", "sourcecode.java"}, |
116 {".js", "sourcecode.javascript"}, | 116 {"js", "sourcecode.javascript"}, |
117 {".kext", "wrapper.kext"}, | 117 {"kext", "wrapper.kext"}, |
118 {".m", "sourcecode.c.objc"}, | 118 {"m", "sourcecode.c.objc"}, |
119 {".mm", "sourcecode.cpp.objcpp"}, | 119 {"mm", "sourcecode.cpp.objcpp"}, |
120 {".nib", "wrapper.nib"}, | 120 {"nib", "wrapper.nib"}, |
121 {".o", "compiled.mach-o.objfile"}, | 121 {"o", "compiled.mach-o.objfile"}, |
122 {".pdf", "image.pdf"}, | 122 {"pdf", "image.pdf"}, |
123 {".pl", "text.script.perl"}, | 123 {"pl", "text.script.perl"}, |
124 {".plist", "text.plist.xml"}, | 124 {"plist", "text.plist.xml"}, |
125 {".pm", "text.script.perl"}, | 125 {"pm", "text.script.perl"}, |
126 {".png", "image.png"}, | 126 {"png", "image.png"}, |
127 {".py", "text.script.python"}, | 127 {"py", "text.script.python"}, |
128 {".r", "sourcecode.rez"}, | 128 {"r", "sourcecode.rez"}, |
129 {".rez", "sourcecode.rez"}, | 129 {"rez", "sourcecode.rez"}, |
130 {".s", "sourcecode.asm"}, | 130 {"s", "sourcecode.asm"}, |
131 {".storyboard", "file.storyboard"}, | 131 {"storyboard", "file.storyboard"}, |
132 {".strings", "text.plist.strings"}, | 132 {"strings", "text.plist.strings"}, |
133 {".swift", "sourcecode.swift"}, | 133 {"swift", "sourcecode.swift"}, |
134 {".ttf", "file"}, | 134 {"ttf", "file"}, |
135 {".xcassets", "folder.assetcatalog"}, | 135 {"xcassets", "folder.assetcatalog"}, |
136 {".xcconfig", "text.xcconfig"}, | 136 {"xcconfig", "text.xcconfig"}, |
137 {".xcdatamodel", "wrapper.xcdatamodel"}, | 137 {"xcdatamodel", "wrapper.xcdatamodel"}, |
138 {".xcdatamodeld", "wrapper.xcdatamodeld"}, | 138 {"xcdatamodeld", "wrapper.xcdatamodeld"}, |
139 {".xib", "file.xib"}, | 139 {"xib", "file.xib"}, |
140 {".y", "sourcecode.yacc"}, | 140 {"y", "sourcecode.yacc"}, |
141 }; | 141 }; |
142 | 142 |
143 const char* GetSourceType(const base::StringPiece& ext) { | 143 const char* GetSourceType(const base::StringPiece& ext) { |
144 for (size_t i = 0; i < arraysize(kSourceTypeForExt); ++i) { | 144 for (size_t i = 0; i < arraysize(kSourceTypeForExt); ++i) { |
145 if (kSourceTypeForExt[i].ext == ext) | 145 if (kSourceTypeForExt[i].ext == ext) |
146 return kSourceTypeForExt[i].source_type; | 146 return kSourceTypeForExt[i].source_type; |
147 } | 147 } |
148 | 148 |
149 return "text"; | 149 return "text"; |
150 } | 150 } |
151 | 151 |
152 bool HasExplicitFileType(const base::StringPiece& ext) { | 152 bool HasExplicitFileType(const base::StringPiece& ext) { |
153 return ext == ".dart"; | 153 return ext == "dart"; |
154 } | 154 } |
155 | 155 |
156 bool IsSourceFileForIndexing(const base::StringPiece& ext) { | 156 bool IsSourceFileForIndexing(const base::StringPiece& ext) { |
157 return ext == ".c" || ext == ".cc" || ext == ".cpp" || ext == ".cxx" || | 157 return ext == "c" || ext == "cc" || ext == "cpp" || ext == "cxx" || |
158 ext == ".m" || ext == ".mm"; | 158 ext == "m" || ext == "mm"; |
159 } | 159 } |
160 | 160 |
161 void PrintValue(std::ostream& out, IndentRules rules, unsigned value) { | 161 void PrintValue(std::ostream& out, IndentRules rules, unsigned value) { |
162 out << value; | 162 out << value; |
163 } | 163 } |
164 | 164 |
165 void PrintValue(std::ostream& out, IndentRules rules, const char* value) { | 165 void PrintValue(std::ostream& out, IndentRules rules, const char* value) { |
166 out << EncodeString(value); | 166 out << EncodeString(value); |
167 } | 167 } |
168 | 168 |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 const std::string indent_str(indent, '\t'); | 859 const std::string indent_str(indent, '\t'); |
860 const IndentRules rules = {false, indent + 1}; | 860 const IndentRules rules = {false, indent + 1}; |
861 out << indent_str << Reference() << " = {\n"; | 861 out << indent_str << Reference() << " = {\n"; |
862 PrintProperty(out, rules, "isa", ToString(Class())); | 862 PrintProperty(out, rules, "isa", ToString(Class())); |
863 PrintProperty(out, rules, "buildConfigurations", configurations_); | 863 PrintProperty(out, rules, "buildConfigurations", configurations_); |
864 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); | 864 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); |
865 PrintProperty(out, rules, "defaultConfigurationName", | 865 PrintProperty(out, rules, "defaultConfigurationName", |
866 configurations_[0]->Name()); | 866 configurations_[0]->Name()); |
867 out << indent_str << "};\n"; | 867 out << indent_str << "};\n"; |
868 } | 868 } |
OLD | NEW |