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 | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 40 | {% set API = metadata.c_prefix %} |
| 41 | #if defined({{API}}_SHARED_LIBRARY) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 42 | # if defined(_WIN32) |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 43 | # if defined({{API}}_IMPLEMENTATION) |
| 44 | # define {{API}}_EXPORT __declspec(dllexport) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 45 | # else |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 46 | # define {{API}}_EXPORT __declspec(dllimport) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 47 | # endif |
| 48 | # else // defined(_WIN32) |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 49 | # if defined({{API}}_IMPLEMENTATION) |
| 50 | # define {{API}}_EXPORT __attribute__((visibility("default"))) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 51 | # else |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 52 | # define {{API}}_EXPORT |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 53 | # endif |
| 54 | # endif // defined(_WIN32) |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 55 | #else // defined({{API}}_SHARED_LIBRARY) |
| 56 | # define {{API}}_EXPORT |
| 57 | #endif // defined({{API}}_SHARED_LIBRARY) |
| 58 | |
| 59 | #if !defined({{API}}_OBJECT_ATTRIBUTE) |
| 60 | #define {{API}}_OBJECT_ATTRIBUTE |
| 61 | #endif |
| 62 | #if !defined({{API}}_ENUM_ATTRIBUTE) |
| 63 | #define {{API}}_ENUM_ATTRIBUTE |
| 64 | #endif |
| 65 | #if !defined({{API}}_STRUCTURE_ATTRIBUTE) |
| 66 | #define {{API}}_STRUCTURE_ATTRIBUTE |
| 67 | #endif |
| 68 | #if !defined({{API}}_FUNCTION_ATTRIBUTE) |
| 69 | #define {{API}}_FUNCTION_ATTRIBUTE |
| 70 | #endif |
| 71 | #if !defined({{API}}_NULLABLE) |
| 72 | #define {{API}}_NULLABLE |
| 73 | #endif |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 74 | |
François Beaufort | 37e6b5c | 2024-09-05 20:01:49 +0000 | [diff] [blame] | 75 | #define WGPU_BREAKING_CHANGE_DROP_DESCRIPTOR |
| 76 | |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 77 | #include <stdint.h> |
| 78 | #include <stddef.h> |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 79 | |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 80 | #if defined(__cplusplus) |
| 81 | # if __cplusplus >= 201103L |
| 82 | # define {{API}}_MAKE_INIT_STRUCT(type, value) (type value) |
| 83 | # else |
| 84 | # define {{API}}_MAKE_INIT_STRUCT(type, value) value |
| 85 | # endif |
| 86 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| 87 | # define {{API}}_MAKE_INIT_STRUCT(type, value) ((type) value) |
| 88 | #else |
| 89 | # define {{API}}_MAKE_INIT_STRUCT(type, value) value |
| 90 | #endif |
| 91 | |
fujunwei | 4e87690 | 2021-11-25 08:44:01 +0000 | [diff] [blame] | 92 | {% for constant in by_category["constant"] %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 93 | #define {{API}}_{{constant.name.SNAKE_CASE()}} {{constant.value}} |
fujunwei | 4e87690 | 2021-11-25 08:44:01 +0000 | [diff] [blame] | 94 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 95 | |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 96 | typedef uint64_t {{API}}Flags; |
Loko Kung | 440a30c | 2023-08-04 23:41:21 +0000 | [diff] [blame] | 97 | typedef uint32_t {{API}}Bool; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 98 | |
| 99 | {% for type in by_category["object"] %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 100 | 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] | 101 | {% endfor %} |
| 102 | |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 103 | // Structure forward declarations |
Austin Eng | 622dbaf | 2024-07-23 00:09:52 +0000 | [diff] [blame] | 104 | {% for type in by_category["structure"] if type.name.get() != "nullable string view" %} |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 105 | struct {{as_cType(type.name)}}; |
| 106 | {% endfor %} |
| 107 | |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 108 | {% for type in by_category["enum"] %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 109 | typedef enum {{as_cType(type.name)}} { |
| 110 | {% for value in type.values %} |
| 111 | {{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}}, |
| 112 | {% endfor %} |
| 113 | {{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 114 | } {{as_cType(type.name)}} {{API}}_ENUM_ATTRIBUTE; |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 115 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 116 | |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 117 | {% for type in by_category["bitmask"] %} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 118 | typedef {{API}}Flags {{as_cType(type.name)}}; |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 119 | {% for value in type.values %} |
| 120 | static const {{as_cType(type.name)}} {{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "016X")}}; |
| 121 | {% endfor %} |
Kai Ninomiya | 930e918 | 2021-09-17 19:44:43 +0000 | [diff] [blame] | 122 | {% endfor -%} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 123 | |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 124 | {% for type in by_category["function pointer"] %} |
| 125 | typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})( |
| 126 | {%- if type.arguments == [] -%} |
| 127 | void |
| 128 | {%- else -%} |
| 129 | {%- for arg in type.arguments -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 130 | {% if not loop.first %}, {% endif %} |
| 131 | {% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}} |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 132 | {%- endfor -%} |
| 133 | {%- endif -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 134 | ) {{API}}_FUNCTION_ATTRIBUTE; |
Brandon Jones | 112b7fd | 2023-05-17 01:52:30 +0000 | [diff] [blame] | 135 | {% endfor %} |
| 136 | |
Loko Kung | 4e63525 | 2024-05-08 04:33:44 +0000 | [diff] [blame] | 137 | // Callback function pointers |
| 138 | {% for type in by_category["callback function"] %} |
| 139 | typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})( |
| 140 | {%- for arg in type.arguments -%} |
Jaswant Panchumarti | 6f535820 | 2024-06-11 21:45:14 +0000 | [diff] [blame] | 141 | {% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}}{{", "}} |
Loko Kung | 4e63525 | 2024-05-08 04:33:44 +0000 | [diff] [blame] | 142 | {%- endfor -%} |
| 143 | void* userdata1, void* userdata2) {{API}}_FUNCTION_ATTRIBUTE; |
| 144 | {% endfor %} |
| 145 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 146 | typedef struct {{API}}ChainedStruct { |
| 147 | struct {{API}}ChainedStruct const * next; |
| 148 | {{API}}SType sType; |
| 149 | } {{API}}ChainedStruct {{API}}_STRUCTURE_ATTRIBUTE; |
Corentin Wallez | 2b24c3d | 2020-01-15 09:54:42 +0000 | [diff] [blame] | 150 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 151 | typedef struct {{API}}ChainedStructOut { |
| 152 | struct {{API}}ChainedStructOut * next; |
| 153 | {{API}}SType sType; |
| 154 | } {{API}}ChainedStructOut {{API}}_STRUCTURE_ATTRIBUTE; |
Austin Eng | bffc966 | 2021-09-17 15:36:00 +0000 | [diff] [blame] | 155 | |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 156 | {% macro render_c_default_value(member) -%} |
| 157 | {%- if member.annotation in ["*", "const*"] and member.optional or member.default_value == "nullptr" -%} |
| 158 | nullptr |
| 159 | {%- elif member.type.category == "object" and member.optional -%} |
| 160 | nullptr |
Loko Kung | 4e63525 | 2024-05-08 04:33:44 +0000 | [diff] [blame] | 161 | {%- elif member.type.category == "callback function" -%} |
| 162 | nullptr |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 163 | {%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%} |
| 164 | {{as_cEnum(member.type.name, Name(member.default_value))}} |
| 165 | {%- elif member.default_value != None -%} |
| 166 | {{member.default_value}} |
| 167 | {%- elif member.type.category == "structure" and member.annotation == "value" -%} |
| 168 | {{API}}_{{member.type.name.SNAKE_CASE()}}_INIT |
| 169 | {%- else -%} |
| 170 | {{- assert(member.json_data.get("no_default", false) == false) -}} |
| 171 | {{- assert(member.default_value == None) -}} |
| 172 | {} |
| 173 | {%- endif -%} |
| 174 | {% endmacro %} |
| 175 | |
| 176 | #define {{API}}_COMMA , |
| 177 | |
Loko Kung | f2a5e57 | 2024-06-20 21:56:42 +0000 | [diff] [blame] | 178 | {% for type in by_category["callback info"] %} |
| 179 | typedef struct {{as_cType(type.name)}} { |
| 180 | {{API}}ChainedStruct const* nextInChain; |
| 181 | {% for member in type.members %} |
| 182 | {{as_annotated_cType(member)}}; |
| 183 | {% endfor %} |
| 184 | void* userdata1; |
| 185 | void* userdata2; |
| 186 | } {{as_cType(type.name)}} {{API}}_STRUCTURE_ATTRIBUTE; |
| 187 | |
| 188 | #define {{API}}_{{type.name.SNAKE_CASE()}}_INIT {{API}}_MAKE_INIT_STRUCT({{as_cType(type.name)}}, { \ |
| 189 | /*.nextInChain=*/nullptr {{API}}_COMMA \ |
| 190 | {% for member in type.members %} |
| 191 | /*.{{as_varName(member.name)}}=*/{{render_c_default_value(member)}} {{API}}_COMMA \ |
| 192 | {% endfor %} |
| 193 | /*.userdata1=*/nullptr {{API}}_COMMA \ |
| 194 | /*.userdata2=*/nullptr {{API}}_COMMA \ |
| 195 | }) |
| 196 | |
| 197 | {% endfor %} |
Austin Eng | 622dbaf | 2024-07-23 00:09:52 +0000 | [diff] [blame] | 198 | |
| 199 | {% for type in by_category["structure"] if type.name.get() != "nullable string view" %} |
Corentin Wallez | a45561b | 2022-07-14 12:58:25 +0000 | [diff] [blame] | 200 | {% for root in type.chain_roots %} |
| 201 | // Can be chained in {{as_cType(root.name)}} |
| 202 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 203 | typedef struct {{as_cType(type.name)}} { |
Austin Eng | bffc966 | 2021-09-17 15:36:00 +0000 | [diff] [blame] | 204 | {% set Out = "Out" if type.output else "" %} |
Kai Ninomiya | 7d174a1 | 2021-09-21 17:36:27 +0000 | [diff] [blame] | 205 | {% set const = "const " if not type.output else "" %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 206 | {% if type.extensible %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 207 | {{API}}ChainedStruct{{Out}} {{const}}* nextInChain; |
Corentin Wallez | 2b24c3d | 2020-01-15 09:54:42 +0000 | [diff] [blame] | 208 | {% endif %} |
| 209 | {% if type.chained %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 210 | {{API}}ChainedStruct{{Out}} chain; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 211 | {% endif %} |
| 212 | {% for member in type.members %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 213 | {% if member.optional %} |
| 214 | {{API}}_NULLABLE {{as_annotated_cType(member)}}; |
| 215 | {% else %} |
| 216 | {{as_annotated_cType(member)}}; |
| 217 | {% endif-%} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 218 | {% endfor %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 219 | } {{as_cType(type.name)}} {{API}}_STRUCTURE_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 220 | |
Austin Eng | 58213ae | 2024-04-30 06:15:26 +0000 | [diff] [blame] | 221 | #define {{API}}_{{type.name.SNAKE_CASE()}}_INIT {{API}}_MAKE_INIT_STRUCT({{as_cType(type.name)}}, { \ |
| 222 | {% if type.extensible %} |
| 223 | /*.nextInChain=*/nullptr {{API}}_COMMA \ |
| 224 | {% endif %} |
| 225 | {% if type.chained %} |
Corentin Wallez | 075e51a | 2024-09-20 08:06:07 +0000 | [diff] [blame^] | 226 | /*.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] | 227 | {% endif %} |
| 228 | {% for member in type.members %} |
| 229 | /*.{{as_varName(member.name)}}=*/{{render_c_default_value(member)}} {{API}}_COMMA \ |
| 230 | {% endfor %} |
| 231 | }) |
| 232 | |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 233 | {% endfor %} |
Brandon Jones | 58a471a | 2021-02-08 19:48:06 +0000 | [diff] [blame] | 234 | {% for typeDef in by_category["typedef"] %} |
| 235 | // {{as_cType(typeDef.name)}} is deprecated. |
| 236 | // Use {{as_cType(typeDef.type.name)}} instead. |
| 237 | typedef {{as_cType(typeDef.type.name)}} {{as_cType(typeDef.name)}}; |
| 238 | |
| 239 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 240 | #ifdef __cplusplus |
| 241 | extern "C" { |
| 242 | #endif |
| 243 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 244 | #if !defined({{API}}_SKIP_PROCS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 245 | |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 246 | {% for function in by_category["function"] %} |
| 247 | typedef {{as_cType(function.return_type.name)}} (*{{as_cProc(None, function.name)}})( |
| 248 | {%- for arg in function.arguments -%} |
| 249 | {% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}} |
| 250 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 251 | ) {{API}}_FUNCTION_ATTRIBUTE; |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 252 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 253 | |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 254 | {% for type in by_category["object"] if len(c_methods(type)) > 0 %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 255 | // Procs of {{type.name.CamelCase()}} |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 256 | {% for method in c_methods(type) %} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 257 | 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] | 258 | {{-as_cType(type.name)}} {{as_varName(type.name)}} |
| 259 | {%- for arg in method.arguments -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 260 | ,{{" "}} |
| 261 | {%- if arg.optional %}{{API}}_NULLABLE {% endif -%} |
| 262 | {{as_annotated_cType(arg)}} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 263 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 264 | ) {{API}}_FUNCTION_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 265 | {% endfor %} |
| 266 | |
| 267 | {% endfor %} |
Austin Eng | 643625a | 2023-08-09 00:59:33 +0000 | [diff] [blame] | 268 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 269 | #endif // !defined({{API}}_SKIP_PROCS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 270 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 271 | #if !defined({{API}}_SKIP_DECLARATIONS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 272 | |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 273 | {% for function in by_category["function"] %} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 274 | {{API}}_EXPORT {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}( |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 275 | {%- for arg in function.arguments -%} |
Kai Ninomiya | be98f27 | 2023-09-11 20:47:26 +0000 | [diff] [blame] | 276 | {% if not loop.first %}, {% endif -%} |
| 277 | {%- if arg.optional %}{{API}}_NULLABLE {% endif -%} |
| 278 | {{as_annotated_cType(arg)}} |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 279 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 280 | ) {{API}}_FUNCTION_ATTRIBUTE; |
fujunwei | 23f7162 | 2021-12-02 07:41:21 +0000 | [diff] [blame] | 281 | {% endfor %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 282 | |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 283 | {% for type in by_category["object"] if len(c_methods(type)) > 0 %} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 284 | // Methods of {{type.name.CamelCase()}} |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 285 | {% for method in c_methods(type) %} |
Austin Eng | 83d3e7f | 2024-06-28 19:48:10 +0000 | [diff] [blame] | 286 | {{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] | 287 | {{-as_cType(type.name)}} {{as_varName(type.name)}} |
| 288 | {%- for arg in method.arguments -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 289 | ,{{" "}} |
| 290 | {%- if arg.optional %}{{API}}_NULLABLE {% endif -%} |
| 291 | {{as_annotated_cType(arg)}} |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 292 | {%- endfor -%} |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 293 | ) {{API}}_FUNCTION_ATTRIBUTE; |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 294 | {% endfor %} |
| 295 | |
| 296 | {% endfor %} |
Austin Eng | 643625a | 2023-08-09 00:59:33 +0000 | [diff] [blame] | 297 | |
Corentin Wallez | 8d45d44 | 2023-05-23 08:16:55 +0000 | [diff] [blame] | 298 | #endif // !defined({{API}}_SKIP_DECLARATIONS) |
Corentin Wallez | 2c8b5c6 | 2019-10-21 20:04:10 +0000 | [diff] [blame] | 299 | |
| 300 | #ifdef __cplusplus |
| 301 | } // extern "C" |
| 302 | #endif |
| 303 | |
fujunwei | 76bda37 | 2021-11-23 08:47:35 +0000 | [diff] [blame] | 304 | #endif // {{metadata.api.upper()}}_H_ |