Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | //* Copyright 2017 The Dawn & Tint Authors |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [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: |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [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. |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [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. |
| 12 | //* |
| 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. |
| 16 | //* |
| 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 | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 27 | |
fujunwei | a840574 | 2021-12-10 01:35:19 +0000 | [diff] [blame] | 28 | {% set Prefix = metadata.proc_table_prefix %} |
| 29 | {% set prefix = Prefix.lower() %} |
| 30 | #include "dawn/{{prefix}}_proc.h" |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 31 | |
fujunwei | a840574 | 2021-12-10 01:35:19 +0000 | [diff] [blame] | 32 | static {{Prefix}}ProcTable procs; |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 33 | |
fujunwei | a840574 | 2021-12-10 01:35:19 +0000 | [diff] [blame] | 34 | static {{Prefix}}ProcTable nullProcs; |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 35 | |
fujunwei | a840574 | 2021-12-10 01:35:19 +0000 | [diff] [blame] | 36 | void {{prefix}}ProcSetProcs(const {{Prefix}}ProcTable* procs_) { |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 37 | if (procs_) { |
| 38 | procs = *procs_; |
| 39 | } else { |
| 40 | procs = nullProcs; |
| 41 | } |
| 42 | } |
| 43 | |
fujunwei | a840574 | 2021-12-10 01:35:19 +0000 | [diff] [blame] | 44 | {% for function in by_category["function"] %} |
| 45 | {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}( |
| 46 | {%- for arg in function.arguments -%} |
| 47 | {% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}} |
| 48 | {%- endfor -%} |
| 49 | ) { |
| 50 | {% if function.return_type.name.canonical_case() != "void" %}return {% endif %} |
| 51 | procs.{{as_varName(function.name)}}( |
| 52 | {%- for arg in function.arguments -%} |
| 53 | {% if not loop.first %}, {% endif %}{{as_varName(arg.name)}} |
| 54 | {%- endfor -%} |
| 55 | ); |
| 56 | } |
| 57 | {% endfor %} |
Corentin Wallez | c57b180 | 2019-10-15 12:08:48 +0000 | [diff] [blame] | 58 | |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 59 | {% for type in by_category["object"] %} |
Corentin Wallez | aca8c4a | 2019-11-22 14:02:52 +0000 | [diff] [blame] | 60 | {% for method in c_methods(type) %} |
Loko Kung | cd16294 | 2023-06-01 19:03:05 +0000 | [diff] [blame] | 61 | {{as_cReturnType(method.return_type)}} {{as_cMethod(type.name, method.name)}}( |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 62 | {{-as_cType(type.name)}} {{as_varName(type.name)}} |
| 63 | {%- for arg in method.arguments -%} |
| 64 | , {{as_annotated_cType(arg)}} |
| 65 | {%- endfor -%} |
| 66 | ) { |
| 67 | {% if method.return_type.name.canonical_case() != "void" %}return {% endif %} |
| 68 | procs.{{as_varName(type.name, method.name)}}({{as_varName(type.name)}} |
| 69 | {%- for arg in method.arguments -%} |
| 70 | , {{as_varName(arg.name)}} |
| 71 | {%- endfor -%} |
| 72 | ); |
| 73 | } |
| 74 | {% endfor %} |
| 75 | |
| 76 | {% endfor %} |