[tests] Haxe serializer

This commit is contained in:
Mario Zechner 2025-07-30 19:10:13 +02:00
parent 790caa8316
commit 4a715633a7
5 changed files with 7477 additions and 3745 deletions

View File

@ -132,7 +132,7 @@ export class DartWriter {
lines.push(this.generateHeader());
// Imports (unified logic)
lines.push(...this.generateImports(dartClass.imports, dartClass.needsPackageFfi, dartClass.hasRtti));
lines.push(...this.generateImports(dartClass.imports, dartClass.hasRtti));
// Class declaration (unified)
lines.push(this.generateClassDeclaration(dartClass));
@ -242,7 +242,7 @@ export class DartWriter {
// Add destructor as dispose method for concrete classes
if (classType === 'concrete' && cType.destructor) {
members.push(this.createDisposeMethod(cType.destructor, cType));
members.push(this.createDisposeMethod(cType.destructor));
}
// Process methods with unified logic - Apply SAME logic for ALL class types
@ -338,7 +338,7 @@ export class DartWriter {
return overloadedSetters;
}
private createDisposeMethod (destructor: CMethod, cType: CClassOrStruct): DartMember {
private createDisposeMethod (destructor: CMethod): DartMember {
const implementation = `SpineBindings.bindings.${destructor.name}(_ptr);`;
return {
@ -498,7 +498,7 @@ export class DartWriter {
// AUTO GENERATED FILE, DO NOT EDIT.`;
}
private generateImports (imports: string[], needsPackageFfi: boolean, hasRtti: boolean): string[] {
private generateImports (imports: string[], hasRtti: boolean): string[] {
const lines: string[] = [];
lines.push('');

View File

@ -638,7 +638,7 @@ class SkeletonJson {
var box:BoundingBoxAttachment = attachmentLoader.newBoundingBoxAttachment(skin, name);
if (box == null)
return null;
readVertices(map, box, Std.parseInt(Reflect.field(map, "vertexCount")) << 1);
readVertices(map, box, getInt(map, "vertexCount", 0) << 1);
return box;
case AttachmentType.path:
var path:PathAttachment = attachmentLoader.newPathAttachment(skin, name);
@ -646,7 +646,7 @@ class SkeletonJson {
return null;
path.closed = Reflect.hasField(map, "closed") ? cast(Reflect.field(map, "closed"), Bool) : false;
path.constantSpeed = Reflect.hasField(map, "constantSpeed") ? cast(Reflect.field(map, "constantSpeed"), Bool) : true;
var vertexCount:Int = Std.parseInt(Reflect.field(map, "vertexCount"));
var vertexCount:Int = getInt(map, "vertexCount", 0);
readVertices(map, path, vertexCount << 1);
var lengths:Array<Float> = new Array<Float>();
for (curves in cast(Reflect.field(map, "lengths"), Array<Dynamic>)) {

File diff suppressed because it is too large Load Diff

View File

@ -95,7 +95,13 @@ class HeadlessTest {
// Print skeleton state
Sys.println("\n=== SKELETON STATE ===");
Sys.println(serializer.serializeSkeleton(skeleton));
try {
Sys.println(serializer.serializeSkeleton(skeleton));
} catch (e:Dynamic) {
Sys.stderr().writeString('Error serializing skeleton: $e\n');
Sys.stderr().writeString(haxe.CallStack.toString(haxe.CallStack.exceptionStack()) + '\n');
throw e;
}
// Print animation state if present
if (state != null) {

View File

@ -52,7 +52,7 @@ function transformType (javaType: string): string {
// Handle TransformConstraintData inner classes
if (['FromProperty', 'FromRotate', 'FromScaleX', 'FromScaleY', 'FromShearY', 'FromX', 'FromY',
'ToProperty', 'ToRotate', 'ToScaleX', 'ToScaleY', 'ToShearY', 'ToX', 'ToY'].includes(simpleName)) {
'ToProperty', 'ToRotate', 'ToScaleX', 'ToScaleY', 'ToShearY', 'ToX', 'ToY'].includes(simpleName)) {
return 'spine.TransformConstraintData.' + simpleName;
}