mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 10:25:28 +00:00
Adds strformat code-gen for helping auto-generate readable strings for structs.
- Adds generator infra for absl::StrFormat for bind group structs and types. - Uses absl::ParsedFormat to avoid multiple parsing for format strings. Bug: dawn:549 Change-Id: Ida4ca65eb85c4474c492161c8ae34f53bd692a3c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/81944 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Loko Kung <lokokung@google.com>
This commit is contained in:
@@ -684,6 +684,15 @@ def as_wireType(metadata, typ):
|
||||
return as_cppType(typ.name)
|
||||
|
||||
|
||||
def as_formatType(typ):
|
||||
# Unsigned integral types
|
||||
if typ.json_data['type'] in ['bool', 'uint32_t', 'uint64_t']:
|
||||
return 'u'
|
||||
|
||||
# Defaults everything else to strings.
|
||||
return 's'
|
||||
|
||||
|
||||
def c_methods(params, typ):
|
||||
return typ.methods + [
|
||||
x for x in [
|
||||
@@ -753,7 +762,8 @@ def make_base_render_params(metadata):
|
||||
'as_jsEnumValue': as_jsEnumValue,
|
||||
'convert_cType_to_cppType': convert_cType_to_cppType,
|
||||
'as_varName': as_varName,
|
||||
'decorate': decorate
|
||||
'decorate': decorate,
|
||||
'as_formatType': as_formatType
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user