Allow device lost callback to be passed at creation
This change updates the Device descriptor to allow a device lost
callback to be passed in at device creation time. This will be
important for allowing the API to return devices which have
already been lost in a future CL, which is the behavior required
by the spec.
This change does not yet deprecate the old method for setting the
callback, as there's still some tricky scenarios that will need to
be worked around to enable that and this CL is already fairly
large. (The uses in question pass the device or a value created
from the device as the userdata.)
Bug: chromium:1234617
Change-Id: I1adea5ceffdfdcfedff9fff4960f12303abba29c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121041
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
diff --git a/generator/templates/api.h b/generator/templates/api.h
index c4def22..bf220e7 100644
--- a/generator/templates/api.h
+++ b/generator/templates/api.h
@@ -65,6 +65,11 @@
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
{% endfor %}
+// Structure forward declarations
+{% for type in by_category["structure"] %}
+ struct {{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 %}
@@ -78,6 +83,18 @@
{% endfor -%}
+{% for type in by_category["function pointer"] %}
+ 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 %}{% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ {%- endif -%}
+ );
+{% endfor %}
+
typedef struct {{c_prefix}}ChainedStruct {
struct {{c_prefix}}ChainedStruct const * next;
{{c_prefix}}SType sType;