mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-06 21:25:58 +00:00
webgpu.h: Add overridable (default empty) attributes to all types
See https://github.com/webgpu-native/webgpu-headers/issues/179 Also changes WGPU_NULLABLE instead of /* nullable */ and make a couple formatting fixes. Bug: None Change-Id: Ieb4315cddd3c806144892221fba11888171f072f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133102 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
47245bc33f
commit
8d45d44905
@ -32,37 +32,53 @@
|
|||||||
#ifndef {{metadata.api.upper()}}_H_
|
#ifndef {{metadata.api.upper()}}_H_
|
||||||
#define {{metadata.api.upper()}}_H_
|
#define {{metadata.api.upper()}}_H_
|
||||||
|
|
||||||
{% set c_prefix = metadata.c_prefix %}
|
{% set API = metadata.c_prefix %}
|
||||||
#if defined({{c_prefix}}_SHARED_LIBRARY)
|
#if defined({{API}}_SHARED_LIBRARY)
|
||||||
# if defined(_WIN32)
|
# if defined(_WIN32)
|
||||||
# if defined({{c_prefix}}_IMPLEMENTATION)
|
# if defined({{API}}_IMPLEMENTATION)
|
||||||
# define {{c_prefix}}_EXPORT __declspec(dllexport)
|
# define {{API}}_EXPORT __declspec(dllexport)
|
||||||
# else
|
# else
|
||||||
# define {{c_prefix}}_EXPORT __declspec(dllimport)
|
# define {{API}}_EXPORT __declspec(dllimport)
|
||||||
# endif
|
# endif
|
||||||
# else // defined(_WIN32)
|
# else // defined(_WIN32)
|
||||||
# if defined({{c_prefix}}_IMPLEMENTATION)
|
# if defined({{API}}_IMPLEMENTATION)
|
||||||
# define {{c_prefix}}_EXPORT __attribute__((visibility("default")))
|
# define {{API}}_EXPORT __attribute__((visibility("default")))
|
||||||
# else
|
# else
|
||||||
# define {{c_prefix}}_EXPORT
|
# define {{API}}_EXPORT
|
||||||
# endif
|
# endif
|
||||||
# endif // defined(_WIN32)
|
# endif // defined(_WIN32)
|
||||||
#else // defined({{c_prefix}}_SHARED_LIBRARY)
|
#else // defined({{API}}_SHARED_LIBRARY)
|
||||||
# define {{c_prefix}}_EXPORT
|
# define {{API}}_EXPORT
|
||||||
#endif // defined({{c_prefix}}_SHARED_LIBRARY)
|
#endif // defined({{API}}_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
#if !defined({{API}}_OBJECT_ATTRIBUTE)
|
||||||
|
#define {{API}}_OBJECT_ATTRIBUTE
|
||||||
|
#endif
|
||||||
|
#if !defined({{API}}_ENUM_ATTRIBUTE)
|
||||||
|
#define {{API}}_ENUM_ATTRIBUTE
|
||||||
|
#endif
|
||||||
|
#if !defined({{API}}_STRUCTURE_ATTRIBUTE)
|
||||||
|
#define {{API}}_STRUCTURE_ATTRIBUTE
|
||||||
|
#endif
|
||||||
|
#if !defined({{API}}_FUNCTION_ATTRIBUTE)
|
||||||
|
#define {{API}}_FUNCTION_ATTRIBUTE
|
||||||
|
#endif
|
||||||
|
#if !defined({{API}}_NULLABLE)
|
||||||
|
#define {{API}}_NULLABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
{% for constant in by_category["constant"] %}
|
{% for constant in by_category["constant"] %}
|
||||||
#define {{c_prefix}}_{{constant.name.SNAKE_CASE()}} {{constant.value}}
|
#define {{API}}_{{constant.name.SNAKE_CASE()}} {{constant.value}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
typedef uint32_t {{c_prefix}}Flags;
|
typedef uint32_t {{API}}Flags;
|
||||||
|
|
||||||
{% for type in by_category["object"] %}
|
{% for type in by_category["object"] %}
|
||||||
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
|
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}} {{API}}_OBJECT_ATTRIBUTE;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
// Structure forward declarations
|
// Structure forward declarations
|
||||||
@ -76,34 +92,34 @@ typedef uint32_t {{c_prefix}}Flags;
|
|||||||
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
|
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
|
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
|
||||||
} {{as_cType(type.name)}};
|
} {{as_cType(type.name)}} {{API}}_ENUM_ATTRIBUTE;
|
||||||
{% if type.category == "bitmask" %}
|
{% if type.category == "bitmask" %}
|
||||||
typedef {{c_prefix}}Flags {{as_cType(type.name)}}Flags;
|
typedef {{API}}Flags {{as_cType(type.name)}}Flags {{API}}_ENUM_ATTRIBUTE;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
|
||||||
{% for type in by_category["function pointer"] %}
|
{% for type in by_category["function pointer"] %}
|
||||||
typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})(
|
typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})(
|
||||||
{%- if type.arguments == [] -%}
|
{%- if type.arguments == [] -%}
|
||||||
void
|
void
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- for arg in type.arguments -%}
|
{%- for arg in type.arguments -%}
|
||||||
{% if not loop.first %}, {% endif %}{% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}}
|
{% if not loop.first %}, {% endif %}
|
||||||
|
{% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
);
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
typedef struct {{c_prefix}}ChainedStruct {
|
typedef struct {{API}}ChainedStruct {
|
||||||
struct {{c_prefix}}ChainedStruct const * next;
|
struct {{API}}ChainedStruct const * next;
|
||||||
{{c_prefix}}SType sType;
|
{{API}}SType sType;
|
||||||
} {{c_prefix}}ChainedStruct;
|
} {{API}}ChainedStruct {{API}}_STRUCTURE_ATTRIBUTE;
|
||||||
|
|
||||||
typedef struct {{c_prefix}}ChainedStructOut {
|
typedef struct {{API}}ChainedStructOut {
|
||||||
struct {{c_prefix}}ChainedStructOut * next;
|
struct {{API}}ChainedStructOut * next;
|
||||||
{{c_prefix}}SType sType;
|
{{API}}SType sType;
|
||||||
} {{c_prefix}}ChainedStructOut;
|
} {{API}}ChainedStructOut {{API}}_STRUCTURE_ATTRIBUTE;
|
||||||
|
|
||||||
{% for type in by_category["structure"] %}
|
{% for type in by_category["structure"] %}
|
||||||
{% for root in type.chain_roots %}
|
{% for root in type.chain_roots %}
|
||||||
@ -113,16 +129,19 @@ typedef struct {{c_prefix}}ChainedStructOut {
|
|||||||
{% set Out = "Out" if type.output else "" %}
|
{% set Out = "Out" if type.output else "" %}
|
||||||
{% set const = "const " if not type.output else "" %}
|
{% set const = "const " if not type.output else "" %}
|
||||||
{% if type.extensible %}
|
{% if type.extensible %}
|
||||||
{{c_prefix}}ChainedStruct{{Out}} {{const}}* nextInChain;
|
{{API}}ChainedStruct{{Out}} {{const}}* nextInChain;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if type.chained %}
|
{% if type.chained %}
|
||||||
{{c_prefix}}ChainedStruct{{Out}} chain;
|
{{API}}ChainedStruct{{Out}} chain;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for member in type.members %}
|
{% for member in type.members %}
|
||||||
|
{% if member.optional %}
|
||||||
|
{{API}}_NULLABLE {{as_annotated_cType(member)}};
|
||||||
|
{% else %}
|
||||||
{{as_annotated_cType(member)}};
|
{{as_annotated_cType(member)}};
|
||||||
{%- if member.optional %} // nullable{% endif %}{{""}}
|
{% endif-%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
} {{as_cType(type.name)}};
|
} {{as_cType(type.name)}} {{API}}_STRUCTURE_ATTRIBUTE;
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for typeDef in by_category["typedef"] %}
|
{% for typeDef in by_category["typedef"] %}
|
||||||
@ -135,26 +154,14 @@ typedef struct {{c_prefix}}ChainedStructOut {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{% for type in by_category["function pointer"] %}
|
#if !defined({{API}}_SKIP_PROCS)
|
||||||
typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})(
|
|
||||||
{%- if type.arguments == [] -%}
|
|
||||||
void
|
|
||||||
{%- else -%}
|
|
||||||
{%- for arg in type.arguments -%}
|
|
||||||
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
||||||
{%- endfor -%}
|
|
||||||
{%- endif -%}
|
|
||||||
);
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
#if !defined({{c_prefix}}_SKIP_PROCS)
|
|
||||||
|
|
||||||
{% for function in by_category["function"] %}
|
{% for function in by_category["function"] %}
|
||||||
typedef {{as_cType(function.return_type.name)}} (*{{as_cProc(None, function.name)}})(
|
typedef {{as_cType(function.return_type.name)}} (*{{as_cProc(None, function.name)}})(
|
||||||
{%- for arg in function.arguments -%}
|
{%- for arg in function.arguments -%}
|
||||||
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
);
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
||||||
@ -163,39 +170,41 @@ extern "C" {
|
|||||||
typedef {{as_cType(method.return_type.name)}} (*{{as_cProc(type.name, method.name)}})(
|
typedef {{as_cType(method.return_type.name)}} (*{{as_cProc(type.name, method.name)}})(
|
||||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||||
{%- for arg in method.arguments -%}
|
{%- for arg in method.arguments -%}
|
||||||
, {{as_annotated_cType(arg)}}
|
,{{" "}}
|
||||||
{%- if arg.optional %} /* nullable */{% endif %}
|
{%- if arg.optional %}{{API}}_NULLABLE {% endif -%}
|
||||||
|
{{as_annotated_cType(arg)}}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
);
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
#endif // !defined({{c_prefix}}_SKIP_PROCS)
|
#endif // !defined({{API}}_SKIP_PROCS)
|
||||||
|
|
||||||
#if !defined({{c_prefix}}_SKIP_DECLARATIONS)
|
#if !defined({{API}}_SKIP_DECLARATIONS)
|
||||||
|
|
||||||
{% for function in by_category["function"] %}
|
{% for function in by_category["function"] %}
|
||||||
{{c_prefix}}_EXPORT {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}(
|
{{API}}_EXPORT {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}(
|
||||||
{%- for arg in function.arguments -%}
|
{%- for arg in function.arguments -%}
|
||||||
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
);
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
||||||
// Methods of {{type.name.CamelCase()}}
|
// Methods of {{type.name.CamelCase()}}
|
||||||
{% for method in c_methods(type) %}
|
{% for method in c_methods(type) %}
|
||||||
{{c_prefix}}_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
|
{{API}}_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
|
||||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||||
{%- for arg in method.arguments -%}
|
{%- for arg in method.arguments -%}
|
||||||
, {{as_annotated_cType(arg)}}
|
,{{" "}}
|
||||||
{%- if arg.optional %} /* nullable */{% endif %}
|
{%- if arg.optional %}{{API}}_NULLABLE {% endif -%}
|
||||||
|
{{as_annotated_cType(arg)}}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
);
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
#endif // !defined({{c_prefix}}_SKIP_DECLARATIONS)
|
#endif // !defined({{API}}_SKIP_DECLARATIONS)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user