diff --git a/spine-c/codegen/exclusions.txt b/spine-c/codegen/exclusions.txt index c54e0c656..01a212684 100644 --- a/spine-c/codegen/exclusions.txt +++ b/spine-c/codegen/exclusions.txt @@ -33,6 +33,9 @@ method: TrackEntry::setListener method: TrackEntry::getListener method: Atlas::Atlas +# Exclude Atlas destructor - we handle atlas disposal in extensions.cpp +method: Atlas::~Atlas + # Used in UE4/cocos2dx, not used anywhere else method: AnimationState::setRendererObject method: TrackEntry::setRendererObject diff --git a/spine-c/codegen/src/c-types.ts b/spine-c/codegen/src/c-types.ts index 2597b3d3e..76b241c83 100644 --- a/spine-c/codegen/src/c-types.ts +++ b/spine-c/codegen/src/c-types.ts @@ -18,7 +18,7 @@ export interface CClassOrStruct { name: string; // C type name (e.g., "spine_bone") cppType: ClassOrStruct; // Original C++ type info constructors: CMethod[]; // All constructors (including default) - destructor: CMethod; // Always present (calls delete) + destructor: CMethod | null; // Present unless excluded (calls delete) methods: CMethod[]; // All methods } diff --git a/spine-c/codegen/src/c-writer.ts b/spine-c/codegen/src/c-writer.ts index 2a9aa06b7..893c257a0 100644 --- a/spine-c/codegen/src/c-writer.ts +++ b/spine-c/codegen/src/c-writer.ts @@ -52,8 +52,10 @@ export class CWriter { lines.push(''); } - lines.push(this.writeMethodDeclaration(type.destructor)); - lines.push(''); + if (type.destructor) { + lines.push(this.writeMethodDeclaration(type.destructor)); + lines.push(''); + } for (const method of type.methods) { lines.push(this.writeMethodDeclaration(method)); @@ -87,8 +89,10 @@ export class CWriter { lines.push(''); } - lines.push(this.writeMethodImplementation(type.destructor)); - lines.push(''); + if (type.destructor) { + lines.push(this.writeMethodImplementation(type.destructor)); + lines.push(''); + } for (const method of type.methods) { lines.push(this.writeMethodImplementation(method)); @@ -247,7 +251,9 @@ export class CWriter { // Add all method declarations for (const arrayType of cArrayTypes) { arrayHeaderLines.push(arrayType.constructors.map(c => this.writeMethodDeclaration(c)).join('\n\n')); - arrayHeaderLines.push(this.writeMethodDeclaration(arrayType.destructor)); + if (arrayType.destructor) { + arrayHeaderLines.push(this.writeMethodDeclaration(arrayType.destructor)); + } arrayHeaderLines.push(arrayType.methods.map(c => this.writeMethodDeclaration(c)).join('\n\n')); arrayHeaderLines.push(''); } @@ -275,7 +281,9 @@ export class CWriter { // Add all method implementations for (const arrayType of cArrayTypes) { arraySourceLines.push(arrayType.constructors.map(c => this.writeMethodImplementation(c)).join('\n\n')); - arraySourceLines.push(this.writeMethodImplementation(arrayType.destructor)); + if (arrayType.destructor) { + arraySourceLines.push(this.writeMethodImplementation(arrayType.destructor)); + } arraySourceLines.push(arrayType.methods.map(c => this.writeMethodImplementation(c)).join('\n\n')); arraySourceLines.push(''); } diff --git a/spine-c/codegen/src/ir-generator.ts b/spine-c/codegen/src/ir-generator.ts index dc73f40ca..1f6234ddf 100644 --- a/spine-c/codegen/src/ir-generator.ts +++ b/spine-c/codegen/src/ir-generator.ts @@ -128,7 +128,20 @@ export function generateConstructors(type: ClassOrStruct, knownTypeNames: Set + e.kind === 'method' && + e.typeName === type.name && + e.methodName === `~${type.name}` + ); + + if (isDestructorExcluded) { + console.log(` Excluding destructor: ${type.name}::~${type.name}`); + return null; + } + const cTypeName = `spine_${toSnakeCase(type.name)}`; const cppTypeName = type.name; @@ -893,7 +906,7 @@ export async function generateTypes(types: Type[], exclusions: Exclusion[], allE // Generate IR const constructors = generateConstructors(type, knownTypeNames, exclusions, allTypesMap); - const destructor = generateDestructor(type); + const destructor = generateDestructor(type, exclusions); const methods = generateMethods(type, knownTypeNames, exclusions); const fieldAccessors = generateFieldAccessors(type, knownTypeNames, exclusions); diff --git a/spine-c/src/generated/atlas.cpp b/spine-c/src/generated/atlas.cpp index f8dbcbe70..e1502c933 100644 --- a/spine-c/src/generated/atlas.cpp +++ b/spine-c/src/generated/atlas.cpp @@ -3,10 +3,6 @@ using namespace spine; -void spine_atlas_dispose(spine_atlas self) { - delete (Atlas *) self; -} - void spine_atlas_flip_v(spine_atlas self) { Atlas *_self = (Atlas *) self; _self->flipV(); diff --git a/spine-c/src/generated/atlas.h b/spine-c/src/generated/atlas.h index 82a13b6ec..34744423a 100644 --- a/spine-c/src/generated/atlas.h +++ b/spine-c/src/generated/atlas.h @@ -8,8 +8,6 @@ extern "C" { #endif -SPINE_C_API void spine_atlas_dispose(spine_atlas self); - SPINE_C_API void spine_atlas_flip_v(spine_atlas self); SPINE_C_API spine_atlas_region spine_atlas_find_region(spine_atlas self, const char *name); SPINE_C_API spine_array_atlas_page spine_atlas_get_pages(spine_atlas self);