zephyr/scripts/dts/test-bindings/enums.yaml
Martí Bolívar b6dc0a24f7 edtlib: improve enum support
Add enum_tokenizable and enum_upper_tokenizable to PropertySpec. These
allow a PropertySpec to declare that it both has an enumeration of
values and all of them are strings which are "tokenizable". Don't
bother extending Property with these; the user can access the
information through Property.spec now, so the extra delegation is
unnecessary.

See the docstrings for details on what "tokenizable" means. The basic
idea is that we should be able to use the DT binding's enum values as
C 'enum' enumerators in a "reasonable way".

Add val_as_token to Property. This produces a canonical token for the
property value.

Add tests for this feature in particular and property enumerations in
general.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-12-13 19:25:24 -05:00

37 lines
626 B
YAML

# Copyright (c) 2020 Nordic Semiconductor ASA
# SPDX-License-Identifier: BSD-3-Clause
description: Property enum test
compatible: "enums"
properties:
int-enum:
type: int
enum:
- 1
- 2
- 3
string-enum: # not tokenizable
type: string
enum:
- foo bar
- foo_bar
tokenizable-lower-enum: # tokenizable in lowercase only
type: string
enum:
- bar
- BAR
tokenizable-enum: # tokenizable in lower and uppercase
type: string
enum:
- bar
- whitespace is ok
- 123 is ok
no-enum:
type: string