2021-12-14 01:06:15 +00:00
|
|
|
//* This template itself is part of the Dawn source and follows Dawn's license,
|
|
|
|
//* which is Apache 2.0.
|
|
|
|
//*
|
2021-12-16 00:52:26 +00:00
|
|
|
//* The WebGPU native API is a joint project used by Google, Mozilla, and Apple.
|
|
|
|
//* It was agreed to use a BSD 3-Clause license so that it is GPLv2-compatible.
|
2021-12-14 01:06:15 +00:00
|
|
|
//*
|
|
|
|
//* As a result, the template comments using //* at the top of the file are
|
|
|
|
//* removed during generation such that the resulting file starts with the
|
|
|
|
//* BSD 3-Clause comment, which is inside BSD_LICENSE as included below.
|
|
|
|
//*
|
2020-01-15 15:39:12 +00:00
|
|
|
//* Copyright 2020 The Dawn Authors
|
|
|
|
//*
|
|
|
|
//* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
//* you may not use this file except in compliance with the License.
|
|
|
|
//* You may obtain a copy of the License at
|
|
|
|
//*
|
|
|
|
//* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//*
|
|
|
|
//* Unless required by applicable law or agreed to in writing, software
|
|
|
|
//* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//* See the License for the specific language governing permissions and
|
|
|
|
//* limitations under the License.
|
|
|
|
//*
|
|
|
|
//*
|
2021-12-14 01:06:15 +00:00
|
|
|
{% include 'BSD_LICENSE' %}
|
2022-02-09 19:42:51 +00:00
|
|
|
{% if 'dawn' in enabled_tags %}
|
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
|
#error "Do not include this header. Emscripten already provides headers needed for {{metadata.api}}."
|
|
|
|
#endif
|
|
|
|
{% endif %}
|
2021-11-23 08:47:35 +00:00
|
|
|
#ifndef {{metadata.api.upper()}}_H_
|
|
|
|
#define {{metadata.api.upper()}}_H_
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
{% set c_prefix = metadata.c_prefix %}
|
|
|
|
#if defined({{c_prefix}}_SHARED_LIBRARY)
|
2019-10-21 20:04:10 +00:00
|
|
|
# if defined(_WIN32)
|
2021-11-23 08:47:35 +00:00
|
|
|
# if defined({{c_prefix}}_IMPLEMENTATION)
|
|
|
|
# define {{c_prefix}}_EXPORT __declspec(dllexport)
|
2019-10-21 20:04:10 +00:00
|
|
|
# else
|
2021-11-23 08:47:35 +00:00
|
|
|
# define {{c_prefix}}_EXPORT __declspec(dllimport)
|
2019-10-21 20:04:10 +00:00
|
|
|
# endif
|
|
|
|
# else // defined(_WIN32)
|
2021-11-23 08:47:35 +00:00
|
|
|
# if defined({{c_prefix}}_IMPLEMENTATION)
|
|
|
|
# define {{c_prefix}}_EXPORT __attribute__((visibility("default")))
|
2019-10-21 20:04:10 +00:00
|
|
|
# else
|
2021-11-23 08:47:35 +00:00
|
|
|
# define {{c_prefix}}_EXPORT
|
2019-10-21 20:04:10 +00:00
|
|
|
# endif
|
|
|
|
# endif // defined(_WIN32)
|
2021-11-23 08:47:35 +00:00
|
|
|
#else // defined({{c_prefix}}_SHARED_LIBRARY)
|
|
|
|
# define {{c_prefix}}_EXPORT
|
|
|
|
#endif // defined({{c_prefix}}_SHARED_LIBRARY)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-11-25 08:44:01 +00:00
|
|
|
{% for constant in by_category["constant"] %}
|
|
|
|
#define {{c_prefix}}_{{constant.name.SNAKE_CASE()}} {{constant.value}}
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
typedef uint32_t {{c_prefix}}Flags;
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% for type in by_category["enum"] + by_category["bitmask"] %}
|
|
|
|
typedef enum {{as_cType(type.name)}} {
|
|
|
|
{% for value in type.values %}
|
|
|
|
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
|
|
|
|
{% endfor %}
|
|
|
|
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
|
|
|
|
} {{as_cType(type.name)}};
|
|
|
|
{% if type.category == "bitmask" %}
|
2021-11-23 08:47:35 +00:00
|
|
|
typedef {{c_prefix}}Flags {{as_cType(type.name)}}Flags;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2021-09-17 19:44:43 +00:00
|
|
|
{% endfor -%}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
typedef struct {{c_prefix}}ChainedStruct {
|
|
|
|
struct {{c_prefix}}ChainedStruct const * next;
|
|
|
|
{{c_prefix}}SType sType;
|
|
|
|
} {{c_prefix}}ChainedStruct;
|
2020-01-15 09:54:42 +00:00
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
typedef struct {{c_prefix}}ChainedStructOut {
|
|
|
|
struct {{c_prefix}}ChainedStructOut * next;
|
|
|
|
{{c_prefix}}SType sType;
|
|
|
|
} {{c_prefix}}ChainedStructOut;
|
2021-09-17 15:36:00 +00:00
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
{% for type in by_category["structure"] %}
|
|
|
|
typedef struct {{as_cType(type.name)}} {
|
2021-09-17 15:36:00 +00:00
|
|
|
{% set Out = "Out" if type.output else "" %}
|
2021-09-21 17:36:27 +00:00
|
|
|
{% set const = "const " if not type.output else "" %}
|
2019-10-21 20:04:10 +00:00
|
|
|
{% if type.extensible %}
|
2021-11-23 08:47:35 +00:00
|
|
|
{{c_prefix}}ChainedStruct{{Out}} {{const}}* nextInChain;
|
2020-01-15 09:54:42 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if type.chained %}
|
2021-11-23 08:47:35 +00:00
|
|
|
{{c_prefix}}ChainedStruct{{Out}} chain;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endif %}
|
|
|
|
{% for member in type.members %}
|
|
|
|
{{as_annotated_cType(member)}};
|
2022-05-23 15:44:29 +00:00
|
|
|
{%- if member.optional %} // nullable{% endif %}{{""}}
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endfor %}
|
|
|
|
} {{as_cType(type.name)}};
|
|
|
|
|
|
|
|
{% endfor %}
|
2021-02-08 19:48:06 +00:00
|
|
|
{% for typeDef in by_category["typedef"] %}
|
|
|
|
// {{as_cType(typeDef.name)}} is deprecated.
|
|
|
|
// Use {{as_cType(typeDef.type.name)}} instead.
|
|
|
|
typedef {{as_cType(typeDef.type.name)}} {{as_cType(typeDef.name)}};
|
|
|
|
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-12-02 07:41:21 +00:00
|
|
|
{% for type in by_category["function pointer"] %}
|
|
|
|
typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})(
|
2022-03-16 18:35:36 +00:00
|
|
|
{%- if type.arguments == [] -%}
|
|
|
|
void
|
|
|
|
{%- else -%}
|
|
|
|
{%- for arg in type.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- endif -%}
|
2019-11-22 13:18:22 +00:00
|
|
|
);
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
#if !defined({{c_prefix}}_SKIP_PROCS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-12-02 07:41:21 +00:00
|
|
|
{% for function in by_category["function"] %}
|
|
|
|
typedef {{as_cType(function.return_type.name)}} (*{{as_cProc(None, function.name)}})(
|
|
|
|
{%- for arg in function.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
2019-10-21 20:04:10 +00:00
|
|
|
// Procs of {{type.name.CamelCase()}}
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for method in c_methods(type) %}
|
2019-10-21 20:04:10 +00:00
|
|
|
typedef {{as_cType(method.return_type.name)}} (*{{as_cProc(type.name, method.name)}})(
|
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
2022-05-23 15:44:29 +00:00
|
|
|
{%- if arg.optional %} /* nullable */{% endif %}
|
2019-10-21 20:04:10 +00:00
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2021-11-23 08:47:35 +00:00
|
|
|
#endif // !defined({{c_prefix}}_SKIP_PROCS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
#if !defined({{c_prefix}}_SKIP_DECLARATIONS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-12-02 07:41:21 +00:00
|
|
|
{% for function in by_category["function"] %}
|
|
|
|
{{c_prefix}}_EXPORT {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}(
|
|
|
|
{%- for arg in function.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
2019-10-21 20:04:10 +00:00
|
|
|
// Methods of {{type.name.CamelCase()}}
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for method in c_methods(type) %}
|
2021-11-23 08:47:35 +00:00
|
|
|
{{c_prefix}}_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
|
2019-10-21 20:04:10 +00:00
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
2022-05-23 15:44:29 +00:00
|
|
|
{%- if arg.optional %} /* nullable */{% endif %}
|
2019-10-21 20:04:10 +00:00
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2021-11-23 08:47:35 +00:00
|
|
|
#endif // !defined({{c_prefix}}_SKIP_DECLARATIONS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
#endif // {{metadata.api.upper()}}_H_
|