blob: ee9faecab60edf2530fe783ac9eb2db85cbeb2b3 [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
Clark DuValle863c502023-12-13 06:10:41 +000032// The sanitizer is disabled for calls to procs.* since those functions may be
33// dynamically loaded.
34#include "dawn/common/Compiler.h"
35
fujunweia8405742021-12-10 01:35:19 +000036static {{Prefix}}ProcTable procs;
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040037
fujunweia8405742021-12-10 01:35:19 +000038static {{Prefix}}ProcTable nullProcs;
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040039
fujunweia8405742021-12-10 01:35:19 +000040void {{prefix}}ProcSetProcs(const {{Prefix}}ProcTable* procs_) {
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040041 if (procs_) {
42 procs = *procs_;
43 } else {
44 procs = nullProcs;
45 }
46}
47
fujunweia8405742021-12-10 01:35:19 +000048{% for function in by_category["function"] %}
Clark DuValle863c502023-12-13 06:10:41 +000049 DAWN_NO_SANITIZE("cfi-icall")
fujunweia8405742021-12-10 01:35:19 +000050 {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}(
51 {%- for arg in function.arguments -%}
52 {% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
53 {%- endfor -%}
54 ) {
55 {% if function.return_type.name.canonical_case() != "void" %}return {% endif %}
56 procs.{{as_varName(function.name)}}(
57 {%- for arg in function.arguments -%}
58 {% if not loop.first %}, {% endif %}{{as_varName(arg.name)}}
59 {%- endfor -%}
60 );
61 }
62{% endfor %}
Corentin Wallezc57b1802019-10-15 12:08:48 +000063
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040064{% for type in by_category["object"] %}
Corentin Wallezaca8c4a2019-11-22 14:02:52 +000065 {% for method in c_methods(type) %}
Clark DuValle863c502023-12-13 06:10:41 +000066 DAWN_NO_SANITIZE("cfi-icall")
Loko Kungcd162942023-06-01 19:03:05 +000067 {{as_cReturnType(method.return_type)}} {{as_cMethod(type.name, method.name)}}(
Corentin Wallezf07e3bd2017-04-20 14:38:20 -040068 {{-as_cType(type.name)}} {{as_varName(type.name)}}
69 {%- for arg in method.arguments -%}
70 , {{as_annotated_cType(arg)}}
71 {%- endfor -%}
72 ) {
73 {% if method.return_type.name.canonical_case() != "void" %}return {% endif %}
74 procs.{{as_varName(type.name, method.name)}}({{as_varName(type.name)}}
75 {%- for arg in method.arguments -%}
76 , {{as_varName(arg.name)}}
77 {%- endfor -%}
78 );
79 }
80 {% endfor %}
81
82{% endfor %}