• Home
  • Raw
  • Download

Lines Matching refs:writer

241   CodeWriter writer(kIndent);  in GenerateHeader()  local
243 writer.Write("%s", kGeneratedFileFooterComments); in GenerateHeader()
245 writer.Write("#pragma once\n\n"); in GenerateHeader()
246 writer.Write("%s", kCppHeaderIncludes); in GenerateHeader()
249 writer.Write("namespace %s {\n\n", cpp_namespace.c_str()); in GenerateHeader()
260 writer.Write("\n"); in GenerateHeader()
269 writer.Write("enum class %s {\n", GetCppEnumName(prop).c_str()); in GenerateHeader()
270 writer.Indent(); in GenerateHeader()
273 writer.Write("%s,\n", ToUpper(name).c_str()); in GenerateHeader()
275 writer.Dedent(); in GenerateHeader()
276 writer.Write("};\n\n"); in GenerateHeader()
279 writer.Write("%s %s();\n", prop_type.c_str(), prop_id.c_str()); in GenerateHeader()
281 writer.Write("bool %s(const %s& value);\n", prop_id.c_str(), in GenerateHeader()
286 writer.Write("\n} // namespace %s\n", cpp_namespace.c_str()); in GenerateHeader()
288 return writer.Code(); in GenerateHeader()
293 CodeWriter writer(kIndent); in GenerateSource() local
294 writer.Write("%s", kGeneratedFileFooterComments); in GenerateSource()
295 writer.Write("#include <%s>\n\n", include_name.c_str()); in GenerateSource()
296 writer.Write("%s", kCppSourceIncludes); in GenerateSource()
300 writer.Write("namespace {\n\n"); in GenerateSource()
301 writer.Write("using namespace %s;\n\n", cpp_namespace.c_str()); in GenerateSource()
302 writer.Write("template <typename T> T DoParse(const char* str);\n\n"); in GenerateSource()
313 writer.Write("constexpr const std::pair<const char*, %s> %s_list[] = {\n", in GenerateSource()
315 writer.Indent(); in GenerateSource()
318 writer.Write("{\"%s\", %s::%s},\n", name.c_str(), enum_name.c_str(), in GenerateSource()
321 writer.Dedent(); in GenerateSource()
322 writer.Write("};\n\n"); in GenerateSource()
324 writer.Write("template <>\n"); in GenerateSource()
325 writer.Write("std::optional<%s> DoParse(const char* str) {\n", in GenerateSource()
327 writer.Indent(); in GenerateSource()
328 writer.Write("for (auto [name, val] : %s_list) {\n", prop_id.c_str()); in GenerateSource()
329 writer.Indent(); in GenerateSource()
330 writer.Write("if (strcmp(str, name) == 0) {\n"); in GenerateSource()
331 writer.Indent(); in GenerateSource()
332 writer.Write("return val;\n"); in GenerateSource()
333 writer.Dedent(); in GenerateSource()
334 writer.Write("}\n"); in GenerateSource()
335 writer.Dedent(); in GenerateSource()
336 writer.Write("}\n"); in GenerateSource()
337 writer.Write("return std::nullopt;\n"); in GenerateSource()
338 writer.Dedent(); in GenerateSource()
339 writer.Write("}\n\n"); in GenerateSource()
342 writer.Write("std::string FormatValue(std::optional<%s> value) {\n", in GenerateSource()
344 writer.Indent(); in GenerateSource()
345 writer.Write("if (!value) return \"\";\n"); in GenerateSource()
346 writer.Write("for (auto [name, val] : %s_list) {\n", prop_id.c_str()); in GenerateSource()
347 writer.Indent(); in GenerateSource()
348 writer.Write("if (val == *value) {\n"); in GenerateSource()
349 writer.Indent(); in GenerateSource()
350 writer.Write("return name;\n"); in GenerateSource()
351 writer.Dedent(); in GenerateSource()
352 writer.Write("}\n"); in GenerateSource()
353 writer.Dedent(); in GenerateSource()
354 writer.Write("}\n"); in GenerateSource()
356 writer.Write( in GenerateSource()
361 writer.Write("__builtin_unreachable();\n"); in GenerateSource()
362 writer.Dedent(); in GenerateSource()
363 writer.Write("}\n\n"); in GenerateSource()
366 writer.Write("%s", kCppParsersAndFormatters); in GenerateSource()
367 writer.Write("} // namespace\n\n"); in GenerateSource()
369 writer.Write("namespace %s {\n\n", cpp_namespace.c_str()); in GenerateSource()
372 if (i > 0) writer.Write("\n"); in GenerateSource()
378 writer.Write("%s %s() {\n", prop_type.c_str(), prop_id.c_str()); in GenerateSource()
379 writer.Indent(); in GenerateSource()
380 writer.Write("return GetProp<%s>(\"%s\");\n", prop_type.c_str(), in GenerateSource()
382 writer.Dedent(); in GenerateSource()
383 writer.Write("}\n"); in GenerateSource()
386 writer.Write("\nbool %s(const %s& value) {\n", prop_id.c_str(), in GenerateSource()
388 writer.Indent(); in GenerateSource()
407 writer.Write("return __system_property_set(\"%s\", %s) == 0;\n", in GenerateSource()
409 writer.Dedent(); in GenerateSource()
410 writer.Write("}\n"); in GenerateSource()
414 writer.Write("\n} // namespace %s\n", cpp_namespace.c_str()); in GenerateSource()
416 return writer.Code(); in GenerateSource()