mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-08 07:33:33 +00:00
Make dawn.h closer to webgpu.h
This includes several changes to make dawn.h closer to webgpu.h (apart from the renames and copyright changes): - Make nextInChain follow the same type convention as the rest of the header. - Add defines that allow skipping the procs definition or the functions declaration part of the header. - Sort the methods by name for each object. - Put the callback definition inside extern "C" - Make the enums typedef have the name of the enum twice. BUG=dawn:22 Change-Id: I36e4587d60ca43886636ebd19d54752004f4696d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11903 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
a83e0cdbcc
commit
97231682d0
@ -195,6 +195,7 @@ def link_object(obj, types):
|
|||||||
|
|
||||||
methods = [make_method(m) for m in obj.json_data.get('methods', [])]
|
methods = [make_method(m) for m in obj.json_data.get('methods', [])]
|
||||||
obj.methods = [method for method in methods if not is_native_method(method)]
|
obj.methods = [method for method in methods if not is_native_method(method)]
|
||||||
|
obj.methods.sort(key=lambda method: method.name.canonical_case())
|
||||||
obj.native_methods = [method for method in methods if is_native_method(method)]
|
obj.native_methods = [method for method in methods if is_native_method(method)]
|
||||||
|
|
||||||
def link_structure(struct, types):
|
def link_structure(struct, types):
|
||||||
@ -439,7 +440,7 @@ def as_wireType(typ):
|
|||||||
return as_cppType(typ.name)
|
return as_cppType(typ.name)
|
||||||
|
|
||||||
def cpp_native_methods(types, typ):
|
def cpp_native_methods(types, typ):
|
||||||
return typ.methods + typ.native_methods
|
return sorted(typ.methods + typ.native_methods, key=lambda method: method.name.canonical_case())
|
||||||
|
|
||||||
def c_native_methods(types, typ):
|
def c_native_methods(types, typ):
|
||||||
return cpp_native_methods(types, typ) + [
|
return cpp_native_methods(types, typ) + [
|
||||||
|
@ -28,7 +28,7 @@ const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for type in by_category["enum"] + by_category["bitmask"] %}
|
{% for type in by_category["enum"] + by_category["bitmask"] %}
|
||||||
typedef enum {
|
typedef enum {{as_cType(type.name)}} {
|
||||||
{% for value in type.values %}
|
{% for value in type.values %}
|
||||||
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
|
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -40,7 +40,7 @@ const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
|||||||
{% for type in by_category["structure"] %}
|
{% for type in by_category["structure"] %}
|
||||||
typedef struct {{as_cType(type.name)}} {
|
typedef struct {{as_cType(type.name)}} {
|
||||||
{% if type.extensible %}
|
{% if type.extensible %}
|
||||||
const void* nextInChain;
|
void const * nextInChain;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for member in type.members %}
|
{% for member in type.members %}
|
||||||
{{as_annotated_cType(member)}};
|
{{as_annotated_cType(member)}};
|
||||||
@ -49,6 +49,10 @@ const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
|||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// Custom types depending on the target language
|
// Custom types depending on the target language
|
||||||
typedef void (*DawnErrorCallback)(DawnErrorType type, const char* message, void* userdata);
|
typedef void (*DawnErrorCallback)(DawnErrorType type, const char* message, void* userdata);
|
||||||
typedef void (*DawnBufferCreateMappedCallback)(DawnBufferMapAsyncStatus status,
|
typedef void (*DawnBufferCreateMappedCallback)(DawnBufferMapAsyncStatus status,
|
||||||
@ -64,9 +68,7 @@ typedef void (*DawnBufferMapWriteCallback)(DawnBufferMapAsyncStatus status,
|
|||||||
void* userdata);
|
void* userdata);
|
||||||
typedef void (*DawnFenceOnCompletionCallback)(DawnFenceCompletionStatus status, void* userdata);
|
typedef void (*DawnFenceOnCompletionCallback)(DawnFenceCompletionStatus status, void* userdata);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if !defined(DAWN_SKIP_PROCS)
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{% for type in by_category["object"] %}
|
{% for type in by_category["object"] %}
|
||||||
// Procs of {{type.name.CamelCase()}}
|
// Procs of {{type.name.CamelCase()}}
|
||||||
@ -80,6 +82,7 @@ extern "C" {
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
#endif // !defined(DAWN_SKIP_PROCS)
|
||||||
|
|
||||||
struct DawnProcTable_s {
|
struct DawnProcTable_s {
|
||||||
{% for type in by_category["object"] %}
|
{% for type in by_category["object"] %}
|
||||||
@ -93,6 +96,8 @@ typedef struct DawnProcTable_s DawnProcTable;
|
|||||||
|
|
||||||
// Stuff below is for convenience and will forward calls to a static DawnProcTable.
|
// Stuff below is for convenience and will forward calls to a static DawnProcTable.
|
||||||
|
|
||||||
|
#if !defined(DAWN_SKIP_DECLARATIONS)
|
||||||
|
|
||||||
// Set which DawnProcTable will be used
|
// Set which DawnProcTable will be used
|
||||||
DAWN_EXPORT void dawnSetProcs(const DawnProcTable* procs);
|
DAWN_EXPORT void dawnSetProcs(const DawnProcTable* procs);
|
||||||
|
|
||||||
@ -108,6 +113,7 @@ DAWN_EXPORT void dawnSetProcs(const DawnProcTable* procs);
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
#endif // !defined(DAWN_SKIP_DECLARATIONS)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
@ -29,7 +29,6 @@ namespace dawn {
|
|||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
{% for type in by_category["structure"] %}
|
{% for type in by_category["structure"] %}
|
||||||
{% set CppType = as_cppType(type.name) %}
|
{% set CppType = as_cppType(type.name) %}
|
||||||
{% set CType = as_cType(type.name) %}
|
{% set CType = as_cType(type.name) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user