| Index: services/catalog/public/tools/catalog.cc.tmpl
|
| diff --git a/services/catalog/public/tools/catalog.cc.tmpl b/services/catalog/public/tools/catalog.cc.tmpl
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d309ae99979ab8af46420dbc2a767fa52e2b0eb3
|
| --- /dev/null
|
| +++ b/services/catalog/public/tools/catalog.cc.tmpl
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// This is a generated file. Please see the "catalog_cpp_source" template in
|
| +// src/services/catalog/public/tools/catalog.gni for more details.
|
| +
|
| +#include "{{path}}.h"
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| +#include "base/values.h"
|
| +
|
| +namespace {
|
| +
|
| +template <typename T>
|
| +std::unique_ptr<base::Value> GenerateValue(T generator) { return generator(); }
|
| +
|
| +} // namespace
|
| +
|
| +{%- macro generate_value(source) -%}
|
| +{%- if source|is_dict -%}
|
| +GenerateValue([]() {
|
| + auto dict = base::MakeUnique<base::DictionaryValue>();
|
| +{%- for key, value in source.iteritems() %}
|
| + dict->Set("{{key}}", {{generate_value(value)|indent(2)}});
|
| +{%- endfor %}
|
| + return dict;
|
| +})
|
| +{%- elif source|is_list -%}
|
| +GenerateValue([]() {
|
| + auto list = base::MakeUnique<base::ListValue>();
|
| +{%- for value in source %}
|
| + list->Append({{generate_value(value)|indent(2)}});
|
| +{%- endfor %}
|
| + return list;
|
| +})
|
| +{%- elif source|is_number -%}
|
| +base::MakeUnique<base::FundamentalValue>({{source}})
|
| +{%- elif source|is_bool -%}
|
| +base::MakeUnique<base::FundamentalValue>({{source|lower}})
|
| +{%- elif source|is_string or source|is_unicode -%}
|
| +base::MakeUnique<base::StringValue>("{{source|make_ascii}}")
|
| +{%- else %}
|
| +{{raise("Unknown value type: %s" % source, source)}}
|
| +{%- endif %}
|
| +{%- endmacro -%}
|
| +
|
| +{% for namespace in namespaces %}
|
| +namespace {{namespace}} {
|
| +{%- endfor %}
|
| +
|
| +std::unique_ptr<base::Value> {{function_name}}() {
|
| + return {{generate_value(catalog)|indent(2)}};
|
| +}
|
| +
|
| +{%- for namespace in namespaces|reverse %}
|
| +} // namespace {{namespace}}
|
| +{%- endfor %}
|
|
|