Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | //* Copyright 2020 The Dawn & Tint Authors |
Shrek Shao | d7304d1 | 2021-12-14 01:06:15 +0000 | [diff] [blame] | 2 | //* |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | //* Redistribution and use in source and binary forms, with or without |
| 4 | //* modification, are permitted provided that the following conditions are met: |
Shrek Shao | d7304d1 | 2021-12-14 01:06:15 +0000 | [diff] [blame] | 5 | //* |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | //* 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | //* list of conditions and the following disclaimer. |
Shrek Shao | d7304d1 | 2021-12-14 01:06:15 +0000 | [diff] [blame] | 8 | //* |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | //* 2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | //* this list of conditions and the following disclaimer in the documentation |
| 11 | //* and/or other materials provided with the distribution. |
Corentin Wallez | 1bf3167 | 2020-01-15 15:39:12 +0000 | [diff] [blame] | 12 | //* |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 13 | //* 3. Neither the name of the copyright holder nor the names of its |
| 14 | //* contributors may be used to endorse or promote products derived from |
| 15 | //* this software without specific prior written permission. |
Corentin Wallez | 1bf3167 | 2020-01-15 15:39:12 +0000 | [diff] [blame] | 16 | //* |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 17 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | //* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | //* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 21 | //* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | //* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 | //* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 24 | //* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | //* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Corentin Wallez | 1bf3167 | 2020-01-15 15:39:12 +0000 | [diff] [blame] | 27 | //* |
| 28 | //* |
Shrek Shao | d7304d1 | 2021-12-14 01:06:15 +0000 | [diff] [blame] | 29 | {% include 'BSD_LICENSE' %} |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 30 | |
Shrek Shao | 71a363b | 2022-02-09 19:42:51 +0000 | [diff] [blame] | 31 | {% if 'dawn' in enabled_tags %} |
| 32 | #ifdef __EMSCRIPTEN__ |
Loko Kung | c2aeab7 | 2024-07-25 20:08:34 +0000 | [diff] [blame] | 33 | #error "Do not include this header. Emscripten already provides headers needed for {{metadata.api}}." |
| 34 | #endif |
Shrek Shao | 71a363b | 2022-02-09 19:42:51 +0000 | [diff] [blame] | 35 | {% endif %} |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 36 | |
fujunwei | 76bda37 | 2021-11-23 08:47:35 +0000 | [diff] [blame] | 37 | #ifndef {{metadata.api.upper()}}_H_ |
| 38 | #define {{metadata.api.upper()}}_H_ |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 39 | |
Corentin Wallez | efcc72e | 2024-09-26 11:51:53 +0000 | [diff] [blame] | 40 | #define WGPU_BREAKING_CHANGE_STRING_VIEW_LABELS |
Corentin Wallez | 03d6e0e | 2024-10-11 12:53:30 +0000 | [diff] [blame] | 41 | #define WGPU_BREAKING_CHANGE_STRING_VIEW_OUTPUT_STRUCTS |
Corentin Wallez | e4ce129 | 2024-10-14 15:58:25 +0000 | [diff] [blame] | 42 | #define WGPU_BREAKING_CHANGE_STRING_VIEW_CALLBACKS |
Corentin Wallez | efcc72e | 2024-09-26 11:51:53 +0000 | [diff] [blame] | 43 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 44 | {% set API = metadata.c_prefix %} |
| 45 | #if defined({{API}}_SHARED_LIBRARY) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 46 | # if defined(_WIN32) |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 47 | # if defined({{API}}_IMPLEMENTATION) |
| 48 | # define {{API}}_EXPORT __declspec(dllexport) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 49 | # else |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 50 | # define {{API}}_EXPORT __declspec(dllimport) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 51 | # endif |
| 52 | # else // defined(_WIN32) |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 53 | # if defined({{API}}_IMPLEMENTATION) |
| 54 | # define {{API}}_EXPORT __attribute__((visibility("default"))) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 55 | # else |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 56 | # define {{API}}_EXPORT |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 57 | # endif |
| 58 | # endif // defined(_WIN32) |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 59 | #else // defined({{API}}_SHARED_LIBRARY) |
| 60 | # define {{API}}_EXPORT |
| 61 | #endif // defined({{API}}_SHARED_LIBRARY) |
| 62 | |
| 63 | #if !defined({{API}}_OBJECT_ATTRIBUTE) |
| 64 | #define {{API}}_OBJECT_ATTRIBUTE |
| 65 | #endif |
| 66 | #if !defined({{API}}_ENUM_ATTRIBUTE) |
| 67 | #define {{API}}_ENUM_ATTRIBUTE |
| 68 | #endif |
| 69 | #if !defined({{API}}_STRUCTURE_ATTRIBUTE) |
| 70 | #define {{API}}_STRUCTURE_ATTRIBUTE |
| 71 | #endif |
| 72 | #if !defined({{API}}_FUNCTION_ATTRIBUTE) |
| 73 | #define {{API}}_FUNCTION_ATTRIBUTE |
| 74 | #endif |
| 75 | #if !defined({{API}}_NULLABLE) |
| 76 | #define {{API}}_NULLABLE |
| 77 | #endif |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 78 | |
François Beaufort | 37e6b5c | 2024-09-05 20:01:49 +0000 | [diff] [blame] | 79 | #define WGPU_BREAKING_CHANGE_DROP_DESCRIPTOR |
| 80 | |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 81 | #include <stdint.h> |
| 82 | #include <stddef.h> |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 83 | |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 84 | #if defined(__cplusplus) |
| 85 | # if __cplusplus >= 201103L |
| 86 | # define {{API}}_MAKE_INIT_STRUCT(type, value) (type value) |
| 87 | # else |
| 88 | # define {{API}}_MAKE_INIT_STRUCT(type, value) value |
| 89 | # endif |
| 90 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| 91 | # define {{API}}_MAKE_INIT_STRUCT(type, value) ((type) value) |
| 92 | #else |
| 93 | # define {{API}}_MAKE_INIT_STRUCT(type, value) value |
| 94 | #endif |
| 95 | |
fujunwei | 4e87690 | 2021-11-25 08:44:01 +0000 | [diff] [blame] | 96 | {% for constant in by_category["constant"] %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 97 | #define {{API}}_{{constant.name.SNAKE_CASE()}} {{constant.value}} |
fujunwei | 4e87690 | 2021-11-25 08:44:01 +0000 | [diff] [blame] | 98 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 99 | |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 100 | typedef uint64_t {{API}}Flags; |
Loko Kung | 440a30c | 2023-08-04 23:41:21 +0000 | [diff] [blame] | 101 | typedef uint32_t {{API}}Bool; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 102 | |
| 103 | {% for type in by_category["object"] %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 104 | typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}} {{API}}_OBJECT_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 105 | {% endfor %} |
| 106 | |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 107 | // Structure forward declarations |
Corentin Wallez | a1e1e57 | 2024-09-26 09:33:21 +0000 | [diff] [blame] | 108 | {% for type in by_category["structure"] %} |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 109 | struct {{as_cType(type.name)}}; |
| 110 | {% endfor %} |
| 111 | |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 112 | {% for type in by_category["enum"] %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 113 | typedef enum {{as_cType(type.name)}} { |
| 114 | {% for value in type.values %} |
| 115 | {{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}}, |
| 116 | {% endfor %} |
| 117 | {{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 118 | } {{as_cType(type.name)}} {{API}}_ENUM_ATTRIBUTE; |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 119 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 120 | |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 121 | {% for type in by_category["bitmask"] %} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 122 | typedef {{API}}Flags {{as_cType(type.name)}}; |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 123 | {% for value in type.values %} |
| 124 | static const {{as_cType(type.name)}} {{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "016X")}}; |
| 125 | {% endfor %} |
Kai Ninomiya | 930e918 | 2021-09-17 19:44:43 +0000 | [diff] [blame] | 126 | {% endfor -%} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 127 | |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 128 | {% for type in by_category["function pointer"] %} |
| 129 | typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})( |
| 130 | {%- if type.arguments == [] -%} |
| 131 | void |
| 132 | {%- else -%} |
| 133 | {%- for arg in type.arguments -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 134 | {% if not loop.first %}, {% endif %} |
| 135 | {% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}} |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 136 | {%- endfor -%} |
| 137 | {%- endif -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 138 | ) {{API}}_FUNCTION_ATTRIBUTE; |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 139 | {% endfor %} |
| 140 | |
Loko Kung | 4e63525 | 2024-05-08 04:33:44 +0000 | [diff] [blame] | 141 | // Callback function pointers |
| 142 | {% for type in by_category["callback function"] %} |
| 143 | typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})( |
| 144 | {%- for arg in type.arguments -%} |
Jaswant Panchumarti | 6f535820 | 2024-06-11 21:45:14 +0000 | [diff] [blame] | 145 | {% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}}{{", "}} |
Loko Kung | 4e63525 | 2024-05-08 04:33:44 +0000 | [diff] [blame] | 146 | {%- endfor -%} |
| 147 | void* userdata1, void* userdata2) {{API}}_FUNCTION_ATTRIBUTE; |
| 148 | {% endfor %} |
| 149 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 150 | typedef struct {{API}}ChainedStruct { |
| 151 | struct {{API}}ChainedStruct const * next; |
| 152 | {{API}}SType sType; |
| 153 | } {{API}}ChainedStruct {{API}}_STRUCTURE_ATTRIBUTE; |
Corentin Wallez | 2b24c3d | 2020-01-15 09:54:42 +0000 | [diff] [blame] | 154 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 155 | typedef struct {{API}}ChainedStructOut { |
| 156 | struct {{API}}ChainedStructOut * next; |
| 157 | {{API}}SType sType; |
| 158 | } {{API}}ChainedStructOut {{API}}_STRUCTURE_ATTRIBUTE; |
Austin Eng | bffc966 | 2021-09-17 15:36:00 +0000 | [diff] [blame] | 159 | |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 160 | {% macro render_c_default_value(member) -%} |
| 161 | {%- if member.annotation in ["*", "const*"] and member.optional or member.default_value == "nullptr" -%} |
| 162 | nullptr |
| 163 | {%- elif member.type.category == "object" and member.optional -%} |
| 164 | nullptr |
Loko Kung | 4e63525 | 2024-05-08 04:33:44 +0000 | [diff] [blame] | 165 | {%- elif member.type.category == "callback function" -%} |
| 166 | nullptr |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 167 | {%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%} |
| 168 | {{as_cEnum(member.type.name, Name(member.default_value))}} |
| 169 | {%- elif member.default_value != None -%} |
| 170 | {{member.default_value}} |
| 171 | {%- elif member.type.category == "structure" and member.annotation == "value" -%} |
| 172 | {{API}}_{{member.type.name.SNAKE_CASE()}}_INIT |
| 173 | {%- else -%} |
| 174 | {{- assert(member.json_data.get("no_default", false) == false) -}} |
| 175 | {{- assert(member.default_value == None) -}} |
| 176 | {} |
| 177 | {%- endif -%} |
| 178 | {% endmacro %} |
Corentin Wallez | d5c7130 | 2024-09-26 09:44:03 +0000 | [diff] [blame] | 179 | {% macro nullable_annotation(record) -%} |
| 180 | {% if record.optional and (record.type.category == "object" or record.annotation != "value") -%} |
| 181 | {{API}}_NULLABLE{{" "}} |
| 182 | {%- endif %} |
| 183 | {%- endmacro %} |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 184 | |
| 185 | #define {{API}}_COMMA , |
| 186 | |
Loko Kung | f2a5e57 | 2024-06-20 21:56:42 +0000 | [diff] [blame] | 187 | {% for type in by_category["callback info"] %} |
| 188 | typedef struct {{as_cType(type.name)}} { |
| 189 | {{API}}ChainedStruct const* nextInChain; |
| 190 | {% for member in type.members %} |
| 191 | {{as_annotated_cType(member)}}; |
| 192 | {% endfor %} |
| 193 | void* userdata1; |
| 194 | void* userdata2; |
| 195 | } {{as_cType(type.name)}} {{API}}_STRUCTURE_ATTRIBUTE; |
| 196 | |
| 197 | #define {{API}}_{{type.name.SNAKE_CASE()}}_INIT {{API}}_MAKE_INIT_STRUCT({{as_cType(type.name)}}, { \ |
| 198 | /*.nextInChain=*/nullptr {{API}}_COMMA \ |
| 199 | {% for member in type.members %} |
| 200 | /*.{{as_varName(member.name)}}=*/{{render_c_default_value(member)}} {{API}}_COMMA \ |
| 201 | {% endfor %} |
| 202 | /*.userdata1=*/nullptr {{API}}_COMMA \ |
| 203 | /*.userdata2=*/nullptr {{API}}_COMMA \ |
| 204 | }) |
| 205 | |
| 206 | {% endfor %} |
Austin Eng | 622dbaf | 2024-07-23 00:09:52 +0000 | [diff] [blame] | 207 | |
Corentin Wallez | a1e1e57 | 2024-09-26 09:33:21 +0000 | [diff] [blame] | 208 | {% for type in by_category["structure"] %} |
Corentin Wallez | a45561b | 2022-07-14 12:58:25 +0000 | [diff] [blame] | 209 | {% for root in type.chain_roots %} |
| 210 | // Can be chained in {{as_cType(root.name)}} |
| 211 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 212 | typedef struct {{as_cType(type.name)}} { |
Austin Eng | bffc966 | 2021-09-17 15:36:00 +0000 | [diff] [blame] | 213 | {% set Out = "Out" if type.output else "" %} |
Kai Ninomiya | 7d174a1 | 2021-09-21 17:36:27 +0000 | [diff] [blame] | 214 | {% set const = "const " if not type.output else "" %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 215 | {% if type.extensible %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 216 | {{API}}ChainedStruct{{Out}} {{const}}* nextInChain; |
Corentin Wallez | 2b24c3d | 2020-01-15 09:54:42 +0000 | [diff] [blame] | 217 | {% endif %} |
| 218 | {% if type.chained %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 219 | {{API}}ChainedStruct{{Out}} chain; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 220 | {% endif %} |
| 221 | {% for member in type.members %} |
Corentin Wallez | d5c7130 | 2024-09-26 09:44:03 +0000 | [diff] [blame] | 222 | {{nullable_annotation(member)}}{{as_annotated_cType(member)}}; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 223 | {% endfor %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 224 | } {{as_cType(type.name)}} {{API}}_STRUCTURE_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 225 | |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 226 | #define {{API}}_{{type.name.SNAKE_CASE()}}_INIT {{API}}_MAKE_INIT_STRUCT({{as_cType(type.name)}}, { \ |
| 227 | {% if type.extensible %} |
| 228 | /*.nextInChain=*/nullptr {{API}}_COMMA \ |
| 229 | {% endif %} |
| 230 | {% if type.chained %} |
Corentin Wallez | 075e51a | 2024-09-20 08:06:07 +0000 | [diff] [blame] | 231 | /*.chain=*/{/*.nextInChain*/nullptr {{API}}_COMMA /*.sType*/{{API}}SType_{{type.name.CamelCase()}}} {{API}}_COMMA \ |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 232 | {% endif %} |
| 233 | {% for member in type.members %} |
| 234 | /*.{{as_varName(member.name)}}=*/{{render_c_default_value(member)}} {{API}}_COMMA \ |
| 235 | {% endfor %} |
| 236 | }) |
| 237 | |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 238 | {% endfor %} |
Brandon Jones | 58a471a | 2021-02-08 19:48:06 +0000 | [diff] [blame] | 239 | {% for typeDef in by_category["typedef"] %} |
| 240 | // {{as_cType(typeDef.name)}} is deprecated. |
| 241 | // Use {{as_cType(typeDef.type.name)}} instead. |
| 242 | typedef {{as_cType(typeDef.type.name)}} {{as_cType(typeDef.name)}}; |
| 243 | |
| 244 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 245 | #ifdef __cplusplus |
| 246 | extern "C" { |
| 247 | #endif |
| 248 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 249 | #if !defined({{API}}_SKIP_PROCS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 250 | |
Lokbondo Kung | f258823 | 2024-10-22 21:06:21 +0000 | [diff] [blame] | 251 | // TODO(374150686): Remove these Emscripten specific declarations from the |
| 252 | // header once they are fully deprecated. |
| 253 | #ifdef __EMSCRIPTEN__ |
| 254 | {{API}}_EXPORT WGPUDevice emscripten_webgpu_get_device(void); |
| 255 | #endif |
| 256 | |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 257 | {% for function in by_category["function"] %} |
| 258 | typedef {{as_cType(function.return_type.name)}} (*{{as_cProc(None, function.name)}})( |
| 259 | {%- for arg in function.arguments -%} |
Corentin Wallez | d5c7130 | 2024-09-26 09:44:03 +0000 | [diff] [blame] | 260 | {% if not loop.first %}, {% endif %} |
| 261 | {{nullable_annotation(arg)}}{{as_annotated_cType(arg)}} |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 262 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 263 | ) {{API}}_FUNCTION_ATTRIBUTE; |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 264 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 265 | |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 266 | {% for type in by_category["object"] if len(c_methods(type)) > 0 %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 267 | // Procs of {{type.name.CamelCase()}} |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 268 | {% for method in c_methods(type) %} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 269 | typedef {{as_cType(method.return_type.name)}} (*{{as_cProc(type.name, method.name)}})( |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 270 | {{-as_cType(type.name)}} {{as_varName(type.name)}} |
| 271 | {%- for arg in method.arguments -%} |
Corentin Wallez | d5c7130 | 2024-09-26 09:44:03 +0000 | [diff] [blame] | 272 | , {{nullable_annotation(arg)}}{{as_annotated_cType(arg)}} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 273 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 274 | ) {{API}}_FUNCTION_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 275 | {% endfor %} |
| 276 | |
| 277 | {% endfor %} |
Austin Eng | 643625a | 2023-08-09 00:59:33 +0000 | [diff] [blame] | 278 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 279 | #endif // !defined({{API}}_SKIP_PROCS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 280 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 281 | #if !defined({{API}}_SKIP_DECLARATIONS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 282 | |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 283 | {% for function in by_category["function"] %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 284 | {{API}}_EXPORT {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}( |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 285 | {%- for arg in function.arguments -%} |
Kai Ninomiya | be98f27 | 2023-09-11 20:47:26 +0000 | [diff] [blame] | 286 | {% if not loop.first %}, {% endif -%} |
Corentin Wallez | d5c7130 | 2024-09-26 09:44:03 +0000 | [diff] [blame] | 287 | {{nullable_annotation(arg)}}{{as_annotated_cType(arg)}} |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 288 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 289 | ) {{API}}_FUNCTION_ATTRIBUTE; |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 290 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 291 | |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 292 | {% for type in by_category["object"] if len(c_methods(type)) > 0 %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 293 | // Methods of {{type.name.CamelCase()}} |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 294 | {% for method in c_methods(type) %} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 295 | {{API}}_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}( |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 296 | {{-as_cType(type.name)}} {{as_varName(type.name)}} |
| 297 | {%- for arg in method.arguments -%} |
Corentin Wallez | d5c7130 | 2024-09-26 09:44:03 +0000 | [diff] [blame] | 298 | , {{nullable_annotation(arg)}}{{as_annotated_cType(arg)}} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 299 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 300 | ) {{API}}_FUNCTION_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 301 | {% endfor %} |
| 302 | |
| 303 | {% endfor %} |
Austin Eng | 643625a | 2023-08-09 00:59:33 +0000 | [diff] [blame] | 304 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 305 | #endif // !defined({{API}}_SKIP_DECLARATIONS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 306 | |
| 307 | #ifdef __cplusplus |
| 308 | } // extern "C" |
| 309 | #endif |
| 310 | |
fujunwei | 76bda37 | 2021-11-23 08:47:35 +0000 | [diff] [blame] | 311 | #endif // {{metadata.api.upper()}}_H_ |