config: prefer using $return-ctype prop in 2.1
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 10 Mar 2016 23:06:51 +0000 (18:06 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 17 Mar 2016 06:44:25 +0000 (02:44 -0400)
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 <eeppeliteloop@gmail.com>
README.md
barectf/config.py
doc/examples/linux-fs-simple/config.yaml
doc/examples/parallella/config.yaml

index 5a384dc60699d0d34ab70a5715d226865ae2f002..8cf3db93120034984c1a994e16bee7433aa49274 100644 (file)
--- 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
 ```
 
 
index 00d1da6b448d38ca164074f3b22a188084b7d3a5..84f0a1f56f42e30a7e01c560656ab70e15fd42e6 100644 (file)
@@ -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
 
index c1e94add66dfb4f0539d48d262bbd8e076bc3235..6c0b59c94a29062143505fca685d2e957542a1e9 100644 (file)
@@ -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
index bbf7627d979385e616146c101a2207563edbe555..2ff3bbb5492e68e21633f54656187dcd6b49f1b4 100644 (file)
@@ -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
This page took 0.027185 seconds and 4 git commands to generate.