summaryrefslogtreecommitdiff
path: root/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl')
-rw-r--r--mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl65
1 files changed, 65 insertions, 0 deletions
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
new file mode 100644
index 0000000000..7f6497475a
--- /dev/null
+++ b/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
@@ -0,0 +1,65 @@
+{%- import "interface_macros.tmpl" as interface_macros %}
+class {{interface.name}}Proxy;
+
+template <typename ImplRefTraits>
+class {{interface.name}}Stub;
+
+class {{interface.name}}RequestValidator;
+{%- if interface|has_callbacks %}
+class {{interface.name}}ResponseValidator;
+{%- endif %}
+
+class {{export_attribute}} {{interface.name}}
+ : public {{interface.name}}InterfaceBase {
+ public:
+ static const char Name_[];
+ static constexpr uint32_t Version_ = {{interface.version}};
+ static constexpr bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
+ static constexpr bool HasSyncMethods_ = {% if interface|has_sync_methods %}true{% else %}false{% endif %};
+
+ using Proxy_ = {{interface.name}}Proxy;
+
+ template <typename ImplRefTraits>
+ using Stub_ = {{interface.name}}Stub<ImplRefTraits>;
+
+ using RequestValidator_ = {{interface.name}}RequestValidator;
+{%- if interface|has_callbacks %}
+ using ResponseValidator_ = {{interface.name}}ResponseValidator;
+{%- else %}
+ using ResponseValidator_ = mojo::PassThroughFilter;
+{%- endif %}
+
+{#--- Metadata #}
+ enum MethodMinVersions : uint32_t {
+{%- for method in interface.methods %}
+ k{{method.name}}MinVersion = {{method.min_version|default(0, true)}},
+{%- endfor %}
+ };
+
+{#--- Enums #}
+{%- for enum in interface.enums %}
+ using {{enum.name}} = {{enum|get_name_for_kind(flatten_nested_kind=True)}};
+{%- endfor %}
+
+{#--- Constants #}
+{%- for constant in interface.constants %}
+ static {{constant|format_constant_declaration(nested=True)}};
+{%- endfor %}
+
+{#--- Methods #}
+ virtual ~{{interface.name}}() {}
+
+{%- for method in interface.methods %}
+{% if method.response_parameters != None %}
+{%- if method.sync %}
+ // Sync method. This signature is used by the client side; the service side
+ // should implement the signature with callback below.
+ virtual bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}});
+{%- endif %}
+
+ using {{method.name}}Callback = {{interface_macros.declare_callback(method,
+ for_blink, use_once_callback)}};
+{%- endif %}
+ virtual void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) = 0;
+{%- endfor %}
+};