1.1 --- a/generator.py Thu Jan 19 19:23:39 2017 +0100
1.2 +++ b/generator.py Thu Jan 19 23:33:10 2017 +0100
1.3 @@ -535,7 +535,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) {&%s, &%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 @@ -851,7 +851,7 @@
1.13 # Handle gaps in the structure.
1.14
1.15 if attrname is None:
1.16 - structure.append("{0, 0}")
1.17 + structure.append("__NULL")
1.18
1.19 # Handle non-constant and constant members.
1.20
1.21 @@ -884,7 +884,7 @@
1.22 else:
1.23 attr = encode_function_pointer(attr)
1.24
1.25 - structure.append("{%s, .fn=%s}" % (bound_attr and ".b=&%s" % bound_attr or "0", attr))
1.26 + structure.append("{.b=%s, .fn=%s}" % (bound_attr and "&%s" % bound_attr or "0", attr))
1.27 continue
1.28
1.29 # Special argument specification member.
1.30 @@ -937,7 +937,7 @@
1.31 # Special class relationship attributes.
1.32
1.33 elif is_type_attribute(attrname):
1.34 - structure.append("{0, &%s}" % encode_path(decode_type_attribute(attrname)))
1.35 + structure.append("{.context=0, .value=&%s}" % encode_path(decode_type_attribute(attrname)))
1.36 continue
1.37
1.38 # All other kinds of members.
1.39 @@ -976,19 +976,19 @@
1.40
1.41 if kind == "<instance>" and origin == self.none_type:
1.42 attr_path = encode_predefined_reference(self.none_value)
1.43 - return "{&%s, &%s} /* %s */" % (attr_path, attr_path, name)
1.44 + return "{.context=&%s, .value=&%s} /* %s */" % (attr_path, attr_path, name)
1.45
1.46 # Predefined constant members.
1.47
1.48 if (path, name) in self.predefined_constant_members:
1.49 attr_path = encode_predefined_reference("%s.%s" % (path, name))
1.50 - return "{&%s, &%s} /* %s */" % (attr_path, attr_path, name)
1.51 + return "{.context=&%s, .value=&%s} /* %s */" % (attr_path, attr_path, name)
1.52
1.53 # General undetermined members.
1.54
1.55 if kind in ("<var>", "<instance>"):
1.56 attr_path = encode_predefined_reference(self.none_value)
1.57 - return "{&%s, &%s} /* %s */" % (attr_path, attr_path, name)
1.58 + return "{.context=&%s, .value=&%s} /* %s */" % (attr_path, attr_path, name)
1.59
1.60 # Set the context depending on the kind of attribute.
1.61 # For methods: {&<parent>, &<attr>}
1.62 @@ -1002,7 +1002,7 @@
1.63 context = "&%s" % encode_path(origin)
1.64 else:
1.65 context = "0"
1.66 - return "{%s, &%s}" % (context, encode_path(origin))
1.67 + return "{.context=%s, .value=&%s}" % (context, encode_path(origin))
1.68
1.69 def append_defaults(self, path, structure):
1.70
1.71 @@ -1111,21 +1111,22 @@
1.72 %s();""" % function_name
1.73
1.74 print >>f_code, """\
1.75 - return 0;
1.76 }
1.77 __Catch(__tmp_exc)
1.78 {
1.79 - if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {0, &__builtins___exception_system_SystemExit})))
1.80 + if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {.context=0, .value=&__builtins___exception_system_SystemExit})))
1.81 return __load_via_object(
1.82 __load_via_object(__tmp_exc.arg.value, %s).value,
1.83 %s).intvalue;
1.84
1.85 fprintf(stderr, "Program terminated due to exception: %%s.\\n",
1.86 __load_via_object(
1.87 - %s((__attr[]) {{0, 0}, __tmp_exc.arg}).value,
1.88 + %s((__attr[]) {__NULL, __tmp_exc.arg}).value,
1.89 %s).strvalue);
1.90 return 1;
1.91 }
1.92 +
1.93 + return 0;
1.94 }
1.95 """ % (
1.96 encode_symbol("pos", "value"),