Index: tools/json_schema_compiler/templates/ppapi/idl.template |
diff --git a/tools/json_schema_compiler/templates/ppapi/idl.template b/tools/json_schema_compiler/templates/ppapi/idl.template |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9c5b998f97f0b2ee6f30fd9467ebadef28f81b14 |
--- /dev/null |
+++ b/tools/json_schema_compiler/templates/ppapi/idl.template |
@@ -0,0 +1,101 @@ |
+{# Copyright 2013 The Chromium Authors. All rights reserved. |
+Use of this source code is governed by a BSD-style license that can be |
+found in the LICENSE file. -#} |
+ |
+{% extends "base.template" %} |
+ |
+{% macro optional_array_struct(type) %} |
+{%- if type | needs_optional_array %} |
+struct {{ type | ppapi_type(array=True, optional=True) }} { |
+ {{ type | ppapi_type(array=True) }} value; |
+ PP_Bool is_set; |
+}; |
+{% endif -%} |
+{% endmacro %} |
+ |
+{% macro array_struct(type) %} |
+{%- if type | needs_array %} |
+struct {{ type | ppapi_type(array=True) }} { |
+ uint32_t size; |
+ [size_is(size)] {{ type | ppapi_type }}[] elements; |
+}; |
+{% endif -%} |
+{% endmacro %} |
+ |
+{% macro optional_struct(type) %} |
+{%- if type | needs_optional %} |
+struct {{ type | ppapi_type(optional=True) }} { |
+ {{ type | ppapi_type }} value; |
+ PP_Bool is_set; |
+}; |
+{% endif -%} |
+{% endmacro %} |
+ |
+{% block content -%} |
+{# TODO(sammc): Generate version information. -#} |
+label Chrome { |
+ [channel=dev] M33 = 0.1 |
+}; |
+{% for type in enums %} |
+enum {{ type | ppapi_type }} { |
+ {%- for value in type.enum_values %} |
+ {{ value | enum_value(type) }}{% if not loop.last %},{% endif %} |
+ {%- endfor %} |
+}; |
+{{ optional_struct(type) -}} |
+{{ array_struct(type) -}} |
+{{ optional_array_struct(type) -}} |
+{%- endfor %} |
+{%- for type in types %} |
+struct {{ type | ppapi_type }} { |
+ {%- for member in type.properties.itervalues() %} |
+ {{ member | format_param_type }} {{ member.unix_name}}; |
+ {%- endfor %} |
+}; |
+{{ optional_struct(type) -}} |
+{{ array_struct(type) -}} |
+{{ optional_array_struct(type) -}} |
+{% endfor %} |
+{%- for event in events.itervalues() %} |
+typedef void {{ event | ppapi_type }}( |
+ [in] uint32_t listener_id, |
+ [inout] mem_t user_data{% if event.params %},{% endif %} |
+ {%- for param in event.params %} |
+ [in] {{ param | format_param_type }} {{ param.unix_name }} |
+ {%- if not loop.last %},{% endif %} |
+ {%- endfor -%} |
+); |
+{% endfor %} |
+interface PPB_{{ name | classname }} { |
+{% for function in functions.itervalues() %} |
+ {{ function | return_type }} {{ function.name | classname }}( |
+ [in] PP_Instance instance |
+ {%- if function.params or function.callback or function.returns %}, |
+ {%- endif %} |
+ {%- for param in function.params %} |
+ [in] {{ param | format_param_type }} {{ param.unix_name }} |
+ {%- if not loop.last or function.callback or function.returns %}, |
+ {%- endif %} |
+ {%- endfor -%} |
+ {%- if function.returns %} |
+ [out] {{ function.returns | ppapi_type }} result, |
+ {%- endif %} |
+ {%- for param in function.callback.params %} |
+ [out] {{ param | format_param_type }} {{ param.unix_name }}, |
+ {%- endfor %} |
+ {%- if function.callback or function.returns %} |
+ {%- if function | has_array_outs %} |
+ [in] PP_ArrayOutput array_allocator, |
+ {%- endif %} |
+ [in] PP_CompletionCallback callback |
+ {%- endif -%} |
+ ); |
+{% endfor -%} |
+{% for event in events.itervalues() %} |
+ uint32_t Add{{ event.name | classname }}Listener ( |
+ [in] PP_Instance instance, |
+ [in] {{ event | ppapi_type }} callback, |
+ [inout] mem_t user_data); |
+{% endfor %} |
+}; |
+{% endblock %} |