From: Philippe Proulx Date: Thu, 10 Mar 2016 23:06:51 +0000 (-0500) Subject: config: prefer using $return-ctype prop in 2.1 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=a3062ddee268e21597850cda38e22ab33714d276;p=deliverable%2Fbarectf.git config: prefer using $return-ctype prop in 2.1 All properties of config objects which do not end up in the TSDL metadata, i.e. properties for barectf itself, should be prefixed with $ in the future. Signed-off-by: Philippe Proulx --- diff --git a/README.md b/README.md index 5a384dc..8cf3db9 100644 --- a/README.md +++ b/README.md @@ -346,7 +346,7 @@ clocks: freq: 1000000000 offset: seconds: 1434072888 - return-ctype: uint64_t + $return-ctype: uint64_t env: my_system_version: '0.3.2-2015.03' bID: 15 @@ -407,9 +407,9 @@ A CTF clock. | `error-cycles` | Integer (zero or positive) | Error (uncertainty) of clock in clock cycles | Optional | 0 | | `offset` | [Clock offset object](#clock-offset-object) | Offset | Optional | Default clock offset object | | `absolute` | Boolean | Absolute clock | Optional | `false` | -| `return-ctype` | String | Return C type of the associated clock callback | Optional | `uint32_t` | +| `$return-ctype` | String | Return C type of the associated clock callback | Optional | `uint32_t` | -The `return-ctype` property must be set to a valid C integer type +The `$return-ctype` property must be set to a valid C integer type (or valid type definition). This is not currently validated by barectf itself, but the C compiler will fail to compile the generated C code if the clock's return type is not a valid C integer type. @@ -425,7 +425,7 @@ offset: seconds: 1434072888 cycles: 2003912 absolute: false -return-ctype: unsigned long long +$return-ctype: unsigned long long ``` diff --git a/barectf/config.py b/barectf/config.py index 00d1da6..84f0a1f 100644 --- a/barectf/config.py +++ b/barectf/config.py @@ -1704,8 +1704,7 @@ class _YamlConfigParser: def _create_clock(self, node): # create clock object clock = metadata.Clock() - - unk_prop = _get_first_unknown_prop(node, [ + known_props = [ 'uuid', 'description', 'freq', @@ -1713,7 +1712,12 @@ class _YamlConfigParser: 'offset', 'absolute', 'return-ctype', - ]) + ] + + if self._version >= 201: + known_props.append('$return-ctype') + + unk_prop = _get_first_unknown_prop(node, known_props) if unk_prop: raise ConfigError('unknown clock object property: "{}"'.format(unk_prop)) @@ -1810,14 +1814,29 @@ class _YamlConfigParser: clock.absolute = absolute - # return C type - if 'return-ctype' in node: - ctype = node['return-ctype'] + # return C type: + # v2.0: "return-ctype" + # v2.1+: "$return-ctype" + return_ctype_node = None + + if self._version >= 200: + if 'return-ctype' in node: + return_ctype_prop = 'return-ctype' + return_ctype_node = node[return_ctype_prop] + + if self._version >= 201: + if '$return-ctype' in node: + if return_ctype_node is not None: + raise ConfigError('cannot specify both "return-ctype" and "$return-ctype" properties of clock object: prefer "$return-ctype"') + + return_ctype_prop = '$return-ctype' + return_ctype_node = node[return_ctype_prop] - if not _is_str_prop(ctype): - raise ConfigError('"return-ctype" property of clock object must be a string') + if return_ctype_node is not None: + if not _is_str_prop(return_ctype_node): + raise ConfigError('"{}" property of clock object must be a string'.format(return_ctype_prop)) - clock.return_ctype = ctype + clock.return_ctype = return_ctype_node return clock diff --git a/doc/examples/linux-fs-simple/config.yaml b/doc/examples/linux-fs-simple/config.yaml index c1e94ad..6c0b59c 100644 --- a/doc/examples/linux-fs-simple/config.yaml +++ b/doc/examples/linux-fs-simple/config.yaml @@ -1,4 +1,4 @@ -version: '2.0' +version: '2.1' metadata: type-aliases: uint8: @@ -78,7 +78,7 @@ metadata: freq: 1000000000 offset: seconds: 1434072888 - return-ctype: uint64_t + $return-ctype: uint64_t trace: byte-order: le uuid: auto diff --git a/doc/examples/parallella/config.yaml b/doc/examples/parallella/config.yaml index bbf7627..2ff3bbb 100644 --- a/doc/examples/parallella/config.yaml +++ b/doc/examples/parallella/config.yaml @@ -1,4 +1,4 @@ -version: '2.0' +version: '2.1' metadata: type-aliases: uint8: @@ -83,7 +83,7 @@ metadata: freq: 1000000000 offset: seconds: 1434580186 - return-ctype: uint64_t + $return-ctype: uint64_t trace: byte-order: le uuid: auto