# HG changeset patch # User Paul Boddie # Date 1477492577 -7200 # Node ID f06dc96f9ab769af95e6b6e5c337c87d0df23c86 # Parent 8d46733a3be329276a75a1f9b26dcd92f72168c0 Use the parent of an method attribute's origin as its context. diff -r 8d46733a3be3 -r f06dc96f9ab7 generator.py --- a/generator.py Wed Oct 26 13:09:44 2016 +0200 +++ b/generator.py Wed Oct 26 16:36:17 2016 +0200 @@ -774,13 +774,17 @@ return "{0, 0} /* %s */" % name # Set the context depending on the kind of attribute. - # For methods: {&, &} + # For methods: {&, &} # For other attributes: {&, &} else: - context = (kind == "" and structure_type == "" and \ - "&%s" % encode_path(path) or "0") or \ - kind == "" and "&%s" % encode_path(origin) or "0" + if kind == "" and structure_type == "": + parent = origin.rsplit(".", 1)[0] + context = "&%s" % encode_path(parent) + elif kind == "": + context = "&%s" % encode_path(origin) + else: + context = "0" return "{%s, &%s}" % (context, encode_path(origin)) def append_defaults(self, path, structure):