1.1 --- a/generator.py Mon Feb 27 14:41:27 2017 +0100
1.2 +++ b/generator.py Mon Feb 27 14:54:37 2017 +0100
1.3 @@ -564,7 +564,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) {.value=&%s})" % (attr_name, structure_name)
1.8 + print >>f_decls, "#define %s __ATTRVALUE(&%s)" % (attr_name, structure_name)
1.9
1.10 def make_parameter_table(self, f_decls, f_defs, argmin, parameters):
1.11
1.12 @@ -1180,14 +1180,14 @@
1.13 }
1.14 __Catch(__tmp_exc)
1.15 {
1.16 - if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {.value=&__builtins___exception_system_SystemExit})))
1.17 + if (__ISINSTANCE(__tmp_exc.arg, __ATTRVALUE(&__builtins___exception_system_SystemExit)))
1.18 return __load_via_object(
1.19 __load_via_object(__tmp_exc.arg.value, __data__).value,
1.20 value).intvalue;
1.21
1.22 fprintf(stderr, "Program terminated due to exception: %%s.\\n",
1.23 __load_via_object(
1.24 - %s((__attr[]) {__NULL, __tmp_exc.arg}).value,
1.25 + %s(__ARGS(__NULL, __tmp_exc.arg)).value,
1.26 __data__).strvalue);
1.27 return 1;
1.28 }
3.1 --- a/templates/types.h Mon Feb 27 14:41:27 2017 +0100
3.2 +++ b/templates/types.h Mon Feb 27 14:54:37 2017 +0100
3.3 @@ -105,13 +105,10 @@
3.4
3.5 #define __INSTANCEPOS 0
3.6
3.7 -/* Special null values. */
3.8 -
3.9 -#define __NULL ((__attr) {.value=0})
3.10 +/* Attribute value setting. */
3.11
3.12 -/* Function pointer type. */
3.13 -
3.14 -typedef __attr (*__func)();
3.15 +#define __ATTRVALUE(VALUE) ((__attr) {.value=VALUE})
3.16 +#define __NULL __ATTRVALUE(0)
3.17
3.18 /* Argument lists. */
3.19
4.1 --- a/translator.py Mon Feb 27 14:41:27 2017 +0100
4.2 +++ b/translator.py Mon Feb 27 14:54:37 2017 +0100
4.3 @@ -154,7 +154,7 @@
4.4 elif static_name:
4.5 parent = ref.parent()
4.6 context = ref.has_kind("<function>") and encode_path(parent) or None
4.7 - return "((__attr) {.value=&%s})" % static_name
4.8 + return "__ATTRVALUE(&%s)" % static_name
4.9
4.10 # Qualified names must be converted into parent-relative accesses.
4.11
4.12 @@ -938,9 +938,8 @@
4.13 ref = self.importer.identify(class_name)
4.14
4.15 if not ref.static():
4.16 - self.process_assignment_for_object(
4.17 - n.name, make_expression("((__attr) {.value=&%s})" %
4.18 - encode_path(class_name)))
4.19 + self.process_assignment_for_object(n.name,
4.20 + make_expression("__ATTRVALUE(&%s)" % encode_path(class_name)))
4.21
4.22 self.enter_namespace(n.name)
4.23
4.24 @@ -1117,7 +1116,7 @@
4.25 context = self.is_method(objpath)
4.26
4.27 self.process_assignment_for_object(original_name,
4.28 - make_expression("((__attr) {.value=&%s})" % encode_path(objpath)))
4.29 + make_expression("__ATTRVALUE(&%s)" % encode_path(objpath)))
4.30
4.31 def process_function_defaults(self, n, name, objpath, instance_name=None):
4.32
4.33 @@ -1326,7 +1325,7 @@
4.34
4.35 if context_required:
4.36 if have_access_context:
4.37 - args = ["(__attr) {.value=%s}" % context_identity]
4.38 + args = ["__ATTRVALUE(%s)" % context_identity]
4.39 else:
4.40 args = ["__CONTEXT_AS_VALUE(%s)" % target_var]
4.41 else:
4.42 @@ -1507,14 +1506,14 @@
4.43 # Without defaults, produce an attribute referring to the function.
4.44
4.45 if not defaults:
4.46 - return make_expression("((__attr) {.value=&%s})" % encode_path(function_name))
4.47 + return make_expression("__ATTRVALUE(&%s)" % encode_path(function_name))
4.48
4.49 # With defaults, copy the function structure and set the defaults on the
4.50 # copy.
4.51
4.52 else:
4.53 self.record_temp("__tmp_value")
4.54 - return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, (__attr) {.value=__tmp_value})" % (
4.55 + return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, __ATTRVALUE(__tmp_value))" % (
4.56 encode_path(function_name),
4.57 encode_symbol("obj", function_name),
4.58 ", ".join(defaults)))