# HG changeset patch # User Paul Boddie # Date 1548978648 -3600 # Node ID c34258c626307606b8a3a13449120a9182703ce4 # Parent b1cfb839a60e86227c24d732edaa9f29a9a3e67e Fixed instance definitions to use the correct size identifiers, not those for classes. This fixes instance size calculations and instance allocation. diff -r b1cfb839a60e -r c34258c62630 generator.py --- a/generator.py Sat Jan 26 01:04:18 2019 +0100 +++ b/generator.py Fri Feb 01 00:50:48 2019 +0100 @@ -3,7 +3,7 @@ """ Generate C code from object layouts and other deduced information. -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie +Copyright (C) 2015, 2016, 2017, 2018, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -246,7 +246,7 @@ self.populate_structure(Reference(kind, path), attrs, kind, structure) if kind == "": - self.write_instance_structure(f_decls, path, structure_size) + self.write_instance_structure(f_decls, path) self.write_structure(f_decls, f_defs, path, table_name, structure, kind == "" and path) @@ -289,7 +289,6 @@ cls = self.function_type table_name = encode_tablename("", cls) - structure_size = encode_size("", path) # Set a special callable attribute on the instance. @@ -302,7 +301,7 @@ # Functions with defaults need to declare instance structures. if self.importer.function_defaults.get(path): - self.write_instance_structure(f_decls, path, structure_size) + self.write_instance_structure(f_decls, path) extra_function_instances.append(path) # Write function declarations. @@ -809,13 +808,14 @@ """ % (table_name, min_parameters, max_parameters, structure_size, ",\n ".join(members)) - def write_instance_structure(self, f_decls, path, structure_size): + def write_instance_structure(self, f_decls, path): """ - Write a declaration to 'f_decls' for the object having the given 'path' - and the given 'structure_size'. + Write a declaration to 'f_decls' for the object having the given 'path'. """ + structure_size = encode_size("", path) + # Write an instance-specific type definition for instances of classes. # See: templates/types.h