mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[spine-c] Make destructors excludable (needed for spine_atlas_dispose which is overwritten in extensions.cpp)
This commit is contained in:
parent
ab469cbefd
commit
6090b2da22
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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('');
|
||||
}
|
||||
|
||||
@ -128,7 +128,20 @@ export function generateConstructors(type: ClassOrStruct, knownTypeNames: Set<st
|
||||
return constructors;
|
||||
}
|
||||
|
||||
export function generateDestructor(type: ClassOrStruct): CMethod {
|
||||
|
||||
export function generateDestructor(type: ClassOrStruct, exclusions: Exclusion[]): CMethod | null {
|
||||
// Check if destructor is excluded
|
||||
const isDestructorExcluded = exclusions.some(e =>
|
||||
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);
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user