1.1 --- a/generator.py Mon Feb 27 14:44:30 2017 +0100
1.2 +++ b/generator.py Mon Feb 27 14:52:11 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, %s).value,
1.20 %s).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 %s).strvalue);
1.27 return 1;
1.28 }
2.1 --- a/templates/types.h Mon Feb 27 14:44:30 2017 +0100
2.2 +++ b/templates/types.h Mon Feb 27 14:52:11 2017 +0100
2.3 @@ -105,13 +105,10 @@
2.4
2.5 #define __INSTANCEPOS 0
2.6
2.7 -/* Special null values. */
2.8 -
2.9 -#define __NULL ((__attr) {.value=0})
2.10 +/* Attribute value setting. */
2.11
2.12 -/* Function pointer type. */
2.13 -
2.14 -typedef __attr (*__func)();
2.15 +#define __ATTRVALUE(VALUE) ((__attr) {.value=VALUE})
2.16 +#define __NULL __ATTRVALUE(0)
2.17
2.18 /* Argument lists. */
2.19
3.1 --- a/translator.py Mon Feb 27 14:44:30 2017 +0100
3.2 +++ b/translator.py Mon Feb 27 14:52:11 2017 +0100
3.3 @@ -154,7 +154,7 @@
3.4 elif static_name:
3.5 parent = ref.parent()
3.6 context = ref.has_kind("<function>") and encode_path(parent) or None
3.7 - return "((__attr) {.value=&%s})" % static_name
3.8 + return "__ATTRVALUE(&%s)" % static_name
3.9
3.10 # Qualified names must be converted into parent-relative accesses.
3.11
3.12 @@ -938,9 +938,8 @@
3.13 ref = self.importer.identify(class_name)
3.14
3.15 if not ref.static():
3.16 - self.process_assignment_for_object(
3.17 - n.name, make_expression("((__attr) {.value=&%s})" %
3.18 - encode_path(class_name)))
3.19 + self.process_assignment_for_object(n.name,
3.20 + make_expression("__ATTRVALUE(&%s)" % encode_path(class_name)))
3.21
3.22 self.enter_namespace(n.name)
3.23
3.24 @@ -1118,7 +1117,7 @@
3.25 context = self.is_method(objpath)
3.26
3.27 self.process_assignment_for_object(original_name,
3.28 - make_expression("((__attr) {.value=&%s})" % encode_path(objpath)))
3.29 + make_expression("__ATTRVALUE(&%s)" % encode_path(objpath)))
3.30
3.31 def process_function_defaults(self, n, name, objpath, instance_name=None):
3.32
3.33 @@ -1327,7 +1326,7 @@
3.34
3.35 if context_required:
3.36 if have_access_context:
3.37 - args = ["(__attr) {.value=%s}" % context_identity]
3.38 + args = ["__ATTRVALUE(%s)" % context_identity]
3.39 else:
3.40 args = ["__CONTEXT_AS_VALUE(%s)" % target_var]
3.41 else:
3.42 @@ -1509,14 +1508,14 @@
3.43 # Without defaults, produce an attribute referring to the function.
3.44
3.45 if not defaults:
3.46 - return make_expression("((__attr) {.value=&%s})" % encode_path(function_name))
3.47 + return make_expression("__ATTRVALUE(&%s)" % encode_path(function_name))
3.48
3.49 # With defaults, copy the function structure and set the defaults on the
3.50 # copy.
3.51
3.52 else:
3.53 self.record_temp("__tmp_value")
3.54 - return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, (__attr) {.value=__tmp_value})" % (
3.55 + return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, __ATTRVALUE(__tmp_value))" % (
3.56 encode_path(function_name),
3.57 encode_symbol("obj", function_name),
3.58 ", ".join(defaults)))