OLD | NEW |
1 // This file is generated | 1 // This file is generated |
2 | 2 |
3 // Copyright 2016 The Chromium Authors. All rights reserved. | 3 // Copyright 2016 The Chromium Authors. All rights reserved. |
4 // Use of this source code is governed by a BSD-style license that can be | 4 // Use of this source code is governed by a BSD-style license that can be |
5 // found in the LICENSE file. | 5 // found in the LICENSE file. |
6 | 6 |
7 #ifndef HEADLESS_PUBLIC_DEVTOOLS_INTERNAL_TYPE_CONVERSIONS_{{domain.domain | cam
elcase_to_hacker_style | upper}}_H_ | 7 #ifndef HEADLESS_PUBLIC_DEVTOOLS_INTERNAL_TYPE_CONVERSIONS_{{domain.domain | cam
elcase_to_hacker_style | upper}}_H_ |
8 #define HEADLESS_PUBLIC_DEVTOOLS_INTERNAL_TYPE_CONVERSIONS_{{domain.domain | cam
elcase_to_hacker_style | upper}}_H_ | 8 #define HEADLESS_PUBLIC_DEVTOOLS_INTERNAL_TYPE_CONVERSIONS_{{domain.domain | cam
elcase_to_hacker_style | upper}}_H_ |
9 | 9 |
10 #include "headless/public/devtools/domains/types_{{domain.domain | camelcase_to_
hacker_style}}.h" | 10 #include "headless/public/devtools/domains/types_{{domain.domain | camelcase_to_
hacker_style}}.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 errors->AddError("invalid enum value"); | 33 errors->AddError("invalid enum value"); |
34 return {{default}}; | 34 return {{default}}; |
35 } | 35 } |
36 }; | 36 }; |
37 | 37 |
38 template <typename T> | 38 template <typename T> |
39 std::unique_ptr<base::Value> ToValueImpl(const {{namespace}}::{{type.id}}& value
, T*) { | 39 std::unique_ptr<base::Value> ToValueImpl(const {{namespace}}::{{type.id}}& value
, T*) { |
40 switch (value) { | 40 switch (value) { |
41 {% for literal in type.enum %} | 41 {% for literal in type.enum %} |
42 case {{namespace}}::{{type.id}}::{{literal | sanitize_literal | dash_to_came
lcase | camelcase_to_hacker_style | upper }}: | 42 case {{namespace}}::{{type.id}}::{{literal | sanitize_literal | dash_to_came
lcase | camelcase_to_hacker_style | upper }}: |
43 return base::WrapUnique(new base::StringValue("{{literal}}")); | 43 return base::WrapUnique(new base::Value("{{literal}}")); |
44 {% endfor %} | 44 {% endfor %} |
45 }; | 45 }; |
46 NOTREACHED(); | 46 NOTREACHED(); |
47 return nullptr; | 47 return nullptr; |
48 } | 48 } |
49 {% continue %} | 49 {% continue %} |
50 {% endif %} | 50 {% endif %} |
51 | 51 |
52 {% if not (type.type == "object") or not ("properties" in type) %}{% continue
%}{% endif %} | 52 {% if not (type.type == "object") or not ("properties" in type) %}{% continue
%}{% endif %} |
53 template <> | 53 template <> |
54 struct FromValue<{{namespace}}::{{type.id}}> { | 54 struct FromValue<{{namespace}}::{{type.id}}> { |
55 static std::unique_ptr<{{namespace}}::{{type.id}}> Parse(const base::Value& va
lue, ErrorReporter* errors) { | 55 static std::unique_ptr<{{namespace}}::{{type.id}}> Parse(const base::Value& va
lue, ErrorReporter* errors) { |
56 return {{namespace}}::{{type.id}}::Parse(value, errors); | 56 return {{namespace}}::{{type.id}}::Parse(value, errors); |
57 } | 57 } |
58 }; | 58 }; |
59 | 59 |
60 template <typename T> | 60 template <typename T> |
61 std::unique_ptr<base::Value> ToValueImpl(const {{namespace}}::{{type.id}}& value
, T*) { | 61 std::unique_ptr<base::Value> ToValueImpl(const {{namespace}}::{{type.id}}& value
, T*) { |
62 return value.Serialize(); | 62 return value.Serialize(); |
63 } | 63 } |
64 | 64 |
65 {% endfor %} | 65 {% endfor %} |
66 | 66 |
67 } // namespace internal | 67 } // namespace internal |
68 } // namespace headless | 68 } // namespace headless |
69 | 69 |
70 #endif // HEADLESS_PUBLIC_DEVTOOLS_INTERNAL_TYPE_CONVERSIONS_{{domain.domain |
camelcase_to_hacker_style | upper}}_H_ | 70 #endif // HEADLESS_PUBLIC_DEVTOOLS_INTERNAL_TYPE_CONVERSIONS_{{domain.domain |
camelcase_to_hacker_style | upper}}_H_ |
OLD | NEW |