blob: 2f0c60e97af4f7afdcb1f02266e2665382e27d79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
{%- import "interface_macros.tmpl" as interface_macros %}
class {{interface.name}}Proxy;
class {{interface.name}}Stub;
class {{interface.name}}RequestValidator;
{%- if interface|has_callbacks %}
class {{interface.name}}ResponseValidator;
{%- endif %}
class {{interface.name}} {
public:
static const char Name_[];
static const uint32_t Version_ = {{interface.version}};
static const bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
static const bool HasSyncMethods_ = {% if interface|has_sync_methods %}true{% else %}false{% endif %};
using GenericInterface = {{interface|get_qualified_name_for_kind}};
using Proxy_ = {{interface.name}}Proxy;
using Stub_ = {{interface.name}}Stub;
using RequestValidator_ = {{interface.name}}RequestValidator;
{%- if interface|has_callbacks %}
using ResponseValidator_ = {{interface.name}}ResponseValidator;
{%- else %}
using ResponseValidator_ = mojo::PassThroughFilter;
{%- endif %}
{#--- Enums #}
{% from "enum_macros.tmpl" import enum_decl -%}
{%- for enum in interface.enums %}
{{enum_decl(enum)|indent(2)}}
{%- endfor %}
{#--- Constants #}
{%- for constant in interface.constants %}
{%- if constant.kind|is_integral_kind %}
static const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}};
{%- else %}
static const {{constant.kind|cpp_pod_type}} {{constant.name}};
{%- endif %}
{%- endfor %}
{#--- Methods #}
virtual ~{{interface.name}}() {}
{%- for method in interface.methods %}
{% if method.response_parameters != None %}
{%- if method.sync %}
virtual bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}}) {
// Sync method. This signature is used by the client side; the service side
// should implement the signature with callback below.
NOTREACHED();
return false;
}
{%- endif %}
using {{method.name}}Callback = {{interface_macros.declare_callback(method)}};
{%- endif %}
virtual void {{method.name}}({{interface_macros.declare_request_params("", method)}}) = 0;
{%- endfor %}
};
|