blob: 342f184f2e7e8e2d3b93034d76140beffd72804b [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001//* Copyright 2017 The Dawn & Tint Authors
Corentin Wallezf07e3bd2017-04-20 14:38:20 -04002//*
Austin Engcc2516a2023-10-17 20:57:54 +00003//* Redistribution and use in source and binary forms, with or without
4//* modification, are permitted provided that the following conditions are met:
Corentin Wallezf07e3bd2017-04-20 14:38:20 -04005//*
Austin Engcc2516a2023-10-17 20:57:54 +00006//* 1. Redistributions of source code must retain the above copyright notice, this
7//* list of conditions and the following disclaimer.
Corentin Wallezf07e3bd2017-04-20 14:38:20 -04008//*
Austin Engcc2516a2023-10-17 20:57:54 +00009//* 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 Wallezf07e3bd2017-04-20 14:38:20 -040027
fujunweia8405742021-12-10 01:35:19 +000028{% set Prefix = metadata.proc_table_prefix %}
29{% set prefix = Prefix.lower() %}
30#include "dawn/{{prefix}}_proc.h"
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040031
fujunweia8405742021-12-10 01:35:19 +000032static {{Prefix}}ProcTable procs;
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040033
fujunweia8405742021-12-10 01:35:19 +000034static {{Prefix}}ProcTable nullProcs;
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040035
fujunweia8405742021-12-10 01:35:19 +000036void {{prefix}}ProcSetProcs(const {{Prefix}}ProcTable* procs_) {
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040037 if (procs_) {
38 procs = *procs_;
39 } else {
40 procs = nullProcs;
41 }
42}
43
fujunweia8405742021-12-10 01:35:19 +000044{% 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 Wallezc57b1802019-10-15 12:08:48 +000058
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040059{% for type in by_category["object"] %}
Corentin Wallezaca8c4a2019-11-22 14:02:52 +000060 {% for method in c_methods(type) %}
Loko Kungcd162942023-06-01 19:03:05 +000061 {{as_cReturnType(method.return_type)}} {{as_cMethod(type.name, method.name)}}(
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040062 {{-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 %}