1.1 --- a/generator.py Fri Feb 10 16:01:18 2017 +0100
1.2 +++ b/generator.py Fri Feb 10 16:51:17 2017 +0100
1.3 @@ -551,7 +551,7 @@
1.4 # Define a macro for the constant.
1.5
1.6 attr_name = encode_path(const_path)
1.7 - print >>f_decls, "#define %s ((__attr) {.context=&%s, .value=&%s})" % (attr_name, structure_name, structure_name)
1.8 + print >>f_decls, "#define %s ((__attr) {{.context=&%s, .value=&%s}})" % (attr_name, structure_name, structure_name)
1.9
1.10 def make_parameter_table(self, f_decls, f_defs, parameters):
1.11
1.12 @@ -887,7 +887,7 @@
1.13 attr = encode_function_pointer(attr)
1.14 unbound_attr = "__unbound_method"
1.15
1.16 - structure.append("{.inv=%s, .fn=%s}" % (unbound_attr, attr))
1.17 + structure.append("{{.inv=%s, .fn=%s}}" % (unbound_attr, attr))
1.18 continue
1.19
1.20 # Special argument specification member.
1.21 @@ -896,13 +896,13 @@
1.22 signature = self.get_signature_for_callable(ref.get_origin())
1.23 ptable = encode_tablename("<function>", signature)
1.24
1.25 - structure.append("{.min=%s, .ptable=&%s}" % (attr, ptable))
1.26 + structure.append("{{.min=%s, .ptable=&%s}}" % (attr, ptable))
1.27 continue
1.28
1.29 # Special internal data member.
1.30
1.31 elif attrname == "__data__":
1.32 - structure.append("{.size=%d, .%s=%s}" % (
1.33 + structure.append("{{.size=%d, .%s=%s}}" % (
1.34 encode_literal_constant_size(attr),
1.35 encode_literal_constant_member(attr),
1.36 encode_literal_constant_value(attr)))
1.37 @@ -911,8 +911,8 @@
1.38 # Special internal key member.
1.39
1.40 elif attrname == "__key__":
1.41 - structure.append("{.code=%s, .pos=%s}" % (attr and encode_symbol("code", attr) or "0",
1.42 - attr and encode_symbol("pos", attr) or "0"))
1.43 + structure.append("{{.code=%s, .pos=%s}}" % (attr and encode_symbol("code", attr) or "0",
1.44 + attr and encode_symbol("pos", attr) or "0"))
1.45 continue
1.46
1.47 # Special cases.
1.48 @@ -955,13 +955,13 @@
1.49 # object paths.
1.50
1.51 value = path.rsplit(".", 1)[0]
1.52 - structure.append("{.context=0, .value=&%s}" % encode_path(value))
1.53 + structure.append("{{.context=0, .value=&%s}}" % encode_path(value))
1.54 continue
1.55
1.56 # Special class relationship attributes.
1.57
1.58 elif is_type_attribute(attrname):
1.59 - structure.append("{.context=0, .value=&%s}" % encode_path(decode_type_attribute(attrname)))
1.60 + structure.append("{{.context=0, .value=&%s}}" % encode_path(decode_type_attribute(attrname)))
1.61 continue
1.62
1.63 # All other kinds of members.
1.64 @@ -1000,19 +1000,19 @@
1.65
1.66 if kind == "<instance>" and origin == self.none_type:
1.67 attr_path = encode_predefined_reference(self.none_value)
1.68 - return "{.context=&%s, .value=&%s} /* %s */" % (attr_path, attr_path, name)
1.69 + return "{{.context=&%s, .value=&%s}} /* %s */" % (attr_path, attr_path, name)
1.70
1.71 # Predefined constant members.
1.72
1.73 if (path, name) in self.predefined_constant_members:
1.74 attr_path = encode_predefined_reference("%s.%s" % (path, name))
1.75 - return "{.context=&%s, .value=&%s} /* %s */" % (attr_path, attr_path, name)
1.76 + return "{{.context=&%s, .value=&%s}} /* %s */" % (attr_path, attr_path, name)
1.77
1.78 # General undetermined members.
1.79
1.80 if kind in ("<var>", "<instance>"):
1.81 attr_path = encode_predefined_reference(self.none_value)
1.82 - return "{.context=&%s, .value=&%s} /* %s */" % (attr_path, attr_path, name)
1.83 + return "{{.context=&%s, .value=&%s}} /* %s */" % (attr_path, attr_path, name)
1.84
1.85 # Set the context depending on the kind of attribute.
1.86 # For methods: {&<parent>, &<attr>}
1.87 @@ -1026,7 +1026,7 @@
1.88 context = "&%s" % encode_path(origin)
1.89 else:
1.90 context = "0"
1.91 - return "{.context=%s, .value=&%s}" % (context, encode_path(origin))
1.92 + return "{{.context=%s, .value=&%s}}" % (context, encode_path(origin))
1.93
1.94 def append_defaults(self, path, structure):
1.95
1.96 @@ -1138,7 +1138,7 @@
1.97 }
1.98 __Catch(__tmp_exc)
1.99 {
1.100 - if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {.context=0, .value=&__builtins___exception_system_SystemExit})))
1.101 + if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {{.context=0, .value=&__builtins___exception_system_SystemExit}})))
1.102 return __load_via_object(
1.103 __load_via_object(__tmp_exc.arg.value, %s).value,
1.104 %s).intvalue;
2.1 --- a/templates/native/list.c Fri Feb 10 16:01:18 2017 +0100
2.2 +++ b/templates/native/list.c Fri Feb 10 16:51:17 2017 +0100
2.3 @@ -32,7 +32,7 @@
2.4 __attr * const size = &__args[1];
2.5 /* size.__data__ interpreted as int */
2.6 unsigned int n = __load_via_object(size->value, __pos___data__).intvalue;
2.7 - __attr attr = {{0}, .seqvalue=__new_fragment(n)};
2.8 + __attr attr = {{.size=0, .seqvalue=__new_fragment(n)}};
2.9
2.10 /* Return the __data__ attribute. */
2.11 return attr;
2.12 @@ -61,7 +61,7 @@
2.13
2.14 /* Replace the __data__ attribute if appropriate. */
2.15 if (newdata != data)
2.16 - __store_via_object(self->value, __pos___data__, ((__attr) {{0}, .seqvalue=newdata}));
2.17 + __store_via_object(self->value, __pos___data__, ((__attr) {{.size=0, .seqvalue=newdata}}));
2.18 return __builtins___none_None;
2.19 }
2.20
2.21 @@ -92,7 +92,7 @@
2.22
2.23 /* Replace the __data__ attribute if appropriate. */
2.24 if (newdata != data)
2.25 - __store_via_object(self->value, __pos___data__, ((__attr) {{0}, .seqvalue=newdata}));
2.26 + __store_via_object(self->value, __pos___data__, ((__attr) {{.size=0, .seqvalue=newdata}}));
2.27 return __builtins___none_None;
2.28 }
2.29
5.1 --- a/translator.py Fri Feb 10 16:01:18 2017 +0100
5.2 +++ b/translator.py Fri Feb 10 16:51:17 2017 +0100
5.3 @@ -142,7 +142,7 @@
5.4 elif static_name:
5.5 parent = ref.parent()
5.6 context = ref.has_kind("<function>") and encode_path(parent) or None
5.7 - return "((__attr) {.context=%s, .value=&%s})" % (context and "&%s" % context or "0", static_name)
5.8 + return "((__attr) {{.context=%s, .value=&%s}})" % (context and "&%s" % context or "0", static_name)
5.9
5.10 # Qualified names must be converted into parent-relative accesses.
5.11
5.12 @@ -875,7 +875,7 @@
5.13
5.14 if not ref.static():
5.15 self.process_assignment_for_object(
5.16 - n.name, make_expression("((__attr) {.context=0, .value=&%s})" %
5.17 + n.name, make_expression("((__attr) {{.context=0, .value=&%s}})" %
5.18 encode_path(class_name)))
5.19
5.20 self.enter_namespace(n.name)
5.21 @@ -1054,7 +1054,7 @@
5.22 context = self.is_method(objpath)
5.23
5.24 self.process_assignment_for_object(original_name,
5.25 - make_expression("((__attr) {.context=%s, .value=&%s})" % (
5.26 + make_expression("((__attr) {{.context=%s, .value=&%s}})" % (
5.27 context and "&%s" % encode_path(context) or "0",
5.28 encode_path(objpath))))
5.29
5.30 @@ -1414,14 +1414,14 @@
5.31 # Without defaults, produce an attribute referring to the function.
5.32
5.33 if not defaults:
5.34 - return make_expression("((__attr) {.context=0, .value=&%s})" % encode_path(function_name))
5.35 + return make_expression("((__attr) {{.context=0, .value=&%s}})" % encode_path(function_name))
5.36
5.37 # With defaults, copy the function structure and set the defaults on the
5.38 # copy.
5.39
5.40 else:
5.41 self.record_temp("__tmp_value")
5.42 - return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, (__attr) {.context=0, .value=__tmp_value})" % (
5.43 + return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, (__attr) {{.context=0, .value=__tmp_value}})" % (
5.44 encode_path(function_name),
5.45 encode_symbol("obj", function_name),
5.46 ", ".join(defaults)))