optinterpreter: Add support for dictionaries

pull/9382/head
Xavier Claessens 3 years ago committed by Xavier Claessens
parent 709d151eb9
commit a844e9bdb0
  1. 7
      mesonbuild/optinterpreter.py

@ -174,6 +174,13 @@ class OptionInterpreter:
lr = [self.reduce_single(curarg) for curarg in arg.args.arguments]
# mypy really struggles with recursive flattening, help it out
return T.cast(T.Sequence[T.Union[str, int, bool]], lr)
elif isinstance(arg, mparser.DictNode):
d = {}
for k, v in arg.args.kwargs.items():
if not isinstance(k, mparser.StringNode):
raise OptionException('Dictionary keys must be a string literal')
d[k.value] = self.reduce_single(v)
return d
elif isinstance(arg, mparser.UMinusNode):
res = self.reduce_single(arg.value)
if not isinstance(res, (int, float)):

Loading…
Cancel
Save