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

Unified Diff: third_party/inspector_protocol/templates/TypeBuilder_h.template

Issue 2553513002: [inspector] Roll inspector_protocol to c65b17da8a32bc6ab25b4ebbef1008f23c69e7d1. (Closed)
Patch Set: Created 4 years 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 | « third_party/inspector_protocol/templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/inspector_protocol/templates/TypeBuilder_h.template
diff --git a/third_party/inspector_protocol/templates/TypeBuilder_h.template b/third_party/inspector_protocol/templates/TypeBuilder_h.template
index 000b2f5f56435e10ced35154b9b0606030ee316d..81dd7f20e57108c2ed42b7dde1f1153099f519c9 100644
--- a/third_party/inspector_protocol/templates/TypeBuilder_h.template
+++ b/third_party/inspector_protocol/templates/TypeBuilder_h.template
@@ -16,7 +16,7 @@
{% for name in domain.dependencies %}
#include {{format_include(config.protocol.package, name)}}
{% endfor %}
-{% if domain["has_exports"] %}
+{% if protocol.is_exported_domain(domain.domain) %}
#include {{format_include(config.exported.package, domain.domain)}}
{% endif %}
@@ -37,7 +37,7 @@ using {{type.id}} = Object;
{% endif %}
{% elif type.type != "array" %}
// {{type.description}}
-using {{type.id}} = {{resolve_type(type).type}};
+using {{type.id}} = {{protocol.resolve_type(type).type}};
{% endif %}
{% endfor %}
{% for type in domain.types %}
@@ -68,38 +68,40 @@ namespace {{param.name | to_title_case}}Enum {
// ------------- Type and builder declarations.
{% for type in domain.types %}
{% if not (type.type == "object") or not ("properties" in type) %}{% continue %}{% endif %}
- {% set type_def = type_definition(domain.domain + "." + type.id)%}
// {{type.description}}
-class {{config.protocol.export_macro}} {{type.id}} : public Serializable{% if type.exported %}, public API::{{type.id}}{% endif %}{
+class {{config.protocol.export_macro}} {{type.id}} : public Serializable{% if protocol.is_exported(domain.domain, type.id) %}, public API::{{type.id}}{% endif %}{
PROTOCOL_DISALLOW_COPY({{type.id}});
public:
static std::unique_ptr<{{type.id}}> fromValue(protocol::Value* value, ErrorSupport* errors);
~{{type.id}}() override { }
{% for property in type.properties %}
+ {% set property_type = protocol.resolve_type(property) %}
+ {% set property_name = property.name | to_title_case %}
+ {% set property_field = "m_" + property.name %}
{% if "enum" in property %}
- struct {{config.protocol.export_macro}} {{property.name | to_title_case}}Enum {
+ struct {{config.protocol.export_macro}} {{property_name}}Enum {
{% for literal in property.enum %}
static const char* {{literal | dash_to_camelcase}};
{% endfor %}
- }; // {{property.name | to_title_case}}Enum
+ }; // {{property_name}}Enum
{% endif %}
{% if property.optional %}
- bool {{"has" | to_method_case}}{{property.name | to_title_case}}() { return m_{{property.name}}.isJust(); }
- {{resolve_type(property).raw_return_type}} {{"get" | to_method_case}}{{property.name | to_title_case}}({{resolve_type(property).raw_pass_type}} defaultValue) { return m_{{property.name}}.isJust() ? m_{{property.name}}.fromJust() : defaultValue; }
+ bool {{"has" | to_method_case}}{{property_name}}() { return {{property_field}}.isJust(); }
+ {{property_type.raw_return_type}} {{"get" | to_method_case}}{{property_name}}({{property_type.raw_pass_type}} defaultValue) { return {{property_field}}.isJust() ? {{property_field}}.fromJust() : defaultValue; }
{% else %}
- {{resolve_type(property).raw_return_type}} {{"get" | to_method_case}}{{property.name | to_title_case}}() { return {{resolve_type(property).to_raw_type % ("m_" + property.name)}}; }
+ {{property_type.raw_return_type}} {{"get" | to_method_case}}{{property_name}}() { return {{property_type.to_raw_type % property_field}}; }
{% endif %}
- void {{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value) { m_{{property.name}} = {{resolve_type(property).to_rvalue % "value"}}; }
+ void {{"set" | to_method_case}}{{property_name}}({{property_type.pass_type}} value) { {{property_field}} = {{property_type.to_rvalue % "value"}}; }
{% endfor %}
std::unique_ptr<protocol::DictionaryValue> toValue() const;
String serialize() override { return toValue()->serialize(); }
std::unique_ptr<{{type.id}}> clone() const;
- {% if type.exported %}
+ {% if protocol.is_exported(domain.domain, type.id) %}
{{config.exported.string_out}} toJSONString() const override;
{% endif %}
@@ -121,19 +123,21 @@ public:
{% endfor %}0)};
{% for property in type.properties %}
+ {% set property_type = protocol.resolve_type(property) %}
+ {% set property_name = property.name | to_title_case %}
{% if property.optional %}
- {{type.id}}Builder<STATE>& {{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value)
+ {{type.id}}Builder<STATE>& {{"set" | to_method_case}}{{property_name}}({{property_type.pass_type}} value)
{
- m_result->{{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_type(property).to_rvalue % "value"}});
+ m_result->{{"set" | to_method_case}}{{property_name}}({{property_type.to_rvalue % "value"}});
return *this;
}
{% else %}
- {{type.id}}Builder<STATE | {{property.name | to_title_case}}Set>& {{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value)
+ {{type.id}}Builder<STATE | {{property_name}}Set>& {{"set" | to_method_case}}{{property_name}}({{property_type.pass_type}} value)
{
- static_assert(!(STATE & {{property.name | to_title_case}}Set), "property {{property.name}} should not be set yet");
- m_result->{{"set" | to_method_case}}{{property.name | to_title_case}}({{resolve_type(property).to_rvalue % "value"}});
- return castState<{{property.name | to_title_case}}Set>();
+ static_assert(!(STATE & {{property_name}}Set), "property {{property.name}} should not be set yet");
+ m_result->{{"set" | to_method_case}}{{property_name}}({{property_type.to_rvalue % "value"}});
+ return castState<{{property_name}}Set>();
}
{% endif %}
{% endfor %}
@@ -153,7 +157,7 @@ public:
return *reinterpret_cast<{{type.id}}Builder<STATE | STEP>*>(this);
}
- {{type_def.type}} m_result;
+ {{protocol.type_definition(domain.domain + "." + type.id).type}} m_result;
};
static {{type.id}}Builder<0> {{"create" | to_method_case}}()
@@ -165,17 +169,17 @@ private:
{{type.id}}()
{
{% for property in type.properties %}
- {% if not(property.optional) and "default_value" in resolve_type(property) %}
- m_{{property.name}} = {{resolve_type(property).default_value}};
+ {% if not(property.optional) and "default_value" in protocol.resolve_type(property) %}
+ m_{{property.name}} = {{protocol.resolve_type(property).default_value}};
{%endif %}
{% endfor %}
}
{% for property in type.properties %}
{% if property.optional %}
- Maybe<{{resolve_type(property).raw_type}}> m_{{property.name}};
+ Maybe<{{protocol.resolve_type(property).raw_type}}> m_{{property.name}};
{% else %}
- {{resolve_type(property).type}} m_{{property.name}};
+ {{protocol.resolve_type(property).type}} m_{{property.name}};
{% endif %}
{% endfor %}
};
@@ -190,16 +194,16 @@ public:
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
- {% if not generate_command(domain.domain, command.name) %}{% continue %}{% endif %}
- {% if is_async_command(domain.domain, command.name) %}
+ {% if not protocol.generate_command(domain.domain, command.name) %}{% continue %}{% endif %}
+ {% if protocol.is_async_command(domain.domain, command.name) %}
class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callback {
public:
virtual void sendSuccess(
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
- Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}}
+ Maybe<{{protocol.resolve_type(parameter).raw_type}}> {{parameter.name}}
{%- else -%}
- {{resolve_type(parameter).pass_type}} {{parameter.name}}
+ {{protocol.resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}
{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}
@@ -209,7 +213,7 @@ public:
virtual ~{{command.name | to_title_case}}Callback() { }
};
{% endif %}
- {%- if not is_async_command(domain.domain, command.name) %}
+ {%- if not protocol.is_async_command(domain.domain, command.name) %}
virtual DispatchResponse {{command.name | to_method_case}}(
{%- else %}
virtual void {{command.name | to_method_case}}(
@@ -217,28 +221,28 @@ public:
{%- for parameter in command.parameters -%}
{%- if not loop.first -%}, {% endif -%}
{%- if "optional" in parameter -%}
- Maybe<{{resolve_type(parameter).raw_type}}> in_{{parameter.name}}
+ Maybe<{{protocol.resolve_type(parameter).raw_type}}> in_{{parameter.name}}
{%- else -%}
- {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
+ {{protocol.resolve_type(parameter).pass_type}} in_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
- {%- if is_async_command(domain.domain, command.name) -%}
+ {%- if protocol.is_async_command(domain.domain, command.name) -%}
{%- if command.parameters -%}, {% endif -%}
std::unique_ptr<{{command.name | to_title_case}}Callback> callback
{%- else -%}
{%- for parameter in command.returns -%}
{%- if (not loop.first) or command.parameters -%}, {% endif -%}
{%- if "optional" in parameter -%}
- Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
+ Maybe<{{protocol.resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
{%- else -%}
- {{resolve_type(parameter).type}}* out_{{parameter.name}}
+ {{protocol.resolve_type(parameter).type}}* out_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
) = 0;
{% endfor %}
- {% if generate_disable(domain) %}
+ {% if protocol.generate_disable(domain) %}
virtual DispatchResponse {{"disable" | to_method_case}}()
{
return DispatchResponse::OK();
@@ -252,13 +256,13 @@ class {{config.protocol.export_macro}} Frontend {
public:
explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
{% for event in domain.events %}
- {% if not generate_event(domain.domain, event.name) %}{% continue %}{% endif %}
+ {% if not protocol.generate_event(domain.domain, event.name) %}{% continue %}{% endif %}
void {{event.name | to_method_case}}(
{%- for parameter in event.parameters -%}
{%- if "optional" in parameter -%}
- Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} = Maybe<{{resolve_type(parameter).raw_type}}>()
+ Maybe<{{protocol.resolve_type(parameter).raw_type}}> {{parameter.name}} = Maybe<{{protocol.resolve_type(parameter).raw_type}}>()
{%- else -%}
- {{resolve_type(parameter).pass_type}} {{parameter.name}}
+ {{protocol.resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}
);
« no previous file with comments | « third_party/inspector_protocol/templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698