# HG changeset patch # User Paul Boddie # Date 1486851321 -3600 # Node ID 4e9856fce8e3f58471664f5b415746df92961f88 # Parent b76a0be09cb2822382003ba3e8cc9d1ea7d4f89e Tidied up table output and made use of convenience macros. diff -r b76a0be09cb2 -r 4e9856fce8e3 generator.py --- a/generator.py Sat Feb 11 16:04:40 2017 +0100 +++ b/generator.py Sat Feb 11 23:15:21 2017 +0100 @@ -650,9 +650,14 @@ # Write the corresponding definition. - print >>f_defs, "const __table %s = {\n %s,\n {\n %s\n }\n };\n" % ( - table_name, structure_size, - ",\n ".join(table)) + print >>f_defs, """\ +const __table %s = { + %s, + { + %s + } +}; +""" % (table_name, structure_size, ",\n ".join(table)) def write_parameter_table(self, f_decls, f_defs, table_name, structure_size, table): @@ -662,13 +667,22 @@ with 'table' details used to populate the definition. """ + members = [] + for t in table: + members.append("{%s, %s}" % t) + print >>f_decls, "extern const __ptable %s;\n" % table_name # Write the corresponding definition. - print >>f_defs, "const __ptable %s = {\n %s,\n {\n %s\n }\n };\n" % ( - table_name, structure_size, - ",\n ".join([("{%s, %s}" % t) for t in table])) + print >>f_defs, """\ +const __ptable %s = { + %s, + { + %s + } +}; +""" % (table_name, structure_size, ",\n ".join(members)) def write_instance_structure(self, f_decls, path, structure_size): diff -r b76a0be09cb2 -r 4e9856fce8e3 templates/progops.c --- a/templates/progops.c Sat Feb 11 16:04:40 2017 +0100 +++ b/templates/progops.c Sat Feb 11 23:15:21 2017 +0100 @@ -33,7 +33,7 @@ __attr self = {.context=obj, .value=obj}; __attr tmp = {.context=0, .value=cls}; obj->table = table; - __store_via_object(obj, __pos___class__, tmp); + __store_via_object(obj, __ATTRPOS(__class__), tmp); return self; } @@ -69,7 +69,7 @@ /* Store a reference to the data in the object's __data__ attribute. */ - __store_via_object(args[0].value, __pos___data__, attr); + __store_via_object(args[0].value, __ATTRPOS(__data__), attr); } #ifdef __HAVE___builtins___dict_dict @@ -183,7 +183,7 @@ { /* Obtain the __args__ special member, referencing the parameter table. */ - __attr minparams = __check_and_load_via_object(callable.value, __pos___args__, __code___args__); + __attr minparams = __check_and_load_via_object(callable.value, __ATTRPOS(__args__), __ATTRCODE(__args__)); /* Refer to the table and minimum/maximum. */