OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview Generated DevTools bindings for the {{domain.domain}} Domain. | |
Sami
2017/05/24 09:16:21
How do we handle experimental things currently? Ma
alex clarke (OOO till 29th)
2017/05/24 11:38:15
I guess we should just drop them and you have to u
Sami
2017/05/25 17:53:35
Right, let's not generate anything for them now an
alex clarke (OOO till 29th)
2017/05/26 11:37:02
Done.
| |
7 */ | |
8 'use strict'; | |
9 | |
10 goog.require('goog.DevTools.Connection'); | |
11 {% for domain_name in domain.js_dependencies %} | |
12 goog.require('goog.DevTools.{{domain_name}}') | |
13 {% endfor %} | |
14 goog.provide('goog.DevTools.{{domain.domain}}'); | |
15 | |
16 /** | |
17 * @class Bindings for the {{domain.domain}} DevTools Domain. | |
18 * @param {!goog.DevTools.Connection} connection The DevTools connection. | |
19 * @constructor | |
20 */ | |
21 goog.DevTools.{{domain.domain}} = function(connection) { | |
22 /** | |
23 * The DevTools connection. | |
24 * | |
25 * @private {!goog.DevTools.Connection} | |
26 */ | |
27 this.connection_ = connection; | |
28 }; | |
29 | |
30 goog.scope(function () { | |
31 | |
32 var {{domain.domain}} = goog.DevTools.{{domain.domain}}; | |
33 | |
34 {% for type in domain.types %} | |
35 {% if not "enum" in type %}{% continue %}{% endif %} | |
36 /** | |
37 {% if type.description %} | |
38 * {{type.description}} | |
39 * | |
40 {% endif %} | |
41 * @enum {string} | |
42 */ | |
43 {{domain.domain}}.{{type.id}} = { | |
44 {% for literal in type.enum %} | |
45 {{ literal | sanitize_literal | dash_to_camelcase | camelcase_to_hacker_style | upper }}: "{{ literal }}"{{',' if not loop.last}} | |
46 {% endfor %} | |
47 }; | |
48 | |
49 {% endfor %} | |
50 | |
51 {% for type in domain.types %} | |
52 {% if not (type.type == "object") or not ("properties" in type) %}{% continue %} {% endif %} | |
53 /** | |
54 {% if type.description %} | |
55 * {{type.description}} | |
56 * | |
57 {% endif %} | |
58 {% for property in type.properties %} | |
59 {% if property.description %} | |
60 * {{property.name}}: {{property.description}} | |
61 {% endif %} | |
62 {% endfor %} | |
63 * | |
64 {% if type.properties %} | |
65 * @typedef {{ '{{' }} | |
66 {% for property in type.properties %} | |
67 {% if property.optional %} | |
68 * {{property.name}}: ({{ resolve_type(property).js_type }}|undefined){% if no t loop.last %},{% endif %} | |
69 | |
70 {% else %} | |
71 * {{property.name}}: {{ resolve_type(property).js_type }}{% if not loop.last %}, {% endif %} | |
72 | |
73 {% endif %} | |
74 {% endfor %} | |
75 * {{ '}}' }} | |
76 {% else %} | |
77 * @typedef {undefined} | |
78 {% endif %} | |
79 */ | |
80 {{domain.domain}}.{{type.id}}; | |
81 | |
82 | |
83 {% endfor %} | |
84 | |
85 {% for command in domain.commands %} | |
86 {% set method_name = command.name | sanitize_literal | to_title_case %} | |
87 {% if command.parameters|length > 0 %} | |
88 {% set param_name = 'params' %} | |
89 {% set param_type = '{' + domain.domain + '.' + method_name + 'Params}' %} | |
90 {% else %} | |
91 {% set param_name = 'opt_params' %} | |
92 {% set param_type = '{' + domain.domain + '.' + method_name + 'Params=}' %} | |
93 {% endif %} | |
94 {% set result_type = '{Promise<' + domain.domain + '.' + method_name + 'Result>} ' %} | |
95 | |
96 /** | |
97 {% if command.description %} | |
98 * {{ command.description }} | |
99 {% endif %} | |
100 * @param {{param_type}} {{param_name}} | |
101 * @return {{result_type}} | |
102 */ | |
103 {{domain.domain}}.prototype.{{method_name}} = function({{param_name}}) { | |
104 return /** @type {{result_type}} **/( | |
105 this.connection_.SendDevToolsMessage('{{domain.domain}}.{{command.name}}', | |
106 {{param_name}})); | |
107 }; | |
108 | |
109 {% endfor %} | |
110 | |
111 | |
112 {% for event in domain.events %} | |
113 {% set param_type = '{!function(!' + domain.domain + '.' + event.name | to_title _case + 'Params)}' %} | |
114 | |
115 /** | |
116 {% if event.description %} | |
117 * {{ event.description }} | |
118 {% endif %} | |
119 * @param {{param_type}} listener | |
120 */ | |
121 {{domain.domain}}.prototype.On{{event.name | to_title_case}} = function(listener ) { | |
122 this.connection_.AddEventListener('{{domain.domain}}.{{event.name}}', | |
123 /** @type {!function(!Object)} */ (listener )); | |
124 }; | |
125 {% endfor %} | |
126 | |
127 }); // goog.scope | |
OLD | NEW |