summaryrefslogtreecommitdiff
path: root/chromium/tools/json_schema_compiler/templates/ppapi/idl.template
blob: 9c5b998f97f0b2ee6f30fd9467ebadef28f81b14 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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 %}