From: Philippe Proulx Date: Thu, 17 Mar 2016 20:58:44 +0000 (-0400) Subject: Fix: config: start from cur last value when updating enum type obj X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=a29b6bed123380c9c785c9b547872356b59bb3de;p=deliverable%2Fbarectf.git Fix: config: start from cur last value when updating enum type obj Signed-off-by: Philippe Proulx --- diff --git a/barectf/config.py b/barectf/config.py index c8fd904..752e029 100644 --- a/barectf/config.py +++ b/barectf/config.py @@ -1518,6 +1518,12 @@ class _YamlConfigParser: raise ConfigError('"members" property of enumeration type object must be an array') cur = 0 + last_value = obj.last_value + + if last_value is None: + cur = 0 + else: + cur = last_value + 1 for index, m_node in enumerate(members_node): if not _is_str_prop(m_node) and not _is_assoc_array_prop(m_node): diff --git a/barectf/metadata.py b/barectf/metadata.py index 8fd665f..f435dfb 100644 --- a/barectf/metadata.py +++ b/barectf/metadata.py @@ -264,6 +264,13 @@ class Enum(Type): def members(self): return self._members + @property + def last_value(self): + if not self._members: + return + + return list(self._members.values())[-1][1] + def value_of(self, label): return self._members[label]