1.1 --- a/encoders.py Mon Dec 05 16:03:06 2016 +0100
1.2 +++ b/encoders.py Mon Dec 05 17:18:34 2016 +0100
1.3 @@ -389,6 +389,18 @@
1.4
1.5 return "#%s" % path
1.6
1.7 +def decode_type_attribute(s):
1.8 +
1.9 + "Decode the special type attribute 's'."
1.10 +
1.11 + return s[1:]
1.12 +
1.13 +def is_type_attribute(s):
1.14 +
1.15 + "Return whether 's' is a type attribute name."
1.16 +
1.17 + return s.startswith("#")
1.18 +
1.19
1.20
1.21 # A mapping from kinds to structure size reference prefixes.
2.1 --- a/generator.py Mon Dec 05 16:03:06 2016 +0100
2.2 +++ b/generator.py Mon Dec 05 17:18:34 2016 +0100
2.3 @@ -29,7 +29,8 @@
2.4 encode_path, \
2.5 encode_predefined_reference, encode_size, \
2.6 encode_symbol, encode_tablename, \
2.7 - encode_type_attribute
2.8 + encode_type_attribute, decode_type_attribute, \
2.9 + is_type_attribute
2.10 from os import listdir
2.11 from os.path import exists, isdir, join, split
2.12 from referencing import Reference
2.13 @@ -824,6 +825,12 @@
2.14 structure.append("%s /* %s */" % (constant_value, attrname))
2.15 continue
2.16
2.17 + # Special class relationship attributes.
2.18 +
2.19 + elif is_type_attribute(attrname):
2.20 + structure.append("{0, &%s}" % encode_path(decode_type_attribute(attrname)))
2.21 + continue
2.22 +
2.23 structure.append(self.encode_member(origin, attrname, attr, kind))
2.24
2.25 def encode_member(self, path, name, ref, structure_type):