mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
Add ability to generate typedefs from dawn.json
Can be used to help with deprecation during simple struct renames. Includes typedefs for VertexAttributeDescriptor -> VertexAttribute and VertexBufferLayoutDescriptor -> VertexBufferLayout as specified by the latest RenderPipelineDescriptor changes. Bug: dawn:642 Change-Id: Iab3d74d179884499540e813b0e66859713031ccb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40581 Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
734e88b2e7
commit
58a471ae25
@@ -128,6 +128,12 @@ class CallbackType(Type):
|
||||
self.arguments = []
|
||||
|
||||
|
||||
class TypedefType(Type):
|
||||
def __init__(self, name, json_data):
|
||||
Type.__init__(self, name, json_data)
|
||||
self.type = None
|
||||
|
||||
|
||||
class NativeType(Type):
|
||||
def __init__(self, name, json_data):
|
||||
Type.__init__(self, name, json_data, native=True)
|
||||
@@ -271,6 +277,10 @@ def link_callback(callback, types):
|
||||
types)
|
||||
|
||||
|
||||
def link_typedef(typedef, types):
|
||||
typedef.type = types[typedef.json_data['type']]
|
||||
|
||||
|
||||
# Sort structures so that if struct A has struct B as a member, then B is
|
||||
# listed before A.
|
||||
#
|
||||
@@ -321,6 +331,7 @@ def parse_json(json):
|
||||
'callback': CallbackType,
|
||||
'object': ObjectType,
|
||||
'structure': StructureType,
|
||||
'typedef': TypedefType,
|
||||
}
|
||||
|
||||
types = {}
|
||||
@@ -346,6 +357,9 @@ def parse_json(json):
|
||||
for callback in by_category['callback']:
|
||||
link_callback(callback, types)
|
||||
|
||||
for typedef in by_category['typedef']:
|
||||
link_typedef(typedef, types)
|
||||
|
||||
for category in by_category.keys():
|
||||
by_category[category] = sorted(
|
||||
by_category[category], key=lambda typ: typ.name.canonical_case())
|
||||
|
||||
Reference in New Issue
Block a user