| OLD | NEW |
| 1 // This file is generated | 1 // This file is generated |
| 2 | 2 |
| 3 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 3 // Copyright (c) 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 #include "platform/inspector_protocol/{{class_name}}.h" | 7 #include "platform/inspector_protocol/{{class_name}}.h" |
| 8 | 8 |
| 9 #include "wtf/text/CString.h" | 9 #include "wtf/text/CString.h" |
| 10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 namespace protocol { | 13 namespace protocol { |
| 14 | 14 |
| 15 Frontend::Frontend(FrontendChannel* frontendChannel) | 15 Frontend::Frontend(FrontendChannel* frontendChannel) |
| 16 : m_frontendChannel(frontendChannel) | 16 : m_frontendChannel(frontendChannel) |
| 17 {% for domain in api.domains %} | 17 {% for domain in api.domains %} |
| 18 , m_{{domain.domain | lower}}(frontendChannel) | 18 , m_{{domain.domain | lower}}(frontendChannel) |
| 19 {% endfor %} | 19 {% endfor %} |
| 20 { | 20 { |
| 21 } | 21 } |
| 22 | 22 |
| 23 {% for domain in api.domains %} | 23 {% for domain in api.domains %} |
| 24 {% for event in domain.events %} | 24 {% for event in domain.events %} |
| 25 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con
tinue %}{% endif %} | 25 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con
tinue %}{% endif %} |
| 26 void Frontend::{{domain.domain}}::{{event.name}}( | 26 void Frontend::{{domain.domain}}::{{event.name}}( |
| 27 {%- for parameter in event.parameters %} | 27 {%- for parameter in event.parameters %} |
| 28 {% if "optional" in parameter -%} | 28 {% if "optional" in parameter -%} |
| 29 {{resolve_type(parameter).optional_pass_type}} | 29 const Maybe<{{resolve_type(parameter).raw_type}}>& |
| 30 {%- else -%} | 30 {%- else -%} |
| 31 {{resolve_type(parameter).pass_type}} | 31 {{resolve_type(parameter).pass_type}} |
| 32 {%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%} | 32 {%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%} |
| 33 {% endfor -%}) | 33 {% endfor -%}) |
| 34 { | 34 { |
| 35 RefPtr<JSONObject> jsonMessage = JSONObject::create(); | 35 RefPtr<JSONObject> jsonMessage = JSONObject::create(); |
| 36 jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}"); | 36 jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}"); |
| 37 RefPtr<JSONObject> paramsObject = JSONObject::create(); | 37 RefPtr<JSONObject> paramsObject = JSONObject::create(); |
| 38 {% for parameter in event.parameters %} | 38 {% for parameter in event.parameters %} |
| 39 {% if "optional" in parameter %} | 39 {% if "optional" in parameter %} |
| 40 {{resolve_type(parameter).optional_type}} opt_{{parameter.name}} = {{paramet
er.name}}; | 40 if ({{parameter.name}}.isJust()) |
| 41 if (hasValue(opt_{{parameter.name}})) | 41 paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}})
); |
| 42 paramsObject->setValue("{{parameter.name}}", toValue({{resolve_type(para
meter).from_optional_out % ("opt_" + parameter.name)}})); | |
| 43 {% else %} | 42 {% else %} |
| 44 paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}})); | 43 paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}})); |
| 45 {% endif %} | 44 {% endif %} |
| 46 {% endfor %} | 45 {% endfor %} |
| 47 jsonMessage->setObject("params", paramsObject); | 46 jsonMessage->setObject("params", paramsObject); |
| 48 if (m_frontendChannel) | 47 if (m_frontendChannel) |
| 49 m_frontendChannel->sendProtocolNotification(jsonMessage.release()); | 48 m_frontendChannel->sendProtocolNotification(jsonMessage.release()); |
| 50 } | 49 } |
| 51 {% endfor %} | 50 {% endfor %} |
| 52 {% endfor %} | 51 {% endfor %} |
| 53 | 52 |
| 54 } // namespace protocol | 53 } // namespace protocol |
| 55 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |