Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: headless/lib/browser/type_conversions_h.template

Issue 2219843002: headless: Make API generator more robust against weird enum literals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/browser/client_api_generator_unittest.py ('k') | headless/lib/browser/types_h.template » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/type_conversions_h.template
diff --git a/headless/lib/browser/type_conversions_h.template b/headless/lib/browser/type_conversions_h.template
index 286b0e5ea65eac3374a6e844ed111ff039bf90db..1c918ac9ea3f138223957684314682c830ada722 100644
--- a/headless/lib/browser/type_conversions_h.template
+++ b/headless/lib/browser/type_conversions_h.template
@@ -20,7 +20,7 @@ namespace internal {
template <>
struct FromValue<{{namespace}}::{{type.id}}> {
static {{namespace}}::{{type.id}} Parse(const base::Value& value, ErrorReporter* errors) {
- {% set default = namespace + '::' + type.id + '::' + type.enum[0] | dash_to_camelcase | camelcase_to_hacker_style | upper | mangle_enum %}
+ {% set default = namespace + '::' + type.id + '::' + type.enum[0] | sanitize_literal | dash_to_camelcase | camelcase_to_hacker_style | upper %}
std::string string_value;
if (!value.GetAsString(&string_value)) {
errors->AddError("string enum value expected");
@@ -29,7 +29,7 @@ struct FromValue<{{namespace}}::{{type.id}}> {
}
{% for literal in type.enum %}
if (string_value == "{{literal}}")
- return {{namespace}}::{{type.id}}::{{literal | dash_to_camelcase | camelcase_to_hacker_style | upper | mangle_enum}};
+ return {{namespace}}::{{type.id}}::{{literal | sanitize_literal | dash_to_camelcase | camelcase_to_hacker_style | upper }};
{% endfor %}
errors->AddError("invalid enum value");
return {{default}};
@@ -40,7 +40,7 @@ template <typename T>
std::unique_ptr<base::Value> ToValueImpl(const {{namespace}}::{{type.id}}& value, T*) {
switch (value) {
{% for literal in type.enum %}
- case {{namespace}}::{{type.id}}::{{literal | dash_to_camelcase | camelcase_to_hacker_style | upper | mangle_enum}}:
+ case {{namespace}}::{{type.id}}::{{literal | sanitize_literal | dash_to_camelcase | camelcase_to_hacker_style | upper }}:
return base::WrapUnique(new base::StringValue("{{literal}}"));
{% endfor %}
};
« no previous file with comments | « headless/lib/browser/client_api_generator_unittest.py ('k') | headless/lib/browser/types_h.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698