diff --git a/spine-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift b/spine-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817a5..bfa0333a3 100644 --- a/spine-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/spine-flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,5 @@ import FlutterMacOS import Foundation - func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { } diff --git a/spine-flutter/example/macos/Runner/AppDelegate.swift b/spine-flutter/example/macos/Runner/AppDelegate.swift index f8fd66258..3d617e27d 100644 --- a/spine-flutter/example/macos/Runner/AppDelegate.swift +++ b/spine-flutter/example/macos/Runner/AppDelegate.swift @@ -6,7 +6,7 @@ class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } - + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true } diff --git a/spine-haxe/spine-haxe/spine/utils/JsonWriter.hx b/spine-haxe/spine-haxe/spine/utils/JsonWriter.hx index df4b96e20..7b6679662 100644 --- a/spine-haxe/spine-haxe/spine/utils/JsonWriter.hx +++ b/spine-haxe/spine-haxe/spine/utils/JsonWriter.hx @@ -1,95 +1,95 @@ package spine.utils; enum JsonContext { - Object; - Array; + Object; + Array; } class JsonWriter { - private var buffer:StringBuf = new StringBuf(); - private var needsComma:Bool = false; - private var contexts:Array = []; + private var buffer:StringBuf = new StringBuf(); + private var needsComma:Bool = false; + private var contexts:Array = []; - public function new() { - buffer = new StringBuf(); - needsComma = false; - contexts = []; - } + public function new() { + buffer = new StringBuf(); + needsComma = false; + contexts = []; + } - public function writeObjectStart():Void { - writeCommaIfNeeded(); - buffer.add("{"); - contexts.push(Object); - needsComma = false; - } + public function writeObjectStart():Void { + writeCommaIfNeeded(); + buffer.add("{"); + contexts.push(Object); + needsComma = false; + } - public function writeObjectEnd():Void { - buffer.add("}"); - contexts.pop(); - needsComma = true; - } + public function writeObjectEnd():Void { + buffer.add("}"); + contexts.pop(); + needsComma = true; + } - public function writeArrayStart():Void { - writeCommaIfNeeded(); - buffer.add("["); - contexts.push(Array); - needsComma = false; - } + public function writeArrayStart():Void { + writeCommaIfNeeded(); + buffer.add("["); + contexts.push(Array); + needsComma = false; + } - public function writeArrayEnd():Void { - buffer.add("]"); - contexts.pop(); - needsComma = true; - } + public function writeArrayEnd():Void { + buffer.add("]"); + contexts.pop(); + needsComma = true; + } - public function writeName(name:String):Void { - writeCommaIfNeeded(); - buffer.add('"${escapeString(name)}":'); - needsComma = false; - } + public function writeName(name:String):Void { + writeCommaIfNeeded(); + buffer.add('"${escapeString(name)}":'); + needsComma = false; + } - public function writeValue(value:Dynamic):Void { - writeCommaIfNeeded(); - - if (value == null) { - buffer.add("null"); - } else if (Std.isOfType(value, String)) { - buffer.add('"${escapeString(cast(value, String))}"'); - } else if (Std.isOfType(value, Bool)) { - buffer.add(value ? "true" : "false"); - } else if (Std.isOfType(value, Float) || Std.isOfType(value, Int)) { - // Ensure consistent float formatting (C locale style) - buffer.add(Std.string(value)); - } else { - buffer.add(Std.string(value)); - } - - needsComma = true; - } + public function writeValue(value:Dynamic):Void { + writeCommaIfNeeded(); - public function writeNull():Void { - writeCommaIfNeeded(); - buffer.add("null"); - needsComma = true; - } + if (value == null) { + buffer.add("null"); + } else if (Std.isOfType(value, String)) { + buffer.add('"${escapeString(cast(value, String))}"'); + } else if (Std.isOfType(value, Bool)) { + buffer.add(value ? "true" : "false"); + } else if (Std.isOfType(value, Float) || Std.isOfType(value, Int)) { + // Ensure consistent float formatting (C locale style) + buffer.add(Std.string(value)); + } else { + buffer.add(Std.string(value)); + } - public function getString():String { - return buffer.toString(); - } + needsComma = true; + } - private function writeCommaIfNeeded():Void { - if (needsComma) { - buffer.add(","); - } - } + public function writeNull():Void { + writeCommaIfNeeded(); + buffer.add("null"); + needsComma = true; + } - private function escapeString(str:String):String { - // Escape special characters for JSON - str = StringTools.replace(str, "\\", "\\\\"); - str = StringTools.replace(str, '"', '\\"'); - str = StringTools.replace(str, "\n", "\\n"); - str = StringTools.replace(str, "\r", "\\r"); - str = StringTools.replace(str, "\t", "\\t"); - return str; - } -} \ No newline at end of file + public function getString():String { + return buffer.toString(); + } + + private function writeCommaIfNeeded():Void { + if (needsComma) { + buffer.add(","); + } + } + + private function escapeString(str:String):String { + // Escape special characters for JSON + str = StringTools.replace(str, "\\", "\\\\"); + str = StringTools.replace(str, '"', '\\"'); + str = StringTools.replace(str, "\n", "\\n"); + str = StringTools.replace(str, "\r", "\\r"); + str = StringTools.replace(str, "\t", "\\t"); + return str; + } +} diff --git a/spine-haxe/spine-haxe/spine/utils/SkeletonSerializer.hx b/spine-haxe/spine-haxe/spine/utils/SkeletonSerializer.hx index 15b2e8a47..c54fd0a8a 100644 --- a/spine-haxe/spine-haxe/spine/utils/SkeletonSerializer.hx +++ b/spine-haxe/spine-haxe/spine/utils/SkeletonSerializer.hx @@ -36,12 +36,75 @@ class SkeletonSerializer { return json.getString(); } - private function writeAnimation(obj:Animation):Void { + // Core reflection helpers + private function extractPropertyName(javaGetter:String):String { + var getter = javaGetter; + if (getter.indexOf("()") != -1) getter = getter.substr(0, getter.length - 2); + + if (getter.substr(0, 3) == "get") { + var prop = getter.substr(3); + return prop.charAt(0).toLowerCase() + prop.substr(1); + } + if (getter.substr(0, 2) == "is") { + var prop = getter.substr(2); + return prop.charAt(0).toLowerCase() + prop.substr(1); + } + return getter; + } + + private function getSpecialFieldNames(javaGetter:String):Array { + return switch(javaGetter) { + case "getInt()": ["intValue"]; + case "getFloat()": ["floatValue"]; + case "getString()": ["stringValue"]; + case "getPhysicsConstraints()": ["physics"]; + case "getUpdateCache()": ["_updateCache"]; + case "getSetupPose()": ["setup"]; + case "getAppliedPose()": ["applied"]; + default: []; + } + } + + private function getPropertyValue(obj:Dynamic, javaGetter:String):Dynamic { + var propName = extractPropertyName(javaGetter); + + // Try direct field access first + if (Reflect.hasField(obj, propName)) { + return Reflect.field(obj, propName); + } + + // Try special field variations + var specialNames = getSpecialFieldNames(javaGetter); + for (name in specialNames) { + if (Reflect.hasField(obj, name)) { + return Reflect.field(obj, name); + } + } + + // Try method access (remove parentheses) + var methodName = javaGetter; + if (methodName.indexOf("()") != -1) { + methodName = methodName.substr(0, methodName.length - 2); + } + if (Reflect.hasField(obj, methodName)) { + var method = Reflect.field(obj, methodName); + if (Reflect.isFunction(method)) { + return Reflect.callMethod(obj, method, []); + } + } + + // Last resort: return null and let the caller handle it + return null; + } + + private function writeAnimation(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -51,30 +114,27 @@ class SkeletonSerializer { json.writeValue("Animation"); json.writeName("timelines"); - json.writeArrayStart(); - for (item in obj.timelines) { - writeTimeline(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getTimelines()", {"kind":"array","name":"timelines","getter":"getTimelines()","elementType":"Timeline","elementKind":"object","writeMethodCall":"writeTimeline","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.duration); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeName("bones"); - writeIntArray(obj.bones); + writeProperty(obj, "getBones()", {"kind":"object","name":"bones","getter":"getBones()","valueType":"IntArray","writeMethodCall":"writeIntArray","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writeAlphaTimeline(obj:AlphaTimeline):Void { + private function writeAlphaTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -84,40 +144,33 @@ class SkeletonSerializer { json.writeValue("AlphaTimeline"); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeAttachmentTimeline(obj:AttachmentTimeline):Void { + private function writeAttachmentTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -127,47 +180,36 @@ class SkeletonSerializer { json.writeValue("AttachmentTimeline"); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("attachmentNames"); - json.writeArrayStart(); - for (item in obj.attachmentNames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getAttachmentNames()", {"kind":"array","name":"attachmentNames","getter":"getAttachmentNames()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeDeformTimeline(obj:DeformTimeline):Void { + private function writeDeformTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -177,58 +219,39 @@ class SkeletonSerializer { json.writeValue("DeformTimeline"); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("attachment"); - writeVertexAttachment(obj.attachment); + writeProperty(obj, "getAttachment()", {"kind":"object","name":"attachment","getter":"getAttachment()","valueType":"VertexAttachment","writeMethodCall":"writeVertexAttachment","isNullable":false}); json.writeName("vertices"); - json.writeArrayStart(); - for (nestedArray in obj.vertices) { - if (nestedArray == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (elem in nestedArray) { - json.writeValue(elem); - } - json.writeArrayEnd(); - } - } - json.writeArrayEnd(); + writeProperty(obj, "getVertices()", {"kind":"nestedArray","name":"vertices","getter":"getVertices()","elementType":"float","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeDrawOrderTimeline(obj:DrawOrderTimeline):Void { + private function writeDrawOrderTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -238,52 +261,33 @@ class SkeletonSerializer { json.writeValue("DrawOrderTimeline"); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("drawOrders"); - json.writeArrayStart(); - for (nestedArray in obj.drawOrders) { - if (nestedArray == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (elem in nestedArray) { - json.writeValue(elem); - } - json.writeArrayEnd(); - } - } - json.writeArrayEnd(); + writeProperty(obj, "getDrawOrders()", {"kind":"nestedArray","name":"drawOrders","getter":"getDrawOrders()","elementType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeEventTimeline(obj:EventTimeline):Void { + private function writeEventTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -293,44 +297,33 @@ class SkeletonSerializer { json.writeValue("EventTimeline"); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("events"); - json.writeArrayStart(); - for (item in obj.events) { - writeEvent(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getEvents()", {"kind":"array","name":"events","getter":"getEvents()","elementType":"Event","elementKind":"object","writeMethodCall":"writeEvent","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeIkConstraintTimeline(obj:IkConstraintTimeline):Void { + private function writeIkConstraintTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -340,40 +333,33 @@ class SkeletonSerializer { json.writeValue("IkConstraintTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeInheritTimeline(obj:InheritTimeline):Void { + private function writeInheritTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -383,40 +369,33 @@ class SkeletonSerializer { json.writeValue("InheritTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePathConstraintMixTimeline(obj:PathConstraintMixTimeline):Void { + private function writePathConstraintMixTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -426,40 +405,33 @@ class SkeletonSerializer { json.writeValue("PathConstraintMixTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePathConstraintPositionTimeline(obj:PathConstraintPositionTimeline):Void { + private function writePathConstraintPositionTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -469,40 +441,33 @@ class SkeletonSerializer { json.writeValue("PathConstraintPositionTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePathConstraintSpacingTimeline(obj:PathConstraintSpacingTimeline):Void { + private function writePathConstraintSpacingTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -512,40 +477,33 @@ class SkeletonSerializer { json.writeValue("PathConstraintSpacingTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintDampingTimeline(obj:PhysicsConstraintDampingTimeline):Void { + private function writePhysicsConstraintDampingTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -555,40 +513,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintDampingTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintGravityTimeline(obj:PhysicsConstraintGravityTimeline):Void { + private function writePhysicsConstraintGravityTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -598,40 +549,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintGravityTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintInertiaTimeline(obj:PhysicsConstraintInertiaTimeline):Void { + private function writePhysicsConstraintInertiaTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -641,40 +585,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintInertiaTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintMassTimeline(obj:PhysicsConstraintMassTimeline):Void { + private function writePhysicsConstraintMassTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -684,40 +621,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintMassTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintMixTimeline(obj:PhysicsConstraintMixTimeline):Void { + private function writePhysicsConstraintMixTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -727,40 +657,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintMixTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintResetTimeline(obj:PhysicsConstraintResetTimeline):Void { + private function writePhysicsConstraintResetTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -770,40 +693,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintResetTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintStrengthTimeline(obj:PhysicsConstraintStrengthTimeline):Void { + private function writePhysicsConstraintStrengthTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -813,40 +729,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintStrengthTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintWindTimeline(obj:PhysicsConstraintWindTimeline):Void { + private function writePhysicsConstraintWindTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -856,40 +765,33 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintWindTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeRGB2Timeline(obj:RGB2Timeline):Void { + private function writeRGB2Timeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -899,40 +801,33 @@ class SkeletonSerializer { json.writeValue("RGB2Timeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeRGBA2Timeline(obj:RGBA2Timeline):Void { + private function writeRGBA2Timeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -942,40 +837,33 @@ class SkeletonSerializer { json.writeValue("RGBA2Timeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeRGBATimeline(obj:RGBATimeline):Void { + private function writeRGBATimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -985,40 +873,33 @@ class SkeletonSerializer { json.writeValue("RGBATimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeRGBTimeline(obj:RGBTimeline):Void { + private function writeRGBTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1028,40 +909,33 @@ class SkeletonSerializer { json.writeValue("RGBTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeRotateTimeline(obj:RotateTimeline):Void { + private function writeRotateTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1071,40 +945,33 @@ class SkeletonSerializer { json.writeValue("RotateTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeScaleTimeline(obj:ScaleTimeline):Void { + private function writeScaleTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1114,40 +981,33 @@ class SkeletonSerializer { json.writeValue("ScaleTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeScaleXTimeline(obj:ScaleXTimeline):Void { + private function writeScaleXTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1157,40 +1017,33 @@ class SkeletonSerializer { json.writeValue("ScaleXTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeScaleYTimeline(obj:ScaleYTimeline):Void { + private function writeScaleYTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1200,40 +1053,33 @@ class SkeletonSerializer { json.writeValue("ScaleYTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeSequenceTimeline(obj:SequenceTimeline):Void { + private function writeSequenceTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1243,43 +1089,36 @@ class SkeletonSerializer { json.writeValue("SequenceTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("slotIndex"); - json.writeValue(obj.getSlotIndex()); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); json.writeName("attachment"); - writeAttachment(obj.attachment); + writeProperty(obj, "getAttachment()", {"kind":"object","name":"attachment","getter":"getAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeShearTimeline(obj:ShearTimeline):Void { + private function writeShearTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1289,40 +1128,33 @@ class SkeletonSerializer { json.writeValue("ShearTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeShearXTimeline(obj:ShearXTimeline):Void { + private function writeShearXTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1332,40 +1164,33 @@ class SkeletonSerializer { json.writeValue("ShearXTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeShearYTimeline(obj:ShearYTimeline):Void { + private function writeShearYTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1375,40 +1200,33 @@ class SkeletonSerializer { json.writeValue("ShearYTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeSliderMixTimeline(obj:SliderMixTimeline):Void { + private function writeSliderMixTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1418,40 +1236,33 @@ class SkeletonSerializer { json.writeValue("SliderMixTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeSliderTimeline(obj:SliderTimeline):Void { + private function writeSliderTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1461,118 +1272,111 @@ class SkeletonSerializer { json.writeValue("SliderTimeline"); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeTimeline(obj:Timeline):Void { + private function writeTimeline(obj:Dynamic):Void { if (Std.isOfType(obj, AlphaTimeline)) { - writeAlphaTimeline(cast(obj, AlphaTimeline)); + writeAlphaTimeline(obj); } else if (Std.isOfType(obj, AttachmentTimeline)) { - writeAttachmentTimeline(cast(obj, AttachmentTimeline)); + writeAttachmentTimeline(obj); } else if (Std.isOfType(obj, DeformTimeline)) { - writeDeformTimeline(cast(obj, DeformTimeline)); + writeDeformTimeline(obj); } else if (Std.isOfType(obj, DrawOrderTimeline)) { - writeDrawOrderTimeline(cast(obj, DrawOrderTimeline)); + writeDrawOrderTimeline(obj); } else if (Std.isOfType(obj, EventTimeline)) { - writeEventTimeline(cast(obj, EventTimeline)); + writeEventTimeline(obj); } else if (Std.isOfType(obj, IkConstraintTimeline)) { - writeIkConstraintTimeline(cast(obj, IkConstraintTimeline)); + writeIkConstraintTimeline(obj); } else if (Std.isOfType(obj, InheritTimeline)) { - writeInheritTimeline(cast(obj, InheritTimeline)); + writeInheritTimeline(obj); } else if (Std.isOfType(obj, PathConstraintMixTimeline)) { - writePathConstraintMixTimeline(cast(obj, PathConstraintMixTimeline)); + writePathConstraintMixTimeline(obj); } else if (Std.isOfType(obj, PathConstraintPositionTimeline)) { - writePathConstraintPositionTimeline(cast(obj, PathConstraintPositionTimeline)); + writePathConstraintPositionTimeline(obj); } else if (Std.isOfType(obj, PathConstraintSpacingTimeline)) { - writePathConstraintSpacingTimeline(cast(obj, PathConstraintSpacingTimeline)); + writePathConstraintSpacingTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintDampingTimeline)) { - writePhysicsConstraintDampingTimeline(cast(obj, PhysicsConstraintDampingTimeline)); + writePhysicsConstraintDampingTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintGravityTimeline)) { - writePhysicsConstraintGravityTimeline(cast(obj, PhysicsConstraintGravityTimeline)); + writePhysicsConstraintGravityTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintInertiaTimeline)) { - writePhysicsConstraintInertiaTimeline(cast(obj, PhysicsConstraintInertiaTimeline)); + writePhysicsConstraintInertiaTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintMassTimeline)) { - writePhysicsConstraintMassTimeline(cast(obj, PhysicsConstraintMassTimeline)); + writePhysicsConstraintMassTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintMixTimeline)) { - writePhysicsConstraintMixTimeline(cast(obj, PhysicsConstraintMixTimeline)); + writePhysicsConstraintMixTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintResetTimeline)) { - writePhysicsConstraintResetTimeline(cast(obj, PhysicsConstraintResetTimeline)); + writePhysicsConstraintResetTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintStrengthTimeline)) { - writePhysicsConstraintStrengthTimeline(cast(obj, PhysicsConstraintStrengthTimeline)); + writePhysicsConstraintStrengthTimeline(obj); } else if (Std.isOfType(obj, PhysicsConstraintWindTimeline)) { - writePhysicsConstraintWindTimeline(cast(obj, PhysicsConstraintWindTimeline)); + writePhysicsConstraintWindTimeline(obj); } else if (Std.isOfType(obj, RGB2Timeline)) { - writeRGB2Timeline(cast(obj, RGB2Timeline)); + writeRGB2Timeline(obj); } else if (Std.isOfType(obj, RGBA2Timeline)) { - writeRGBA2Timeline(cast(obj, RGBA2Timeline)); + writeRGBA2Timeline(obj); } else if (Std.isOfType(obj, RGBATimeline)) { - writeRGBATimeline(cast(obj, RGBATimeline)); + writeRGBATimeline(obj); } else if (Std.isOfType(obj, RGBTimeline)) { - writeRGBTimeline(cast(obj, RGBTimeline)); + writeRGBTimeline(obj); } else if (Std.isOfType(obj, RotateTimeline)) { - writeRotateTimeline(cast(obj, RotateTimeline)); + writeRotateTimeline(obj); } else if (Std.isOfType(obj, ScaleTimeline)) { - writeScaleTimeline(cast(obj, ScaleTimeline)); + writeScaleTimeline(obj); } else if (Std.isOfType(obj, ScaleXTimeline)) { - writeScaleXTimeline(cast(obj, ScaleXTimeline)); + writeScaleXTimeline(obj); } else if (Std.isOfType(obj, ScaleYTimeline)) { - writeScaleYTimeline(cast(obj, ScaleYTimeline)); + writeScaleYTimeline(obj); } else if (Std.isOfType(obj, SequenceTimeline)) { - writeSequenceTimeline(cast(obj, SequenceTimeline)); + writeSequenceTimeline(obj); } else if (Std.isOfType(obj, ShearTimeline)) { - writeShearTimeline(cast(obj, ShearTimeline)); + writeShearTimeline(obj); } else if (Std.isOfType(obj, ShearXTimeline)) { - writeShearXTimeline(cast(obj, ShearXTimeline)); + writeShearXTimeline(obj); } else if (Std.isOfType(obj, ShearYTimeline)) { - writeShearYTimeline(cast(obj, ShearYTimeline)); + writeShearYTimeline(obj); } else if (Std.isOfType(obj, SliderMixTimeline)) { - writeSliderMixTimeline(cast(obj, SliderMixTimeline)); + writeSliderMixTimeline(obj); } else if (Std.isOfType(obj, SliderTimeline)) { - writeSliderTimeline(cast(obj, SliderTimeline)); + writeSliderTimeline(obj); } else if (Std.isOfType(obj, TransformConstraintTimeline)) { - writeTransformConstraintTimeline(cast(obj, TransformConstraintTimeline)); + writeTransformConstraintTimeline(obj); } else if (Std.isOfType(obj, TranslateTimeline)) { - writeTranslateTimeline(cast(obj, TranslateTimeline)); + writeTranslateTimeline(obj); } else if (Std.isOfType(obj, TranslateXTimeline)) { - writeTranslateXTimeline(cast(obj, TranslateXTimeline)); + writeTranslateXTimeline(obj); } else if (Std.isOfType(obj, TranslateYTimeline)) { - writeTranslateYTimeline(cast(obj, TranslateYTimeline)); + writeTranslateYTimeline(obj); } else { throw new spine.SpineException("Unknown Timeline type"); } } - private function writeTransformConstraintTimeline(obj:TransformConstraintTimeline):Void { + private function writeTransformConstraintTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1582,40 +1386,33 @@ class SkeletonSerializer { json.writeValue("TransformConstraintTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("constraintIndex"); - json.writeValue(obj.constraintIndex); + writeProperty(obj, "getConstraintIndex()", {"kind":"primitive","name":"constraintIndex","getter":"getConstraintIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeTranslateTimeline(obj:TranslateTimeline):Void { + private function writeTranslateTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1625,40 +1422,33 @@ class SkeletonSerializer { json.writeValue("TranslateTimeline"); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeTranslateXTimeline(obj:TranslateXTimeline):Void { + private function writeTranslateXTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1668,40 +1458,33 @@ class SkeletonSerializer { json.writeValue("TranslateXTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeTranslateYTimeline(obj:TranslateYTimeline):Void { + private function writeTranslateYTimeline(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1711,40 +1494,33 @@ class SkeletonSerializer { json.writeValue("TranslateYTimeline"); json.writeName("boneIndex"); - json.writeValue(obj.getBoneIndex()); + writeProperty(obj, "getBoneIndex()", {"kind":"primitive","name":"boneIndex","getter":"getBoneIndex()","valueType":"int","isNullable":false}); json.writeName("frameEntries"); - json.writeValue(obj.getFrameEntries()); + writeProperty(obj, "getFrameEntries()", {"kind":"primitive","name":"frameEntries","getter":"getFrameEntries()","valueType":"int","isNullable":false}); json.writeName("propertyIds"); - json.writeArrayStart(); - for (item in obj.propertyIds) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPropertyIds()", {"kind":"array","name":"propertyIds","getter":"getPropertyIds()","elementType":"String","elementKind":"primitive","isNullable":false}); json.writeName("frames"); - json.writeArrayStart(); - for (item in obj.frames) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getFrames()", {"kind":"array","name":"frames","getter":"getFrames()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("frameCount"); - json.writeValue(obj.getFrameCount()); + writeProperty(obj, "getFrameCount()", {"kind":"primitive","name":"frameCount","getter":"getFrameCount()","valueType":"int","isNullable":false}); json.writeName("duration"); - json.writeValue(obj.getDuration()); + writeProperty(obj, "getDuration()", {"kind":"primitive","name":"duration","getter":"getDuration()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeAnimationState(obj:AnimationState):Void { + private function writeAnimationState(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1754,27 +1530,24 @@ class SkeletonSerializer { json.writeValue("AnimationState"); json.writeName("timeScale"); - json.writeValue(obj.timeScale); + writeProperty(obj, "getTimeScale()", {"kind":"primitive","name":"timeScale","getter":"getTimeScale()","valueType":"float","isNullable":false}); json.writeName("data"); - writeAnimationStateData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"AnimationStateData","writeMethodCall":"writeAnimationStateData","isNullable":false}); json.writeName("tracks"); - json.writeArrayStart(); - for (item in obj.tracks) { - writeTrackEntry(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getTracks()", {"kind":"array","name":"tracks","getter":"getTracks()","elementType":"TrackEntry","elementKind":"object","writeMethodCall":"writeTrackEntry","isNullable":false}); json.writeObjectEnd(); } - private function writeTrackEntry(obj:TrackEntry):Void { + private function writeTrackEntry(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1784,117 +1557,96 @@ class SkeletonSerializer { json.writeValue("TrackEntry"); json.writeName("trackIndex"); - json.writeValue(obj.trackIndex); + writeProperty(obj, "getTrackIndex()", {"kind":"primitive","name":"trackIndex","getter":"getTrackIndex()","valueType":"int","isNullable":false}); json.writeName("animation"); - writeAnimation(obj.animation); + writeProperty(obj, "getAnimation()", {"kind":"object","name":"animation","getter":"getAnimation()","valueType":"Animation","writeMethodCall":"writeAnimation","isNullable":false}); json.writeName("loop"); - json.writeValue(obj.loop); + writeProperty(obj, "getLoop()", {"kind":"primitive","name":"loop","getter":"getLoop()","valueType":"boolean","isNullable":false}); json.writeName("delay"); - json.writeValue(obj.delay); + writeProperty(obj, "getDelay()", {"kind":"primitive","name":"delay","getter":"getDelay()","valueType":"float","isNullable":false}); json.writeName("trackTime"); - json.writeValue(obj.trackTime); + writeProperty(obj, "getTrackTime()", {"kind":"primitive","name":"trackTime","getter":"getTrackTime()","valueType":"float","isNullable":false}); json.writeName("trackEnd"); - json.writeValue(obj.trackEnd); + writeProperty(obj, "getTrackEnd()", {"kind":"primitive","name":"trackEnd","getter":"getTrackEnd()","valueType":"float","isNullable":false}); json.writeName("trackComplete"); - json.writeValue(obj.getTrackComplete()); + writeProperty(obj, "getTrackComplete()", {"kind":"primitive","name":"trackComplete","getter":"getTrackComplete()","valueType":"float","isNullable":false}); json.writeName("animationStart"); - json.writeValue(obj.animationStart); + writeProperty(obj, "getAnimationStart()", {"kind":"primitive","name":"animationStart","getter":"getAnimationStart()","valueType":"float","isNullable":false}); json.writeName("animationEnd"); - json.writeValue(obj.animationEnd); + writeProperty(obj, "getAnimationEnd()", {"kind":"primitive","name":"animationEnd","getter":"getAnimationEnd()","valueType":"float","isNullable":false}); json.writeName("animationLast"); - json.writeValue(obj.animationLast); + writeProperty(obj, "getAnimationLast()", {"kind":"primitive","name":"animationLast","getter":"getAnimationLast()","valueType":"float","isNullable":false}); json.writeName("animationTime"); - json.writeValue(obj.getAnimationTime()); + writeProperty(obj, "getAnimationTime()", {"kind":"primitive","name":"animationTime","getter":"getAnimationTime()","valueType":"float","isNullable":false}); json.writeName("timeScale"); - json.writeValue(obj.timeScale); + writeProperty(obj, "getTimeScale()", {"kind":"primitive","name":"timeScale","getter":"getTimeScale()","valueType":"float","isNullable":false}); json.writeName("alpha"); - json.writeValue(obj.alpha); + writeProperty(obj, "getAlpha()", {"kind":"primitive","name":"alpha","getter":"getAlpha()","valueType":"float","isNullable":false}); json.writeName("eventThreshold"); - json.writeValue(obj.eventThreshold); + writeProperty(obj, "getEventThreshold()", {"kind":"primitive","name":"eventThreshold","getter":"getEventThreshold()","valueType":"float","isNullable":false}); json.writeName("alphaAttachmentThreshold"); - json.writeValue(obj.alphaAttachmentThreshold); + writeProperty(obj, "getAlphaAttachmentThreshold()", {"kind":"primitive","name":"alphaAttachmentThreshold","getter":"getAlphaAttachmentThreshold()","valueType":"float","isNullable":false}); json.writeName("mixAttachmentThreshold"); - json.writeValue(obj.mixAttachmentThreshold); + writeProperty(obj, "getMixAttachmentThreshold()", {"kind":"primitive","name":"mixAttachmentThreshold","getter":"getMixAttachmentThreshold()","valueType":"float","isNullable":false}); json.writeName("mixDrawOrderThreshold"); - json.writeValue(obj.mixDrawOrderThreshold); + writeProperty(obj, "getMixDrawOrderThreshold()", {"kind":"primitive","name":"mixDrawOrderThreshold","getter":"getMixDrawOrderThreshold()","valueType":"float","isNullable":false}); json.writeName("next"); - if (obj.next == null) { - json.writeNull(); - } else { - writeTrackEntry(obj.next); - } + writeProperty(obj, "getNext()", {"kind":"object","name":"next","getter":"getNext()","valueType":"AnimationState.TrackEntry","writeMethodCall":"writeTrackEntry","isNullable":true}); json.writeName("previous"); - if (obj.previous == null) { - json.writeNull(); - } else { - writeTrackEntry(obj.previous); - } + writeProperty(obj, "getPrevious()", {"kind":"object","name":"previous","getter":"getPrevious()","valueType":"AnimationState.TrackEntry","writeMethodCall":"writeTrackEntry","isNullable":true}); json.writeName("mixTime"); - json.writeValue(obj.mixTime); + writeProperty(obj, "getMixTime()", {"kind":"primitive","name":"mixTime","getter":"getMixTime()","valueType":"float","isNullable":false}); json.writeName("mixDuration"); - json.writeValue(obj.mixDuration); + writeProperty(obj, "getMixDuration()", {"kind":"primitive","name":"mixDuration","getter":"getMixDuration()","valueType":"float","isNullable":false}); json.writeName("mixBlend"); - switch (obj.mixBlend) { - case MixBlend.setup: json.writeValue("setup"); - case MixBlend.first: json.writeValue("first"); - case MixBlend.replace: json.writeValue("replace"); - case MixBlend.add: json.writeValue("add"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getMixBlend()", {"kind":"enum","name":"mixBlend","getter":"getMixBlend()","enumName":"MixBlend","isNullable":false}); json.writeName("mixingFrom"); - if (obj.mixingFrom == null) { - json.writeNull(); - } else { - writeTrackEntry(obj.mixingFrom); - } + writeProperty(obj, "getMixingFrom()", {"kind":"object","name":"mixingFrom","getter":"getMixingFrom()","valueType":"AnimationState.TrackEntry","writeMethodCall":"writeTrackEntry","isNullable":true}); json.writeName("mixingTo"); - if (obj.mixingTo == null) { - json.writeNull(); - } else { - writeTrackEntry(obj.mixingTo); - } + writeProperty(obj, "getMixingTo()", {"kind":"object","name":"mixingTo","getter":"getMixingTo()","valueType":"AnimationState.TrackEntry","writeMethodCall":"writeTrackEntry","isNullable":true}); json.writeName("holdPrevious"); - json.writeValue(obj.holdPrevious); + writeProperty(obj, "getHoldPrevious()", {"kind":"primitive","name":"holdPrevious","getter":"getHoldPrevious()","valueType":"boolean","isNullable":false}); json.writeName("shortestRotation"); - json.writeValue(obj.shortestRotation); + writeProperty(obj, "getShortestRotation()", {"kind":"primitive","name":"shortestRotation","getter":"getShortestRotation()","valueType":"boolean","isNullable":false}); json.writeName("reverse"); - json.writeValue(obj.reverse); + writeProperty(obj, "getReverse()", {"kind":"primitive","name":"reverse","getter":"getReverse()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeAnimationStateData(obj:AnimationStateData):Void { + private function writeAnimationStateData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1904,38 +1656,39 @@ class SkeletonSerializer { json.writeValue("AnimationStateData"); json.writeName("skeletonData"); - writeSkeletonData(obj.skeletonData); + writeProperty(obj, "getSkeletonData()", {"kind":"object","name":"skeletonData","getter":"getSkeletonData()","valueType":"SkeletonData","writeMethodCall":"writeSkeletonData","isNullable":false}); json.writeName("defaultMix"); - json.writeValue(obj.defaultMix); + writeProperty(obj, "getDefaultMix()", {"kind":"primitive","name":"defaultMix","getter":"getDefaultMix()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeAttachment(obj:Attachment):Void { + private function writeAttachment(obj:Dynamic):Void { if (Std.isOfType(obj, BoundingBoxAttachment)) { - writeBoundingBoxAttachment(cast(obj, BoundingBoxAttachment)); + writeBoundingBoxAttachment(obj); } else if (Std.isOfType(obj, ClippingAttachment)) { - writeClippingAttachment(cast(obj, ClippingAttachment)); + writeClippingAttachment(obj); } else if (Std.isOfType(obj, MeshAttachment)) { - writeMeshAttachment(cast(obj, MeshAttachment)); + writeMeshAttachment(obj); } else if (Std.isOfType(obj, PathAttachment)) { - writePathAttachment(cast(obj, PathAttachment)); + writePathAttachment(obj); } else if (Std.isOfType(obj, PointAttachment)) { - writePointAttachment(cast(obj, PointAttachment)); + writePointAttachment(obj); } else if (Std.isOfType(obj, RegionAttachment)) { - writeRegionAttachment(cast(obj, RegionAttachment)); + writeRegionAttachment(obj); } else { throw new spine.SpineException("Unknown Attachment type"); } } - private function writeBone(obj:Bone):Void { + private function writeBone(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1945,37 +1698,31 @@ class SkeletonSerializer { json.writeValue("Bone"); json.writeName("parent"); - if (obj.parent == null) { - json.writeNull(); - } else { - writeBone(obj.parent); - } + writeProperty(obj, "getParent()", {"kind":"object","name":"parent","getter":"getParent()","valueType":"Bone","writeMethodCall":"writeBone","isNullable":true}); json.writeName("children"); - json.writeArrayStart(); - for (item in obj.children) { - writeBone(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getChildren()", {"kind":"array","name":"children","getter":"getChildren()","elementType":"Bone","elementKind":"object","writeMethodCall":"writeBone","isNullable":false}); json.writeName("data"); - writeBoneData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("pose"); - writeBoneLocal(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"BoneLocal","writeMethodCall":"writeBoneLocal","isNullable":false}); json.writeName("appliedPose"); - writeBonePose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"BonePose","writeMethodCall":"writeBonePose","isNullable":false}); json.writeObjectEnd(); } - private function writeBoneData(obj:BoneData):Void { + private function writeBoneData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -1985,45 +1732,42 @@ class SkeletonSerializer { json.writeValue("BoneData"); json.writeName("index"); - json.writeValue(obj.index); + writeProperty(obj, "getIndex()", {"kind":"primitive","name":"index","getter":"getIndex()","valueType":"int","isNullable":false}); json.writeName("parent"); - if (obj.parent == null) { - json.writeNull(); - } else { - writeBoneData(obj.parent); - } + writeProperty(obj, "getParent()", {"kind":"object","name":"parent","getter":"getParent()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":true}); json.writeName("length"); - json.writeValue(obj.length); + writeProperty(obj, "getLength()", {"kind":"primitive","name":"length","getter":"getLength()","valueType":"float","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("icon"); - json.writeValue(obj.icon); + writeProperty(obj, "getIcon()", {"kind":"primitive","name":"icon","getter":"getIcon()","valueType":"String","isNullable":true}); json.writeName("visible"); - json.writeValue(obj.visible); + writeProperty(obj, "getVisible()", {"kind":"primitive","name":"visible","getter":"getVisible()","valueType":"boolean","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writeBoneLocal(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"BoneLocal","writeMethodCall":"writeBoneLocal","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeBoneLocal(obj:BoneLocal):Void { + private function writeBoneLocal(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2033,45 +1777,39 @@ class SkeletonSerializer { json.writeValue("BoneLocal"); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("rotation"); - json.writeValue(obj.rotation); + writeProperty(obj, "getRotation()", {"kind":"primitive","name":"rotation","getter":"getRotation()","valueType":"float","isNullable":false}); json.writeName("scaleX"); - json.writeValue(obj.scaleX); + writeProperty(obj, "getScaleX()", {"kind":"primitive","name":"scaleX","getter":"getScaleX()","valueType":"float","isNullable":false}); json.writeName("scaleY"); - json.writeValue(obj.scaleY); + writeProperty(obj, "getScaleY()", {"kind":"primitive","name":"scaleY","getter":"getScaleY()","valueType":"float","isNullable":false}); json.writeName("shearX"); - json.writeValue(obj.shearX); + writeProperty(obj, "getShearX()", {"kind":"primitive","name":"shearX","getter":"getShearX()","valueType":"float","isNullable":false}); json.writeName("shearY"); - json.writeValue(obj.shearY); + writeProperty(obj, "getShearY()", {"kind":"primitive","name":"shearY","getter":"getShearY()","valueType":"float","isNullable":false}); json.writeName("inherit"); - switch (obj.inherit) { - case Inherit.normal: json.writeValue("normal"); - case Inherit.onlyTranslation: json.writeValue("onlyTranslation"); - case Inherit.noRotationOrReflection: json.writeValue("noRotationOrReflection"); - case Inherit.noScale: json.writeValue("noScale"); - case Inherit.noScaleOrReflection: json.writeValue("noScaleOrReflection"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getInherit()", {"kind":"enum","name":"inherit","getter":"getInherit()","enumName":"Inherit","isNullable":false}); json.writeObjectEnd(); } - private function writeBonePose(obj:BonePose):Void { + private function writeBonePose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2081,75 +1819,70 @@ class SkeletonSerializer { json.writeValue("BonePose"); json.writeName("a"); - json.writeValue(obj.a); + writeProperty(obj, "getA()", {"kind":"primitive","name":"a","getter":"getA()","valueType":"float","isNullable":false}); json.writeName("b"); - json.writeValue(obj.b); + writeProperty(obj, "getB()", {"kind":"primitive","name":"b","getter":"getB()","valueType":"float","isNullable":false}); json.writeName("c"); - json.writeValue(obj.c); + writeProperty(obj, "getC()", {"kind":"primitive","name":"c","getter":"getC()","valueType":"float","isNullable":false}); json.writeName("d"); - json.writeValue(obj.d); + writeProperty(obj, "getD()", {"kind":"primitive","name":"d","getter":"getD()","valueType":"float","isNullable":false}); json.writeName("worldX"); - json.writeValue(obj.worldX); + writeProperty(obj, "getWorldX()", {"kind":"primitive","name":"worldX","getter":"getWorldX()","valueType":"float","isNullable":false}); json.writeName("worldY"); - json.writeValue(obj.worldY); + writeProperty(obj, "getWorldY()", {"kind":"primitive","name":"worldY","getter":"getWorldY()","valueType":"float","isNullable":false}); json.writeName("worldRotationX"); - json.writeValue(obj.worldRotationX); + writeProperty(obj, "getWorldRotationX()", {"kind":"primitive","name":"worldRotationX","getter":"getWorldRotationX()","valueType":"float","isNullable":false}); json.writeName("worldRotationY"); - json.writeValue(obj.worldRotationY); + writeProperty(obj, "getWorldRotationY()", {"kind":"primitive","name":"worldRotationY","getter":"getWorldRotationY()","valueType":"float","isNullable":false}); json.writeName("worldScaleX"); - json.writeValue(obj.worldScaleX); + writeProperty(obj, "getWorldScaleX()", {"kind":"primitive","name":"worldScaleX","getter":"getWorldScaleX()","valueType":"float","isNullable":false}); json.writeName("worldScaleY"); - json.writeValue(obj.worldScaleY); + writeProperty(obj, "getWorldScaleY()", {"kind":"primitive","name":"worldScaleY","getter":"getWorldScaleY()","valueType":"float","isNullable":false}); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("rotation"); - json.writeValue(obj.rotation); + writeProperty(obj, "getRotation()", {"kind":"primitive","name":"rotation","getter":"getRotation()","valueType":"float","isNullable":false}); json.writeName("scaleX"); - json.writeValue(obj.scaleX); + writeProperty(obj, "getScaleX()", {"kind":"primitive","name":"scaleX","getter":"getScaleX()","valueType":"float","isNullable":false}); json.writeName("scaleY"); - json.writeValue(obj.scaleY); + writeProperty(obj, "getScaleY()", {"kind":"primitive","name":"scaleY","getter":"getScaleY()","valueType":"float","isNullable":false}); json.writeName("shearX"); - json.writeValue(obj.shearX); + writeProperty(obj, "getShearX()", {"kind":"primitive","name":"shearX","getter":"getShearX()","valueType":"float","isNullable":false}); json.writeName("shearY"); - json.writeValue(obj.shearY); + writeProperty(obj, "getShearY()", {"kind":"primitive","name":"shearY","getter":"getShearY()","valueType":"float","isNullable":false}); json.writeName("inherit"); - switch (obj.inherit) { - case Inherit.normal: json.writeValue("normal"); - case Inherit.onlyTranslation: json.writeValue("onlyTranslation"); - case Inherit.noRotationOrReflection: json.writeValue("noRotationOrReflection"); - case Inherit.noScale: json.writeValue("noScale"); - case Inherit.noScaleOrReflection: json.writeValue("noScaleOrReflection"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getInherit()", {"kind":"enum","name":"inherit","getter":"getInherit()","enumName":"Inherit","isNullable":false}); json.writeObjectEnd(); } - private function writeBoundingBoxAttachment(obj:BoundingBoxAttachment):Void { + private function writeBoundingBoxAttachment(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2159,51 +1892,37 @@ class SkeletonSerializer { json.writeValue("BoundingBoxAttachment"); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("bones"); - if (obj.bones == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (item in obj.bones) { - json.writeValue(item); - } - json.writeArrayEnd(); - } + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"int","elementKind":"primitive","isNullable":true}); json.writeName("vertices"); - json.writeArrayStart(); - for (item in obj.vertices) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getVertices()", {"kind":"array","name":"vertices","getter":"getVertices()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("worldVerticesLength"); - json.writeValue(obj.worldVerticesLength); + writeProperty(obj, "getWorldVerticesLength()", {"kind":"primitive","name":"worldVerticesLength","getter":"getWorldVerticesLength()","valueType":"int","isNullable":false}); json.writeName("timelineAttachment"); - if (obj.timelineAttachment == null) { - json.writeNull(); - } else { - writeAttachment(obj.timelineAttachment); - } + writeProperty(obj, "getTimelineAttachment()", {"kind":"object","name":"timelineAttachment","getter":"getTimelineAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":true}); json.writeName("id"); - json.writeValue(obj.id); + writeProperty(obj, "getId()", {"kind":"primitive","name":"id","getter":"getId()","valueType":"int","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writeClippingAttachment(obj:ClippingAttachment):Void { + private function writeClippingAttachment(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2213,90 +1932,71 @@ class SkeletonSerializer { json.writeValue("ClippingAttachment"); json.writeName("endSlot"); - if (obj.endSlot == null) { - json.writeNull(); - } else { - writeSlotData(obj.endSlot); - } + writeProperty(obj, "getEndSlot()", {"kind":"object","name":"endSlot","getter":"getEndSlot()","valueType":"SlotData","writeMethodCall":"writeSlotData","isNullable":true}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("bones"); - if (obj.bones == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (item in obj.bones) { - json.writeValue(item); - } - json.writeArrayEnd(); - } + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"int","elementKind":"primitive","isNullable":true}); json.writeName("vertices"); - json.writeArrayStart(); - for (item in obj.vertices) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getVertices()", {"kind":"array","name":"vertices","getter":"getVertices()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("worldVerticesLength"); - json.writeValue(obj.worldVerticesLength); + writeProperty(obj, "getWorldVerticesLength()", {"kind":"primitive","name":"worldVerticesLength","getter":"getWorldVerticesLength()","valueType":"int","isNullable":false}); json.writeName("timelineAttachment"); - if (obj.timelineAttachment == null) { - json.writeNull(); - } else { - writeAttachment(obj.timelineAttachment); - } + writeProperty(obj, "getTimelineAttachment()", {"kind":"object","name":"timelineAttachment","getter":"getTimelineAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":true}); json.writeName("id"); - json.writeValue(obj.id); + writeProperty(obj, "getId()", {"kind":"primitive","name":"id","getter":"getId()","valueType":"int","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writeConstraint(obj:Constraint):Void { + private function writeConstraint(obj:Dynamic):Void { if (Std.isOfType(obj, IkConstraint)) { - writeIkConstraint(cast(obj, IkConstraint)); + writeIkConstraint(obj); } else if (Std.isOfType(obj, PathConstraint)) { - writePathConstraint(cast(obj, PathConstraint)); + writePathConstraint(obj); } else if (Std.isOfType(obj, PhysicsConstraint)) { - writePhysicsConstraint(cast(obj, PhysicsConstraint)); + writePhysicsConstraint(obj); } else if (Std.isOfType(obj, Slider)) { - writeSlider(cast(obj, Slider)); + writeSlider(obj); } else if (Std.isOfType(obj, TransformConstraint)) { - writeTransformConstraint(cast(obj, TransformConstraint)); + writeTransformConstraint(obj); } else { throw new spine.SpineException("Unknown Constraint type"); } } - private function writeConstraintData(obj:ConstraintData):Void { + private function writeConstraintData(obj:Dynamic):Void { if (Std.isOfType(obj, IkConstraintData)) { - writeIkConstraintData(cast(obj, IkConstraintData)); + writeIkConstraintData(obj); } else if (Std.isOfType(obj, PathConstraintData)) { - writePathConstraintData(cast(obj, PathConstraintData)); + writePathConstraintData(obj); } else if (Std.isOfType(obj, PhysicsConstraintData)) { - writePhysicsConstraintData(cast(obj, PhysicsConstraintData)); + writePhysicsConstraintData(obj); } else if (Std.isOfType(obj, SliderData)) { - writeSliderData(cast(obj, SliderData)); + writeSliderData(obj); } else if (Std.isOfType(obj, TransformConstraintData)) { - writeTransformConstraintData(cast(obj, TransformConstraintData)); + writeTransformConstraintData(obj); } else { throw new spine.SpineException("Unknown ConstraintData type"); } } - private function writeEvent(obj:Event):Void { + private function writeEvent(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2306,35 +2006,37 @@ class SkeletonSerializer { json.writeValue("Event"); json.writeName("int"); - json.writeValue(obj.intValue); + writeProperty(obj, "getInt()", {"kind":"primitive","name":"int","getter":"getInt()","valueType":"int","isNullable":false}); json.writeName("float"); - json.writeValue(obj.floatValue); + writeProperty(obj, "getFloat()", {"kind":"primitive","name":"float","getter":"getFloat()","valueType":"float","isNullable":false}); json.writeName("string"); - json.writeValue(obj.stringValue); + writeProperty(obj, "getString()", {"kind":"primitive","name":"string","getter":"getString()","valueType":"String","isNullable":false}); json.writeName("volume"); - json.writeValue(obj.volume); + writeProperty(obj, "getVolume()", {"kind":"primitive","name":"volume","getter":"getVolume()","valueType":"float","isNullable":false}); json.writeName("balance"); - json.writeValue(obj.balance); + writeProperty(obj, "getBalance()", {"kind":"primitive","name":"balance","getter":"getBalance()","valueType":"float","isNullable":false}); json.writeName("time"); - json.writeValue(obj.time); + writeProperty(obj, "getTime()", {"kind":"primitive","name":"time","getter":"getTime()","valueType":"float","isNullable":false}); json.writeName("data"); - writeEventData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"EventData","writeMethodCall":"writeEventData","isNullable":false}); json.writeObjectEnd(); } - private function writeEventData(obj:EventData):Void { + private function writeEventData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2344,35 +2046,36 @@ class SkeletonSerializer { json.writeValue("EventData"); json.writeName("int"); - json.writeValue(obj.intValue); + writeProperty(obj, "getInt()", {"kind":"primitive","name":"int","getter":"getInt()","valueType":"int","isNullable":false}); json.writeName("float"); - json.writeValue(obj.floatValue); + writeProperty(obj, "getFloat()", {"kind":"primitive","name":"float","getter":"getFloat()","valueType":"float","isNullable":false}); json.writeName("string"); - json.writeValue(obj.stringValue); + writeProperty(obj, "getString()", {"kind":"primitive","name":"string","getter":"getString()","valueType":"String","isNullable":false}); json.writeName("audioPath"); - json.writeValue(obj.audioPath); + writeProperty(obj, "getAudioPath()", {"kind":"primitive","name":"audioPath","getter":"getAudioPath()","valueType":"String","isNullable":false}); json.writeName("volume"); - json.writeValue(obj.volume); + writeProperty(obj, "getVolume()", {"kind":"primitive","name":"volume","getter":"getVolume()","valueType":"float","isNullable":false}); json.writeName("balance"); - json.writeValue(obj.balance); + writeProperty(obj, "getBalance()", {"kind":"primitive","name":"balance","getter":"getBalance()","valueType":"float","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writeIkConstraint(obj:IkConstraint):Void { + private function writeIkConstraint(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2382,33 +2085,31 @@ class SkeletonSerializer { json.writeValue("IkConstraint"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBonePose(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BonePose","elementKind":"object","writeMethodCall":"writeBonePose","isNullable":false}); json.writeName("target"); - writeBone(obj.target); + writeProperty(obj, "getTarget()", {"kind":"object","name":"target","getter":"getTarget()","valueType":"Bone","writeMethodCall":"writeBone","isNullable":false}); json.writeName("data"); - writeIkConstraintData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"IkConstraintData","writeMethodCall":"writeIkConstraintData","isNullable":false}); json.writeName("pose"); - writeIkConstraintPose(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"IkConstraintPose","writeMethodCall":"writeIkConstraintPose","isNullable":false}); json.writeName("appliedPose"); - writeIkConstraintPose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"IkConstraintPose","writeMethodCall":"writeIkConstraintPose","isNullable":false}); json.writeObjectEnd(); } - private function writeIkConstraintData(obj:IkConstraintData):Void { + private function writeIkConstraintData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2418,36 +2119,33 @@ class SkeletonSerializer { json.writeValue("IkConstraintData"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBoneData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BoneData","elementKind":"object","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("target"); - writeBoneData(obj.target); + writeProperty(obj, "getTarget()", {"kind":"object","name":"target","getter":"getTarget()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("uniform"); - json.writeValue(obj.uniform); + writeProperty(obj, "getUniform()", {"kind":"primitive","name":"uniform","getter":"getUniform()","valueType":"boolean","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writeIkConstraintPose(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"IkConstraintPose","writeMethodCall":"writeIkConstraintPose","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeIkConstraintPose(obj:IkConstraintPose):Void { + private function writeIkConstraintPose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2457,29 +2155,31 @@ class SkeletonSerializer { json.writeValue("IkConstraintPose"); json.writeName("mix"); - json.writeValue(obj.mix); + writeProperty(obj, "getMix()", {"kind":"primitive","name":"mix","getter":"getMix()","valueType":"float","isNullable":false}); json.writeName("softness"); - json.writeValue(obj.softness); + writeProperty(obj, "getSoftness()", {"kind":"primitive","name":"softness","getter":"getSoftness()","valueType":"float","isNullable":false}); json.writeName("bendDirection"); - json.writeValue(obj.bendDirection); + writeProperty(obj, "getBendDirection()", {"kind":"primitive","name":"bendDirection","getter":"getBendDirection()","valueType":"int","isNullable":false}); json.writeName("compress"); - json.writeValue(obj.compress); + writeProperty(obj, "getCompress()", {"kind":"primitive","name":"compress","getter":"getCompress()","valueType":"boolean","isNullable":false}); json.writeName("stretch"); - json.writeValue(obj.stretch); + writeProperty(obj, "getStretch()", {"kind":"primitive","name":"stretch","getter":"getStretch()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeMeshAttachment(obj:MeshAttachment):Void { + private function writeMeshAttachment(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2489,116 +2189,70 @@ class SkeletonSerializer { json.writeValue("MeshAttachment"); json.writeName("region"); - if (obj.region == null) { - json.writeNull(); - } else { - writeTextureRegion(obj.region); - } + writeProperty(obj, "getRegion()", {"kind":"object","name":"region","getter":"getRegion()","valueType":"TextureRegion","writeMethodCall":"writeTextureRegion","isNullable":true}); json.writeName("triangles"); - json.writeArrayStart(); - for (item in obj.triangles) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getTriangles()", {"kind":"array","name":"triangles","getter":"getTriangles()","elementType":"short","elementKind":"primitive","isNullable":false}); json.writeName("regionUVs"); - json.writeArrayStart(); - for (item in obj.regionUVs) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getRegionUVs()", {"kind":"array","name":"regionUVs","getter":"getRegionUVs()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("uVs"); - json.writeArrayStart(); - for (item in obj.uvs) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getUVs()", {"kind":"array","name":"uVs","getter":"getUVs()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("path"); - json.writeValue(obj.path); + writeProperty(obj, "getPath()", {"kind":"primitive","name":"path","getter":"getPath()","valueType":"String","isNullable":false}); json.writeName("hullLength"); - json.writeValue(obj.hullLength); + writeProperty(obj, "getHullLength()", {"kind":"primitive","name":"hullLength","getter":"getHullLength()","valueType":"int","isNullable":false}); json.writeName("edges"); - if (obj.edges == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (item in obj.edges) { - json.writeValue(item); - } - json.writeArrayEnd(); - } + writeProperty(obj, "getEdges()", {"kind":"array","name":"edges","getter":"getEdges()","elementType":"short","elementKind":"primitive","isNullable":true}); json.writeName("width"); - json.writeValue(obj.width); + writeProperty(obj, "getWidth()", {"kind":"primitive","name":"width","getter":"getWidth()","valueType":"float","isNullable":false}); json.writeName("height"); - json.writeValue(obj.height); + writeProperty(obj, "getHeight()", {"kind":"primitive","name":"height","getter":"getHeight()","valueType":"float","isNullable":false}); json.writeName("sequence"); - if (obj.sequence == null) { - json.writeNull(); - } else { - writeSequence(obj.sequence); - } + writeProperty(obj, "getSequence()", {"kind":"object","name":"sequence","getter":"getSequence()","valueType":"Sequence","writeMethodCall":"writeSequence","isNullable":true}); json.writeName("parentMesh"); - if (obj.parentMesh == null) { - json.writeNull(); - } else { - writeMeshAttachment(obj.parentMesh); - } + writeProperty(obj, "getParentMesh()", {"kind":"object","name":"parentMesh","getter":"getParentMesh()","valueType":"MeshAttachment","writeMethodCall":"writeMeshAttachment","isNullable":true}); json.writeName("bones"); - if (obj.bones == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (item in obj.bones) { - json.writeValue(item); - } - json.writeArrayEnd(); - } + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"int","elementKind":"primitive","isNullable":true}); json.writeName("vertices"); - json.writeArrayStart(); - for (item in obj.vertices) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getVertices()", {"kind":"array","name":"vertices","getter":"getVertices()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("worldVerticesLength"); - json.writeValue(obj.worldVerticesLength); + writeProperty(obj, "getWorldVerticesLength()", {"kind":"primitive","name":"worldVerticesLength","getter":"getWorldVerticesLength()","valueType":"int","isNullable":false}); json.writeName("timelineAttachment"); - if (obj.timelineAttachment == null) { - json.writeNull(); - } else { - writeAttachment(obj.timelineAttachment); - } + writeProperty(obj, "getTimelineAttachment()", {"kind":"object","name":"timelineAttachment","getter":"getTimelineAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":true}); json.writeName("id"); - json.writeValue(obj.id); + writeProperty(obj, "getId()", {"kind":"primitive","name":"id","getter":"getId()","valueType":"int","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writePathAttachment(obj:PathAttachment):Void { + private function writePathAttachment(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2608,64 +2262,45 @@ class SkeletonSerializer { json.writeValue("PathAttachment"); json.writeName("closed"); - json.writeValue(obj.closed); + writeProperty(obj, "getClosed()", {"kind":"primitive","name":"closed","getter":"getClosed()","valueType":"boolean","isNullable":false}); json.writeName("constantSpeed"); - json.writeValue(obj.constantSpeed); + writeProperty(obj, "getConstantSpeed()", {"kind":"primitive","name":"constantSpeed","getter":"getConstantSpeed()","valueType":"boolean","isNullable":false}); json.writeName("lengths"); - json.writeArrayStart(); - for (item in obj.lengths) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getLengths()", {"kind":"array","name":"lengths","getter":"getLengths()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("bones"); - if (obj.bones == null) { - json.writeNull(); - } else { - json.writeArrayStart(); - for (item in obj.bones) { - json.writeValue(item); - } - json.writeArrayEnd(); - } + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"int","elementKind":"primitive","isNullable":true}); json.writeName("vertices"); - json.writeArrayStart(); - for (item in obj.vertices) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getVertices()", {"kind":"array","name":"vertices","getter":"getVertices()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("worldVerticesLength"); - json.writeValue(obj.worldVerticesLength); + writeProperty(obj, "getWorldVerticesLength()", {"kind":"primitive","name":"worldVerticesLength","getter":"getWorldVerticesLength()","valueType":"int","isNullable":false}); json.writeName("timelineAttachment"); - if (obj.timelineAttachment == null) { - json.writeNull(); - } else { - writeAttachment(obj.timelineAttachment); - } + writeProperty(obj, "getTimelineAttachment()", {"kind":"object","name":"timelineAttachment","getter":"getTimelineAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":true}); json.writeName("id"); - json.writeValue(obj.id); + writeProperty(obj, "getId()", {"kind":"primitive","name":"id","getter":"getId()","valueType":"int","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writePathConstraint(obj:PathConstraint):Void { + private function writePathConstraint(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2675,33 +2310,31 @@ class SkeletonSerializer { json.writeValue("PathConstraint"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBonePose(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BonePose","elementKind":"object","writeMethodCall":"writeBonePose","isNullable":false}); json.writeName("slot"); - writeSlot(obj.slot); + writeProperty(obj, "getSlot()", {"kind":"object","name":"slot","getter":"getSlot()","valueType":"Slot","writeMethodCall":"writeSlot","isNullable":false}); json.writeName("data"); - writePathConstraintData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"PathConstraintData","writeMethodCall":"writePathConstraintData","isNullable":false}); json.writeName("pose"); - writePathConstraintPose(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"PathConstraintPose","writeMethodCall":"writePathConstraintPose","isNullable":false}); json.writeName("appliedPose"); - writePathConstraintPose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"PathConstraintPose","writeMethodCall":"writePathConstraintPose","isNullable":false}); json.writeObjectEnd(); } - private function writePathConstraintData(obj:PathConstraintData):Void { + private function writePathConstraintData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2711,60 +2344,42 @@ class SkeletonSerializer { json.writeValue("PathConstraintData"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBoneData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BoneData","elementKind":"object","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("slot"); - writeSlotData(obj.slot); + writeProperty(obj, "getSlot()", {"kind":"object","name":"slot","getter":"getSlot()","valueType":"SlotData","writeMethodCall":"writeSlotData","isNullable":false}); json.writeName("positionMode"); - switch (obj.positionMode) { - case PositionMode.fixed: json.writeValue("fixed"); - case PositionMode.percent: json.writeValue("percent"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getPositionMode()", {"kind":"enum","name":"positionMode","getter":"getPositionMode()","enumName":"PositionMode","isNullable":false}); json.writeName("spacingMode"); - switch (obj.spacingMode) { - case SpacingMode.length: json.writeValue("length"); - case SpacingMode.fixed: json.writeValue("fixed"); - case SpacingMode.percent: json.writeValue("percent"); - case SpacingMode.proportional: json.writeValue("proportional"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getSpacingMode()", {"kind":"enum","name":"spacingMode","getter":"getSpacingMode()","enumName":"SpacingMode","isNullable":false}); json.writeName("rotateMode"); - switch (obj.rotateMode) { - case RotateMode.tangent: json.writeValue("tangent"); - case RotateMode.chain: json.writeValue("chain"); - case RotateMode.chainScale: json.writeValue("chainScale"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getRotateMode()", {"kind":"enum","name":"rotateMode","getter":"getRotateMode()","enumName":"RotateMode","isNullable":false}); json.writeName("offsetRotation"); - json.writeValue(obj.offsetRotation); + writeProperty(obj, "getOffsetRotation()", {"kind":"primitive","name":"offsetRotation","getter":"getOffsetRotation()","valueType":"float","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writePathConstraintPose(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"PathConstraintPose","writeMethodCall":"writePathConstraintPose","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writePathConstraintPose(obj:PathConstraintPose):Void { + private function writePathConstraintPose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2774,29 +2389,30 @@ class SkeletonSerializer { json.writeValue("PathConstraintPose"); json.writeName("position"); - json.writeValue(obj.position); + writeProperty(obj, "getPosition()", {"kind":"primitive","name":"position","getter":"getPosition()","valueType":"float","isNullable":false}); json.writeName("spacing"); - json.writeValue(obj.spacing); + writeProperty(obj, "getSpacing()", {"kind":"primitive","name":"spacing","getter":"getSpacing()","valueType":"float","isNullable":false}); json.writeName("mixRotate"); - json.writeValue(obj.mixRotate); + writeProperty(obj, "getMixRotate()", {"kind":"primitive","name":"mixRotate","getter":"getMixRotate()","valueType":"float","isNullable":false}); json.writeName("mixX"); - json.writeValue(obj.mixX); + writeProperty(obj, "getMixX()", {"kind":"primitive","name":"mixX","getter":"getMixX()","valueType":"float","isNullable":false}); json.writeName("mixY"); - json.writeValue(obj.mixY); + writeProperty(obj, "getMixY()", {"kind":"primitive","name":"mixY","getter":"getMixY()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraint(obj:PhysicsConstraint):Void { + private function writePhysicsConstraint(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2806,26 +2422,28 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraint"); json.writeName("bone"); - writeBonePose(obj.bone); + writeProperty(obj, "getBone()", {"kind":"object","name":"bone","getter":"getBone()","valueType":"BonePose","writeMethodCall":"writeBonePose","isNullable":false}); json.writeName("data"); - writePhysicsConstraintData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"PhysicsConstraintData","writeMethodCall":"writePhysicsConstraintData","isNullable":false}); json.writeName("pose"); - writePhysicsConstraintPose(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"PhysicsConstraintPose","writeMethodCall":"writePhysicsConstraintPose","isNullable":false}); json.writeName("appliedPose"); - writePhysicsConstraintPose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"PhysicsConstraintPose","writeMethodCall":"writePhysicsConstraintPose","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintData(obj:PhysicsConstraintData):Void { + private function writePhysicsConstraintData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2835,68 +2453,69 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintData"); json.writeName("bone"); - writeBoneData(obj.bone); + writeProperty(obj, "getBone()", {"kind":"object","name":"bone","getter":"getBone()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("step"); - json.writeValue(obj.step); + writeProperty(obj, "getStep()", {"kind":"primitive","name":"step","getter":"getStep()","valueType":"float","isNullable":false}); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("rotate"); - json.writeValue(obj.rotate); + writeProperty(obj, "getRotate()", {"kind":"primitive","name":"rotate","getter":"getRotate()","valueType":"float","isNullable":false}); json.writeName("scaleX"); - json.writeValue(obj.scaleX); + writeProperty(obj, "getScaleX()", {"kind":"primitive","name":"scaleX","getter":"getScaleX()","valueType":"float","isNullable":false}); json.writeName("shearX"); - json.writeValue(obj.shearX); + writeProperty(obj, "getShearX()", {"kind":"primitive","name":"shearX","getter":"getShearX()","valueType":"float","isNullable":false}); json.writeName("limit"); - json.writeValue(obj.limit); + writeProperty(obj, "getLimit()", {"kind":"primitive","name":"limit","getter":"getLimit()","valueType":"float","isNullable":false}); json.writeName("inertiaGlobal"); - json.writeValue(obj.inertiaGlobal); + writeProperty(obj, "getInertiaGlobal()", {"kind":"primitive","name":"inertiaGlobal","getter":"getInertiaGlobal()","valueType":"boolean","isNullable":false}); json.writeName("strengthGlobal"); - json.writeValue(obj.strengthGlobal); + writeProperty(obj, "getStrengthGlobal()", {"kind":"primitive","name":"strengthGlobal","getter":"getStrengthGlobal()","valueType":"boolean","isNullable":false}); json.writeName("dampingGlobal"); - json.writeValue(obj.dampingGlobal); + writeProperty(obj, "getDampingGlobal()", {"kind":"primitive","name":"dampingGlobal","getter":"getDampingGlobal()","valueType":"boolean","isNullable":false}); json.writeName("massGlobal"); - json.writeValue(obj.massGlobal); + writeProperty(obj, "getMassGlobal()", {"kind":"primitive","name":"massGlobal","getter":"getMassGlobal()","valueType":"boolean","isNullable":false}); json.writeName("windGlobal"); - json.writeValue(obj.windGlobal); + writeProperty(obj, "getWindGlobal()", {"kind":"primitive","name":"windGlobal","getter":"getWindGlobal()","valueType":"boolean","isNullable":false}); json.writeName("gravityGlobal"); - json.writeValue(obj.gravityGlobal); + writeProperty(obj, "getGravityGlobal()", {"kind":"primitive","name":"gravityGlobal","getter":"getGravityGlobal()","valueType":"boolean","isNullable":false}); json.writeName("mixGlobal"); - json.writeValue(obj.mixGlobal); + writeProperty(obj, "getMixGlobal()", {"kind":"primitive","name":"mixGlobal","getter":"getMixGlobal()","valueType":"boolean","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writePhysicsConstraintPose(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"PhysicsConstraintPose","writeMethodCall":"writePhysicsConstraintPose","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writePhysicsConstraintPose(obj:PhysicsConstraintPose):Void { + private function writePhysicsConstraintPose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2906,35 +2525,37 @@ class SkeletonSerializer { json.writeValue("PhysicsConstraintPose"); json.writeName("inertia"); - json.writeValue(obj.inertia); + writeProperty(obj, "getInertia()", {"kind":"primitive","name":"inertia","getter":"getInertia()","valueType":"float","isNullable":false}); json.writeName("strength"); - json.writeValue(obj.strength); + writeProperty(obj, "getStrength()", {"kind":"primitive","name":"strength","getter":"getStrength()","valueType":"float","isNullable":false}); json.writeName("damping"); - json.writeValue(obj.damping); + writeProperty(obj, "getDamping()", {"kind":"primitive","name":"damping","getter":"getDamping()","valueType":"float","isNullable":false}); json.writeName("massInverse"); - json.writeValue(obj.massInverse); + writeProperty(obj, "getMassInverse()", {"kind":"primitive","name":"massInverse","getter":"getMassInverse()","valueType":"float","isNullable":false}); json.writeName("wind"); - json.writeValue(obj.wind); + writeProperty(obj, "getWind()", {"kind":"primitive","name":"wind","getter":"getWind()","valueType":"float","isNullable":false}); json.writeName("gravity"); - json.writeValue(obj.gravity); + writeProperty(obj, "getGravity()", {"kind":"primitive","name":"gravity","getter":"getGravity()","valueType":"float","isNullable":false}); json.writeName("mix"); - json.writeValue(obj.mix); + writeProperty(obj, "getMix()", {"kind":"primitive","name":"mix","getter":"getMix()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writePointAttachment(obj:PointAttachment):Void { + private function writePointAttachment(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2944,29 +2565,31 @@ class SkeletonSerializer { json.writeValue("PointAttachment"); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("rotation"); - json.writeValue(obj.rotation); + writeProperty(obj, "getRotation()", {"kind":"primitive","name":"rotation","getter":"getRotation()","valueType":"float","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writeRegionAttachment(obj:RegionAttachment):Void { + private function writeRegionAttachment(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -2976,65 +2599,57 @@ class SkeletonSerializer { json.writeValue("RegionAttachment"); json.writeName("region"); - if (obj.region == null) { - json.writeNull(); - } else { - writeTextureRegion(obj.region); - } + writeProperty(obj, "getRegion()", {"kind":"object","name":"region","getter":"getRegion()","valueType":"TextureRegion","writeMethodCall":"writeTextureRegion","isNullable":true}); + + json.writeName("offset"); + writeProperty(obj, "getOffset()", {"kind":"array","name":"offset","getter":"getOffset()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("uVs"); - json.writeArrayStart(); - for (item in obj.uvs) { - json.writeValue(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getUVs()", {"kind":"array","name":"uVs","getter":"getUVs()","elementType":"float","elementKind":"primitive","isNullable":false}); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("scaleX"); - json.writeValue(obj.scaleX); + writeProperty(obj, "getScaleX()", {"kind":"primitive","name":"scaleX","getter":"getScaleX()","valueType":"float","isNullable":false}); json.writeName("scaleY"); - json.writeValue(obj.scaleY); + writeProperty(obj, "getScaleY()", {"kind":"primitive","name":"scaleY","getter":"getScaleY()","valueType":"float","isNullable":false}); json.writeName("rotation"); - json.writeValue(obj.rotation); + writeProperty(obj, "getRotation()", {"kind":"primitive","name":"rotation","getter":"getRotation()","valueType":"float","isNullable":false}); json.writeName("width"); - json.writeValue(obj.width); + writeProperty(obj, "getWidth()", {"kind":"primitive","name":"width","getter":"getWidth()","valueType":"float","isNullable":false}); json.writeName("height"); - json.writeValue(obj.height); + writeProperty(obj, "getHeight()", {"kind":"primitive","name":"height","getter":"getHeight()","valueType":"float","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("path"); - json.writeValue(obj.path); + writeProperty(obj, "getPath()", {"kind":"primitive","name":"path","getter":"getPath()","valueType":"String","isNullable":false}); json.writeName("sequence"); - if (obj.sequence == null) { - json.writeNull(); - } else { - writeSequence(obj.sequence); - } + writeProperty(obj, "getSequence()", {"kind":"object","name":"sequence","getter":"getSequence()","valueType":"Sequence","writeMethodCall":"writeSequence","isNullable":true}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeObjectEnd(); } - private function writeSequence(obj:Sequence):Void { + private function writeSequence(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3044,33 +2659,30 @@ class SkeletonSerializer { json.writeValue("Sequence"); json.writeName("start"); - json.writeValue(obj.start); + writeProperty(obj, "getStart()", {"kind":"primitive","name":"start","getter":"getStart()","valueType":"int","isNullable":false}); json.writeName("digits"); - json.writeValue(obj.digits); + writeProperty(obj, "getDigits()", {"kind":"primitive","name":"digits","getter":"getDigits()","valueType":"int","isNullable":false}); json.writeName("setupIndex"); - json.writeValue(obj.setupIndex); + writeProperty(obj, "getSetupIndex()", {"kind":"primitive","name":"setupIndex","getter":"getSetupIndex()","valueType":"int","isNullable":false}); json.writeName("regions"); - json.writeArrayStart(); - for (item in obj.regions) { - writeTextureRegion(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getRegions()", {"kind":"array","name":"regions","getter":"getRegions()","elementType":"TextureRegion","elementKind":"object","writeMethodCall":"writeTextureRegion","isNullable":false}); json.writeName("id"); - json.writeValue(obj.id); + writeProperty(obj, "getId()", {"kind":"primitive","name":"id","getter":"getId()","valueType":"int","isNullable":false}); json.writeObjectEnd(); } - private function writeSkeleton(obj:Skeleton):Void { + private function writeSkeleton(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3080,99 +2692,73 @@ class SkeletonSerializer { json.writeValue("Skeleton"); json.writeName("data"); - writeSkeletonData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"SkeletonData","writeMethodCall":"writeSkeletonData","isNullable":false}); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBone(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"Bone","elementKind":"object","writeMethodCall":"writeBone","isNullable":false}); json.writeName("updateCache"); - json.writeArrayStart(); - for (item in obj.updateCache) { - writeUpdate(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getUpdateCache()", {"kind":"array","name":"updateCache","getter":"getUpdateCache()","elementType":"Update","elementKind":"object","writeMethodCall":"writeUpdate","isNullable":false}); json.writeName("rootBone"); - writeBone(obj.rootBone); + writeProperty(obj, "getRootBone()", {"kind":"object","name":"rootBone","getter":"getRootBone()","valueType":"Bone","writeMethodCall":"writeBone","isNullable":false}); json.writeName("slots"); - json.writeArrayStart(); - for (item in obj.slots) { - writeSlot(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getSlots()", {"kind":"array","name":"slots","getter":"getSlots()","elementType":"Slot","elementKind":"object","writeMethodCall":"writeSlot","isNullable":false}); json.writeName("drawOrder"); - json.writeArrayStart(); - for (item in obj.drawOrder) { - writeSlot(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getDrawOrder()", {"kind":"array","name":"drawOrder","getter":"getDrawOrder()","elementType":"Slot","elementKind":"object","writeMethodCall":"writeSlot","isNullable":false}); json.writeName("skin"); - if (obj.skin == null) { - json.writeNull(); - } else { - writeSkin(obj.skin); - } + writeProperty(obj, "getSkin()", {"kind":"object","name":"skin","getter":"getSkin()","valueType":"Skin","writeMethodCall":"writeSkin","isNullable":true}); json.writeName("constraints"); - json.writeArrayStart(); - for (item in obj.constraints) { - writeConstraint(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getConstraints()", {"kind":"array","name":"constraints","getter":"getConstraints()","elementType":"Constraint","elementKind":"object","writeMethodCall":"writeConstraint","isNullable":false}); json.writeName("physicsConstraints"); - json.writeArrayStart(); - for (item in obj.physics) { - writePhysicsConstraint(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getPhysicsConstraints()", {"kind":"array","name":"physicsConstraints","getter":"getPhysicsConstraints()","elementType":"PhysicsConstraint","elementKind":"object","writeMethodCall":"writePhysicsConstraint","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("scaleX"); - json.writeValue(obj.scaleX); + writeProperty(obj, "getScaleX()", {"kind":"primitive","name":"scaleX","getter":"getScaleX()","valueType":"float","isNullable":false}); json.writeName("scaleY"); - json.writeValue(obj.scaleY); + writeProperty(obj, "getScaleY()", {"kind":"primitive","name":"scaleY","getter":"getScaleY()","valueType":"float","isNullable":false}); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("windX"); - json.writeValue(obj.windX); + writeProperty(obj, "getWindX()", {"kind":"primitive","name":"windX","getter":"getWindX()","valueType":"float","isNullable":false}); json.writeName("windY"); - json.writeValue(obj.windY); + writeProperty(obj, "getWindY()", {"kind":"primitive","name":"windY","getter":"getWindY()","valueType":"float","isNullable":false}); json.writeName("gravityX"); - json.writeValue(obj.gravityX); + writeProperty(obj, "getGravityX()", {"kind":"primitive","name":"gravityX","getter":"getGravityX()","valueType":"float","isNullable":false}); json.writeName("gravityY"); - json.writeValue(obj.gravityY); + writeProperty(obj, "getGravityY()", {"kind":"primitive","name":"gravityY","getter":"getGravityY()","valueType":"float","isNullable":false}); json.writeName("time"); - json.writeValue(obj.time); + writeProperty(obj, "getTime()", {"kind":"primitive","name":"time","getter":"getTime()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeSkeletonData(obj:SkeletonData):Void { + private function writeSkeletonData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3182,96 +2768,70 @@ class SkeletonSerializer { json.writeValue("SkeletonData"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBoneData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BoneData","elementKind":"object","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("slots"); - json.writeArrayStart(); - for (item in obj.slots) { - writeSlotData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getSlots()", {"kind":"array","name":"slots","getter":"getSlots()","elementType":"SlotData","elementKind":"object","writeMethodCall":"writeSlotData","isNullable":false}); json.writeName("defaultSkin"); - if (obj.defaultSkin == null) { - json.writeNull(); - } else { - writeSkin(obj.defaultSkin); - } + writeProperty(obj, "getDefaultSkin()", {"kind":"object","name":"defaultSkin","getter":"getDefaultSkin()","valueType":"Skin","writeMethodCall":"writeSkin","isNullable":true}); json.writeName("skins"); - json.writeArrayStart(); - for (item in obj.skins) { - writeSkin(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getSkins()", {"kind":"array","name":"skins","getter":"getSkins()","elementType":"Skin","elementKind":"object","writeMethodCall":"writeSkin","isNullable":false}); json.writeName("events"); - json.writeArrayStart(); - for (item in obj.events) { - writeEventData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getEvents()", {"kind":"array","name":"events","getter":"getEvents()","elementType":"EventData","elementKind":"object","writeMethodCall":"writeEventData","isNullable":false}); json.writeName("animations"); - json.writeArrayStart(); - for (item in obj.animations) { - writeAnimation(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getAnimations()", {"kind":"array","name":"animations","getter":"getAnimations()","elementType":"Animation","elementKind":"object","writeMethodCall":"writeAnimation","isNullable":false}); json.writeName("constraints"); - json.writeArrayStart(); - for (item in obj.constraints) { - writeConstraintData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getConstraints()", {"kind":"array","name":"constraints","getter":"getConstraints()","elementType":"ConstraintData","elementKind":"object","writeMethodCall":"writeConstraintData","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":true}); json.writeName("x"); - json.writeValue(obj.x); + writeProperty(obj, "getX()", {"kind":"primitive","name":"x","getter":"getX()","valueType":"float","isNullable":false}); json.writeName("y"); - json.writeValue(obj.y); + writeProperty(obj, "getY()", {"kind":"primitive","name":"y","getter":"getY()","valueType":"float","isNullable":false}); json.writeName("width"); - json.writeValue(obj.width); + writeProperty(obj, "getWidth()", {"kind":"primitive","name":"width","getter":"getWidth()","valueType":"float","isNullable":false}); json.writeName("height"); - json.writeValue(obj.height); + writeProperty(obj, "getHeight()", {"kind":"primitive","name":"height","getter":"getHeight()","valueType":"float","isNullable":false}); json.writeName("referenceScale"); - json.writeValue(obj.referenceScale); + writeProperty(obj, "getReferenceScale()", {"kind":"primitive","name":"referenceScale","getter":"getReferenceScale()","valueType":"float","isNullable":false}); json.writeName("version"); - json.writeValue(obj.version); + writeProperty(obj, "getVersion()", {"kind":"primitive","name":"version","getter":"getVersion()","valueType":"String","isNullable":true}); json.writeName("hash"); - json.writeValue(obj.hash); + writeProperty(obj, "getHash()", {"kind":"primitive","name":"hash","getter":"getHash()","valueType":"String","isNullable":true}); json.writeName("imagesPath"); - json.writeValue(obj.imagesPath); + writeProperty(obj, "getImagesPath()", {"kind":"primitive","name":"imagesPath","getter":"getImagesPath()","valueType":"String","isNullable":true}); json.writeName("audioPath"); - json.writeValue(obj.audioPath); + writeProperty(obj, "getAudioPath()", {"kind":"primitive","name":"audioPath","getter":"getAudioPath()","valueType":"String","isNullable":true}); json.writeName("fps"); - json.writeValue(obj.fps); + writeProperty(obj, "getFps()", {"kind":"primitive","name":"fps","getter":"getFps()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeSkin(obj:Skin):Void { + private function writeSkin(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3280,63 +2840,59 @@ class SkeletonSerializer { json.writeName("type"); json.writeValue("Skin"); - json.writeName("name"); - json.writeValue(obj.name); - json.writeName("attachments"); - json.writeArrayStart(); - var skinEntries = obj.getAttachments(); - for (entry in skinEntries) { - writeSkinEntry(entry); - } - json.writeArrayEnd(); + writeProperty(obj, "getAttachments()", {"kind":"array","name":"attachments","getter":"getAttachments()","elementType":"SkinEntry","elementKind":"object","writeMethodCall":"writeSkinEntry","isNullable":false}); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBoneData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BoneData","elementKind":"object","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("constraints"); - json.writeArrayStart(); - for (item in obj.constraints) { - writeConstraintData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getConstraints()", {"kind":"array","name":"constraints","getter":"getConstraints()","elementType":"ConstraintData","elementKind":"object","writeMethodCall":"writeConstraintData","isNullable":false}); + + json.writeName("name"); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeObjectEnd(); } - private function writeSkinEntry(obj:SkinEntry):Void { - json.writeObjectStart(); - var refString = ""; - json.writeName("refString"); - json.writeValue(refString); - json.writeName("type"); - json.writeValue("SkinEntry"); - json.writeName("slotIndex"); - json.writeValue(obj.slotIndex); - json.writeName("name"); - json.writeValue(obj.name); - json.writeName("attachment"); - if (obj.attachment == null) { - json.writeNull(); - } else { - writeAttachment(obj.attachment); - } - json.writeObjectEnd(); - } - - private function writeSlider(obj:Slider):Void { + private function writeSkinEntry(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; + visitedObjects.set(obj, refString); + + json.writeObjectStart(); + json.writeName("refString"); + json.writeValue(refString); + json.writeName("type"); + json.writeValue("SkinEntry"); + + json.writeName("slotIndex"); + writeProperty(obj, "getSlotIndex()", {"kind":"primitive","name":"slotIndex","getter":"getSlotIndex()","valueType":"int","isNullable":false}); + + json.writeName("name"); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); + + json.writeName("attachment"); + writeProperty(obj, "getAttachment()", {"kind":"object","name":"attachment","getter":"getAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":false}); + + json.writeObjectEnd(); + } + + private function writeSlider(obj:Dynamic):Void { + if (visitedObjects.exists(obj)) { + json.writeValue(visitedObjects.get(obj)); + return; + } + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3346,26 +2902,28 @@ class SkeletonSerializer { json.writeValue("Slider"); json.writeName("bone"); - writeBone(obj.bone); + writeProperty(obj, "getBone()", {"kind":"object","name":"bone","getter":"getBone()","valueType":"Bone","writeMethodCall":"writeBone","isNullable":false}); json.writeName("data"); - writeSliderData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"SliderData","writeMethodCall":"writeSliderData","isNullable":false}); json.writeName("pose"); - writeSliderPose(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"SliderPose","writeMethodCall":"writeSliderPose","isNullable":false}); json.writeName("appliedPose"); - writeSliderPose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"SliderPose","writeMethodCall":"writeSliderPose","isNullable":false}); json.writeObjectEnd(); } - private function writeSliderData(obj:SliderData):Void { + private function writeSliderData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3375,55 +2933,48 @@ class SkeletonSerializer { json.writeValue("SliderData"); json.writeName("animation"); - writeAnimation(obj.animation); + writeProperty(obj, "getAnimation()", {"kind":"object","name":"animation","getter":"getAnimation()","valueType":"Animation","writeMethodCall":"writeAnimation","isNullable":false}); json.writeName("additive"); - json.writeValue(obj.additive); + writeProperty(obj, "getAdditive()", {"kind":"primitive","name":"additive","getter":"getAdditive()","valueType":"boolean","isNullable":false}); json.writeName("loop"); - json.writeValue(obj.loop); + writeProperty(obj, "getLoop()", {"kind":"primitive","name":"loop","getter":"getLoop()","valueType":"boolean","isNullable":false}); json.writeName("bone"); - if (obj.bone == null) { - json.writeNull(); - } else { - writeBoneData(obj.bone); - } + writeProperty(obj, "getBone()", {"kind":"object","name":"bone","getter":"getBone()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":true}); json.writeName("property"); - if (obj.property == null) { - json.writeNull(); - } else { - writeFromProperty(obj.property); - } + writeProperty(obj, "getProperty()", {"kind":"object","name":"property","getter":"getProperty()","valueType":"TransformConstraintData.FromProperty","writeMethodCall":"writeFromProperty","isNullable":true}); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "getOffset()", {"kind":"primitive","name":"offset","getter":"getOffset()","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "getScale()", {"kind":"primitive","name":"scale","getter":"getScale()","valueType":"float","isNullable":false}); json.writeName("local"); - json.writeValue(obj.local); + writeProperty(obj, "getLocal()", {"kind":"primitive","name":"local","getter":"getLocal()","valueType":"boolean","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writeSliderPose(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"SliderPose","writeMethodCall":"writeSliderPose","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeSliderPose(obj:SliderPose):Void { + private function writeSliderPose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3433,20 +2984,21 @@ class SkeletonSerializer { json.writeValue("SliderPose"); json.writeName("time"); - json.writeValue(obj.time); + writeProperty(obj, "getTime()", {"kind":"primitive","name":"time","getter":"getTime()","valueType":"float","isNullable":false}); json.writeName("mix"); - json.writeValue(obj.mix); + writeProperty(obj, "getMix()", {"kind":"primitive","name":"mix","getter":"getMix()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeSlot(obj:Slot):Void { + private function writeSlot(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3456,26 +3008,28 @@ class SkeletonSerializer { json.writeValue("Slot"); json.writeName("bone"); - writeBone(obj.bone); + writeProperty(obj, "getBone()", {"kind":"object","name":"bone","getter":"getBone()","valueType":"Bone","writeMethodCall":"writeBone","isNullable":false}); json.writeName("data"); - writeSlotData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"SlotData","writeMethodCall":"writeSlotData","isNullable":false}); json.writeName("pose"); - writeSlotPose(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"SlotPose","writeMethodCall":"writeSlotPose","isNullable":false}); json.writeName("appliedPose"); - writeSlotPose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"SlotPose","writeMethodCall":"writeSlotPose","isNullable":false}); json.writeObjectEnd(); } - private function writeSlotData(obj:SlotData):Void { + private function writeSlotData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3485,44 +3039,39 @@ class SkeletonSerializer { json.writeValue("SlotData"); json.writeName("index"); - json.writeValue(obj.index); + writeProperty(obj, "getIndex()", {"kind":"primitive","name":"index","getter":"getIndex()","valueType":"int","isNullable":false}); json.writeName("boneData"); - writeBoneData(obj.boneData); + writeProperty(obj, "getBoneData()", {"kind":"object","name":"boneData","getter":"getBoneData()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("attachmentName"); - json.writeValue(obj.attachmentName); + writeProperty(obj, "getAttachmentName()", {"kind":"primitive","name":"attachmentName","getter":"getAttachmentName()","valueType":"String","isNullable":true}); json.writeName("blendMode"); - switch (obj.blendMode) { - case BlendMode.normal: json.writeValue("normal"); - case BlendMode.additive: json.writeValue("additive"); - case BlendMode.multiply: json.writeValue("multiply"); - case BlendMode.screen: json.writeValue("screen"); - default: json.writeValue("unknown"); - } + writeProperty(obj, "getBlendMode()", {"kind":"enum","name":"blendMode","getter":"getBlendMode()","enumName":"BlendMode","isNullable":false}); json.writeName("visible"); - json.writeValue(obj.visible); + writeProperty(obj, "getVisible()", {"kind":"primitive","name":"visible","getter":"getVisible()","valueType":"boolean","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writeSlotPose(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"SlotPose","writeMethodCall":"writeSlotPose","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeSlotPose(obj:SlotPose):Void { + private function writeSlotPose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3532,37 +3081,30 @@ class SkeletonSerializer { json.writeValue("SlotPose"); json.writeName("color"); - writeColor(obj.color); + writeProperty(obj, "getColor()", {"kind":"object","name":"color","getter":"getColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":false}); json.writeName("darkColor"); - if (obj.darkColor == null) { - json.writeNull(); - } else { - writeColor(obj.darkColor); - } + writeProperty(obj, "getDarkColor()", {"kind":"object","name":"darkColor","getter":"getDarkColor()","valueType":"Color","writeMethodCall":"writeColor","isNullable":true}); json.writeName("attachment"); - if (obj.attachment == null) { - json.writeNull(); - } else { - writeAttachment(obj.attachment); - } + writeProperty(obj, "getAttachment()", {"kind":"object","name":"attachment","getter":"getAttachment()","valueType":"Attachment","writeMethodCall":"writeAttachment","isNullable":true}); json.writeName("sequenceIndex"); - json.writeValue(obj.sequenceIndex); + writeProperty(obj, "getSequenceIndex()", {"kind":"primitive","name":"sequenceIndex","getter":"getSequenceIndex()","valueType":"int","isNullable":false}); json.writeName("deform"); - writeFloatArray(obj.deform); + writeProperty(obj, "getDeform()", {"kind":"object","name":"deform","getter":"getDeform()","valueType":"FloatArray","writeMethodCall":"writeFloatArray","isNullable":false}); json.writeObjectEnd(); } - private function writeTransformConstraint(obj:TransformConstraint):Void { + private function writeTransformConstraint(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3572,33 +3114,31 @@ class SkeletonSerializer { json.writeValue("TransformConstraint"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBonePose(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BonePose","elementKind":"object","writeMethodCall":"writeBonePose","isNullable":false}); json.writeName("source"); - writeBone(obj.source); + writeProperty(obj, "getSource()", {"kind":"object","name":"source","getter":"getSource()","valueType":"Bone","writeMethodCall":"writeBone","isNullable":false}); json.writeName("data"); - writeTransformConstraintData(obj.data); + writeProperty(obj, "getData()", {"kind":"object","name":"data","getter":"getData()","valueType":"TransformConstraintData","writeMethodCall":"writeTransformConstraintData","isNullable":false}); json.writeName("pose"); - writeTransformConstraintPose(obj.pose); + writeProperty(obj, "getPose()", {"kind":"object","name":"pose","getter":"getPose()","valueType":"TransformConstraintPose","writeMethodCall":"writeTransformConstraintPose","isNullable":false}); json.writeName("appliedPose"); - writeTransformConstraintPose(obj.applied); + writeProperty(obj, "getAppliedPose()", {"kind":"object","name":"appliedPose","getter":"getAppliedPose()","valueType":"TransformConstraintPose","writeMethodCall":"writeTransformConstraintPose","isNullable":false}); json.writeObjectEnd(); } - private function writeTransformConstraintData(obj:TransformConstraintData):Void { + private function writeTransformConstraintData(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = obj.name != null ? "" : ""; + + var nameValue = getPropertyValue(obj, "getName()"); + var refString = nameValue != null ? "" : ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3608,88 +3148,81 @@ class SkeletonSerializer { json.writeValue("TransformConstraintData"); json.writeName("bones"); - json.writeArrayStart(); - for (item in obj.bones) { - writeBoneData(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getBones()", {"kind":"array","name":"bones","getter":"getBones()","elementType":"BoneData","elementKind":"object","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("source"); - writeBoneData(obj.source); + writeProperty(obj, "getSource()", {"kind":"object","name":"source","getter":"getSource()","valueType":"BoneData","writeMethodCall":"writeBoneData","isNullable":false}); json.writeName("offsetRotation"); - json.writeValue(obj.offsetRotation); + writeProperty(obj, "getOffsetRotation()", {"kind":"primitive","name":"offsetRotation","getter":"getOffsetRotation()","valueType":"float","isNullable":false}); json.writeName("offsetX"); - json.writeValue(obj.offsetX); + writeProperty(obj, "getOffsetX()", {"kind":"primitive","name":"offsetX","getter":"getOffsetX()","valueType":"float","isNullable":false}); json.writeName("offsetY"); - json.writeValue(obj.offsetY); + writeProperty(obj, "getOffsetY()", {"kind":"primitive","name":"offsetY","getter":"getOffsetY()","valueType":"float","isNullable":false}); json.writeName("offsetScaleX"); - json.writeValue(obj.offsetScaleX); + writeProperty(obj, "getOffsetScaleX()", {"kind":"primitive","name":"offsetScaleX","getter":"getOffsetScaleX()","valueType":"float","isNullable":false}); json.writeName("offsetScaleY"); - json.writeValue(obj.offsetScaleY); + writeProperty(obj, "getOffsetScaleY()", {"kind":"primitive","name":"offsetScaleY","getter":"getOffsetScaleY()","valueType":"float","isNullable":false}); json.writeName("offsetShearY"); - json.writeValue(obj.offsetShearY); + writeProperty(obj, "getOffsetShearY()", {"kind":"primitive","name":"offsetShearY","getter":"getOffsetShearY()","valueType":"float","isNullable":false}); json.writeName("localSource"); - json.writeValue(obj.localSource); + writeProperty(obj, "getLocalSource()", {"kind":"primitive","name":"localSource","getter":"getLocalSource()","valueType":"boolean","isNullable":false}); json.writeName("localTarget"); - json.writeValue(obj.localTarget); + writeProperty(obj, "getLocalTarget()", {"kind":"primitive","name":"localTarget","getter":"getLocalTarget()","valueType":"boolean","isNullable":false}); json.writeName("additive"); - json.writeValue(obj.additive); + writeProperty(obj, "getAdditive()", {"kind":"primitive","name":"additive","getter":"getAdditive()","valueType":"boolean","isNullable":false}); json.writeName("clamp"); - json.writeValue(obj.clamp); + writeProperty(obj, "getClamp()", {"kind":"primitive","name":"clamp","getter":"getClamp()","valueType":"boolean","isNullable":false}); json.writeName("properties"); - json.writeArrayStart(); - for (item in obj.properties) { - writeFromProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "getProperties()", {"kind":"array","name":"properties","getter":"getProperties()","elementType":"FromProperty","elementKind":"object","writeMethodCall":"writeFromProperty","isNullable":false}); json.writeName("name"); - json.writeValue(obj.name); + writeProperty(obj, "getName()", {"kind":"primitive","name":"name","getter":"getName()","valueType":"String","isNullable":false}); json.writeName("setupPose"); - writeTransformConstraintPose(obj.setup); + writeProperty(obj, "getSetupPose()", {"kind":"object","name":"setupPose","getter":"getSetupPose()","valueType":"TransformConstraintPose","writeMethodCall":"writeTransformConstraintPose","isNullable":false}); json.writeName("skinRequired"); - json.writeValue(obj.skinRequired); + writeProperty(obj, "getSkinRequired()", {"kind":"primitive","name":"skinRequired","getter":"getSkinRequired()","valueType":"boolean","isNullable":false}); json.writeObjectEnd(); } - private function writeFromProperty(obj:TransformConstraintData.FromProperty):Void { - if (Std.isOfType(obj, TransformConstraintData.FromRotate)) { - writeFromRotate(cast(obj, TransformConstraintData.FromRotate)); - } else if (Std.isOfType(obj, TransformConstraintData.FromScaleX)) { - writeFromScaleX(cast(obj, TransformConstraintData.FromScaleX)); - } else if (Std.isOfType(obj, TransformConstraintData.FromScaleY)) { - writeFromScaleY(cast(obj, TransformConstraintData.FromScaleY)); - } else if (Std.isOfType(obj, TransformConstraintData.FromShearY)) { - writeFromShearY(cast(obj, TransformConstraintData.FromShearY)); - } else if (Std.isOfType(obj, TransformConstraintData.FromX)) { - writeFromX(cast(obj, TransformConstraintData.FromX)); - } else if (Std.isOfType(obj, TransformConstraintData.FromY)) { - writeFromY(cast(obj, TransformConstraintData.FromY)); + private function writeFromProperty(obj:Dynamic):Void { + if (Std.isOfType(obj, spine.TransformConstraintData.FromRotate)) { + writeFromRotate(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.FromScaleX)) { + writeFromScaleX(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.FromScaleY)) { + writeFromScaleY(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.FromShearY)) { + writeFromShearY(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.FromX)) { + writeFromX(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.FromY)) { + writeFromY(obj); } else { throw new spine.SpineException("Unknown FromProperty type"); } } - private function writeFromRotate(obj:TransformConstraintData.FromRotate):Void { + private function writeFromRotate(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3699,24 +3232,21 @@ class SkeletonSerializer { json.writeValue("FromRotate"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("to"); - json.writeArrayStart(); - for (item in obj.to) { - writeToProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "to", {"kind":"array","name":"to","getter":"to","elementType":"ToProperty","elementKind":"object","writeMethodCall":"writeToProperty","isNullable":false}); json.writeObjectEnd(); } - private function writeFromScaleX(obj:TransformConstraintData.FromScaleX):Void { + private function writeFromScaleX(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3726,24 +3256,21 @@ class SkeletonSerializer { json.writeValue("FromScaleX"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("to"); - json.writeArrayStart(); - for (item in obj.to) { - writeToProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "to", {"kind":"array","name":"to","getter":"to","elementType":"ToProperty","elementKind":"object","writeMethodCall":"writeToProperty","isNullable":false}); json.writeObjectEnd(); } - private function writeFromScaleY(obj:TransformConstraintData.FromScaleY):Void { + private function writeFromScaleY(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3753,24 +3280,21 @@ class SkeletonSerializer { json.writeValue("FromScaleY"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("to"); - json.writeArrayStart(); - for (item in obj.to) { - writeToProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "to", {"kind":"array","name":"to","getter":"to","elementType":"ToProperty","elementKind":"object","writeMethodCall":"writeToProperty","isNullable":false}); json.writeObjectEnd(); } - private function writeFromShearY(obj:TransformConstraintData.FromShearY):Void { + private function writeFromShearY(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3780,24 +3304,21 @@ class SkeletonSerializer { json.writeValue("FromShearY"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("to"); - json.writeArrayStart(); - for (item in obj.to) { - writeToProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "to", {"kind":"array","name":"to","getter":"to","elementType":"ToProperty","elementKind":"object","writeMethodCall":"writeToProperty","isNullable":false}); json.writeObjectEnd(); } - private function writeFromX(obj:TransformConstraintData.FromX):Void { + private function writeFromX(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3807,24 +3328,21 @@ class SkeletonSerializer { json.writeValue("FromX"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("to"); - json.writeArrayStart(); - for (item in obj.to) { - writeToProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "to", {"kind":"array","name":"to","getter":"to","elementType":"ToProperty","elementKind":"object","writeMethodCall":"writeToProperty","isNullable":false}); json.writeObjectEnd(); } - private function writeFromY(obj:TransformConstraintData.FromY):Void { + private function writeFromY(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3834,42 +3352,39 @@ class SkeletonSerializer { json.writeValue("FromY"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("to"); - json.writeArrayStart(); - for (item in obj.to) { - writeToProperty(item); - } - json.writeArrayEnd(); + writeProperty(obj, "to", {"kind":"array","name":"to","getter":"to","elementType":"ToProperty","elementKind":"object","writeMethodCall":"writeToProperty","isNullable":false}); json.writeObjectEnd(); } - private function writeToProperty(obj:TransformConstraintData.ToProperty):Void { - if (Std.isOfType(obj, TransformConstraintData.ToRotate)) { - writeToRotate(cast(obj, TransformConstraintData.ToRotate)); - } else if (Std.isOfType(obj, TransformConstraintData.ToScaleX)) { - writeToScaleX(cast(obj, TransformConstraintData.ToScaleX)); - } else if (Std.isOfType(obj, TransformConstraintData.ToScaleY)) { - writeToScaleY(cast(obj, TransformConstraintData.ToScaleY)); - } else if (Std.isOfType(obj, TransformConstraintData.ToShearY)) { - writeToShearY(cast(obj, TransformConstraintData.ToShearY)); - } else if (Std.isOfType(obj, TransformConstraintData.ToX)) { - writeToX(cast(obj, TransformConstraintData.ToX)); - } else if (Std.isOfType(obj, TransformConstraintData.ToY)) { - writeToY(cast(obj, TransformConstraintData.ToY)); + private function writeToProperty(obj:Dynamic):Void { + if (Std.isOfType(obj, spine.TransformConstraintData.ToRotate)) { + writeToRotate(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.ToScaleX)) { + writeToScaleX(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.ToScaleY)) { + writeToScaleY(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.ToShearY)) { + writeToShearY(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.ToX)) { + writeToX(obj); + } else if (Std.isOfType(obj, spine.TransformConstraintData.ToY)) { + writeToY(obj); } else { throw new spine.SpineException("Unknown ToProperty type"); } } - private function writeToRotate(obj:TransformConstraintData.ToRotate):Void { + private function writeToRotate(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3879,23 +3394,24 @@ class SkeletonSerializer { json.writeValue("ToRotate"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("max"); - json.writeValue(obj.max); + writeProperty(obj, "max", {"kind":"primitive","name":"max","getter":"max","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "scale", {"kind":"primitive","name":"scale","getter":"scale","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeToScaleX(obj:TransformConstraintData.ToScaleX):Void { + private function writeToScaleX(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3905,23 +3421,24 @@ class SkeletonSerializer { json.writeValue("ToScaleX"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("max"); - json.writeValue(obj.max); + writeProperty(obj, "max", {"kind":"primitive","name":"max","getter":"max","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "scale", {"kind":"primitive","name":"scale","getter":"scale","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeToScaleY(obj:TransformConstraintData.ToScaleY):Void { + private function writeToScaleY(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3931,23 +3448,24 @@ class SkeletonSerializer { json.writeValue("ToScaleY"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("max"); - json.writeValue(obj.max); + writeProperty(obj, "max", {"kind":"primitive","name":"max","getter":"max","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "scale", {"kind":"primitive","name":"scale","getter":"scale","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeToShearY(obj:TransformConstraintData.ToShearY):Void { + private function writeToShearY(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3957,23 +3475,24 @@ class SkeletonSerializer { json.writeValue("ToShearY"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("max"); - json.writeValue(obj.max); + writeProperty(obj, "max", {"kind":"primitive","name":"max","getter":"max","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "scale", {"kind":"primitive","name":"scale","getter":"scale","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeToX(obj:TransformConstraintData.ToX):Void { + private function writeToX(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -3983,23 +3502,24 @@ class SkeletonSerializer { json.writeValue("ToX"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("max"); - json.writeValue(obj.max); + writeProperty(obj, "max", {"kind":"primitive","name":"max","getter":"max","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "scale", {"kind":"primitive","name":"scale","getter":"scale","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeToY(obj:TransformConstraintData.ToY):Void { + private function writeToY(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -4009,23 +3529,24 @@ class SkeletonSerializer { json.writeValue("ToY"); json.writeName("offset"); - json.writeValue(obj.offset); + writeProperty(obj, "offset", {"kind":"primitive","name":"offset","getter":"offset","valueType":"float","isNullable":false}); json.writeName("max"); - json.writeValue(obj.max); + writeProperty(obj, "max", {"kind":"primitive","name":"max","getter":"max","valueType":"float","isNullable":false}); json.writeName("scale"); - json.writeValue(obj.scale); + writeProperty(obj, "scale", {"kind":"primitive","name":"scale","getter":"scale","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeTransformConstraintPose(obj:TransformConstraintPose):Void { + private function writeTransformConstraintPose(obj:Dynamic):Void { if (visitedObjects.exists(obj)) { json.writeValue(visitedObjects.get(obj)); return; } - var refString = ""; + + var refString = ""; visitedObjects.set(obj, refString); json.writeObjectStart(); @@ -4035,103 +3556,190 @@ class SkeletonSerializer { json.writeValue("TransformConstraintPose"); json.writeName("mixRotate"); - json.writeValue(obj.mixRotate); + writeProperty(obj, "getMixRotate()", {"kind":"primitive","name":"mixRotate","getter":"getMixRotate()","valueType":"float","isNullable":false}); json.writeName("mixX"); - json.writeValue(obj.mixX); + writeProperty(obj, "getMixX()", {"kind":"primitive","name":"mixX","getter":"getMixX()","valueType":"float","isNullable":false}); json.writeName("mixY"); - json.writeValue(obj.mixY); + writeProperty(obj, "getMixY()", {"kind":"primitive","name":"mixY","getter":"getMixY()","valueType":"float","isNullable":false}); json.writeName("mixScaleX"); - json.writeValue(obj.mixScaleX); + writeProperty(obj, "getMixScaleX()", {"kind":"primitive","name":"mixScaleX","getter":"getMixScaleX()","valueType":"float","isNullable":false}); json.writeName("mixScaleY"); - json.writeValue(obj.mixScaleY); + writeProperty(obj, "getMixScaleY()", {"kind":"primitive","name":"mixScaleY","getter":"getMixScaleY()","valueType":"float","isNullable":false}); json.writeName("mixShearY"); - json.writeValue(obj.mixShearY); + writeProperty(obj, "getMixShearY()", {"kind":"primitive","name":"mixShearY","getter":"getMixShearY()","valueType":"float","isNullable":false}); json.writeObjectEnd(); } - private function writeUpdate(obj:Update):Void { + private function writeUpdate(obj:Dynamic):Void { if (Std.isOfType(obj, BonePose)) { - writeBonePose(cast(obj, BonePose)); + writeBonePose(obj); } else if (Std.isOfType(obj, IkConstraint)) { - writeIkConstraint(cast(obj, IkConstraint)); + writeIkConstraint(obj); } else if (Std.isOfType(obj, PathConstraint)) { - writePathConstraint(cast(obj, PathConstraint)); + writePathConstraint(obj); } else if (Std.isOfType(obj, PhysicsConstraint)) { - writePhysicsConstraint(cast(obj, PhysicsConstraint)); + writePhysicsConstraint(obj); } else if (Std.isOfType(obj, Slider)) { - writeSlider(cast(obj, Slider)); + writeSlider(obj); } else if (Std.isOfType(obj, TransformConstraint)) { - writeTransformConstraint(cast(obj, TransformConstraint)); + writeTransformConstraint(obj); } else { throw new spine.SpineException("Unknown Update type"); } } - private function writeVertexAttachment(obj:VertexAttachment):Void { + private function writeVertexAttachment(obj:Dynamic):Void { if (Std.isOfType(obj, BoundingBoxAttachment)) { - writeBoundingBoxAttachment(cast(obj, BoundingBoxAttachment)); + writeBoundingBoxAttachment(obj); } else if (Std.isOfType(obj, ClippingAttachment)) { - writeClippingAttachment(cast(obj, ClippingAttachment)); + writeClippingAttachment(obj); } else if (Std.isOfType(obj, MeshAttachment)) { - writeMeshAttachment(cast(obj, MeshAttachment)); + writeMeshAttachment(obj); } else if (Std.isOfType(obj, PathAttachment)) { - writePathAttachment(cast(obj, PathAttachment)); + writePathAttachment(obj); } else { throw new spine.SpineException("Unknown VertexAttachment type"); } } + private function writeProperty(obj:Dynamic, javaGetter:String, propertyInfo:Dynamic):Void { + var value = getPropertyValue(obj, javaGetter); + + if (value == null) { + json.writeNull(); + return; + } + + switch (propertyInfo.kind) { + case "primitive": + json.writeValue(value); + + case "object": + var writeMethod = Reflect.field(this, propertyInfo.writeMethodCall); + if (writeMethod != null) { + Reflect.callMethod(this, writeMethod, [value]); + } else { + json.writeValue("<" + propertyInfo.valueType + ">"); + } + + case "enum": + // Handle enum-like classes with name property + if (Reflect.hasField(value, "name")) { + json.writeValue(Reflect.field(value, "name")); + } else { + // Fallback for actual Haxe enums + var enumValue = Type.enumConstructor(value); + json.writeValue(enumValue != null ? enumValue : "unknown"); + } + + case "array": + writeArray(value, propertyInfo); + + case "nestedArray": + writeNestedArray(value); + } + } + + private function writeArray(arr:Dynamic, propertyInfo:Dynamic):Void { + if (arr == null) { + json.writeNull(); + return; + } + + json.writeArrayStart(); + for (item in cast(arr, Array)) { + if (propertyInfo.elementKind == "primitive") { + json.writeValue(item); + } else if (propertyInfo.writeMethodCall != null) { + var writeMethod = Reflect.field(this, propertyInfo.writeMethodCall); + if (writeMethod != null) { + Reflect.callMethod(this, writeMethod, [item]); + } else { + json.writeValue(item); + } + } else { + json.writeValue(item); + } + } + json.writeArrayEnd(); + } + + private function writeNestedArray(arr:Dynamic):Void { + if (arr == null) { + json.writeNull(); + return; + } + + json.writeArrayStart(); + for (nestedArray in cast(arr, Array)) { + if (nestedArray == null) { + json.writeNull(); + } else { + json.writeArrayStart(); + for (elem in cast(nestedArray, Array)) { + json.writeValue(elem); + } + json.writeArrayEnd(); + } + } + json.writeArrayEnd(); + } + // Helper methods for special types - private function writeColor(obj:spine.Color):Void { + private function writeColor(obj:Dynamic):Void { if (obj == null) { json.writeNull(); - } else { - json.writeObjectStart(); - json.writeName("r"); - json.writeValue(obj.r); - json.writeName("g"); - json.writeValue(obj.g); - json.writeName("b"); - json.writeValue(obj.b); - json.writeName("a"); - json.writeValue(obj.a); - json.writeObjectEnd(); + return; } + json.writeObjectStart(); + json.writeName("r"); + json.writeValue(Reflect.field(obj, "r")); + json.writeName("g"); + json.writeValue(Reflect.field(obj, "g")); + json.writeName("b"); + json.writeValue(Reflect.field(obj, "b")); + json.writeName("a"); + json.writeValue(Reflect.field(obj, "a")); + json.writeObjectEnd(); } private function writeTextureRegion(obj:Dynamic):Void { - // TextureRegion serialization not implemented json.writeValue(""); } - private function writeFloatArray(arr:Array):Void { - if (arr == null) { + private function writeIntArray(obj:Dynamic):Void { + if (obj == null) { json.writeNull(); + return; + } + // IntArray in Java might be a custom type, try to get its array data + var items = getPropertyValue(obj, "getItems()"); + if (items != null) { + writeArray(items, {elementKind: "primitive"}); } else { - json.writeArrayStart(); - for (val in arr) { - json.writeValue(val); - } - json.writeArrayEnd(); + // Fallback: assume it's already an array + writeArray(obj, {elementKind: "primitive"}); } } - private function writeIntArray(arr:Array):Void { - if (arr == null) { + private function writeFloatArray(obj:Dynamic):Void { + if (obj == null) { json.writeNull(); + return; + } + // FloatArray in Java might be a custom type, try to get its array data + var items = getPropertyValue(obj, "getItems()"); + if (items != null) { + writeArray(items, {elementKind: "primitive"}); } else { - json.writeArrayStart(); - for (val in arr) { - json.writeValue(val); - } - json.writeArrayEnd(); + // Fallback: assume it's already an array + writeArray(obj, {elementKind: "primitive"}); } } - } \ No newline at end of file diff --git a/spine-haxe/tests/HeadlessTest.hx b/spine-haxe/tests/HeadlessTest.hx index 5566512da..1c3c8636e 100644 --- a/spine-haxe/tests/HeadlessTest.hx +++ b/spine-haxe/tests/HeadlessTest.hx @@ -12,96 +12,99 @@ import haxe.io.Bytes; // Mock texture loader that doesn't require actual texture loading class MockTextureLoader implements TextureLoader { - public function new() {} - - public function load(page:TextureAtlasPage, path:String):Void { - // Set mock dimensions - no actual texture loading needed - page.width = 1024; - page.height = 1024; - page.texture = {}; // Empty object as mock texture - } - - public function unload(texture:Dynamic):Void { - // Nothing to unload in headless mode - } + public function new() {} + + public function loadPage(page:TextureAtlasPage, path:String):Void { + // Set mock dimensions - no actual texture loading needed + page.width = 1024; + page.height = 1024; + page.texture = {}; // Empty object as mock texture + } + + public function loadRegion(region:spine.atlas.TextureAtlasRegion):Void { + // Nothing to do in headless mode + } + + public function unloadPage(page:TextureAtlasPage):Void { + // Nothing to unload in headless mode + } } class HeadlessTest { - static function main():Void { - var args = Sys.args(); - - if (args.length < 2) { - Sys.stderr().writeString("Usage: HeadlessTest [animation-name]\n"); - Sys.exit(1); - } - - var skeletonPath = args[0]; - var atlasPath = args[1]; - var animationName = args.length >= 3 ? args[2] : null; - - try { - // Load atlas with mock texture loader - var textureLoader = new MockTextureLoader(); - var atlasContent = File.getContent(atlasPath); - var atlas = new TextureAtlas(atlasContent, textureLoader); - - // Load skeleton data - var skeletonData:SkeletonData; - var attachmentLoader = new AtlasAttachmentLoader(atlas); - - if (StringTools.endsWith(skeletonPath, ".json")) { - var loader = new SkeletonJson(attachmentLoader); - var jsonContent = File.getContent(skeletonPath); - skeletonData = loader.readSkeletonData(jsonContent); - } else { - var loader = new SkeletonBinary(attachmentLoader); - var binaryContent = File.getBytes(skeletonPath); - skeletonData = loader.readSkeletonData(binaryContent); - } - - // Create serializer - var serializer = new SkeletonSerializer(); - - // Print skeleton data - Sys.println("=== SKELETON DATA ==="); - Sys.println(serializer.serializeSkeletonData(skeletonData)); - - // Create skeleton instance - var skeleton = new Skeleton(skeletonData); - - // Handle animation if provided - var state:AnimationState = null; - if (animationName != null) { - var stateData = new AnimationStateData(skeletonData); - state = new AnimationState(stateData); - - var animation = skeletonData.findAnimation(animationName); - if (animation == null) { - Sys.stderr().writeString('Animation not found: $animationName\n'); - Sys.exit(1); - } - - state.setAnimation(0, animation, true); - state.update(0.016); - state.apply(skeleton); - } - - // Update world transforms (following the pattern from other HeadlessTests) - skeleton.updateWorldTransform(Physics.update); - - // Print skeleton state - Sys.println("\n=== SKELETON STATE ==="); - Sys.println(serializer.serializeSkeleton(skeleton)); - - // Print animation state if present - if (state != null) { - Sys.println("\n=== ANIMATION STATE ==="); - Sys.println(serializer.serializeAnimationState(state)); - } - - } catch (e:Dynamic) { - Sys.stderr().writeString('Error: $e\n'); - Sys.exit(1); - } - } -} \ No newline at end of file + static function main():Void { + var args = Sys.args(); + + if (args.length < 2) { + Sys.stderr().writeString("Usage: HeadlessTest [animation-name]\n"); + Sys.exit(1); + } + + var skeletonPath = args[0]; + var atlasPath = args[1]; + var animationName = args.length >= 3 ? args[2] : null; + + try { + // Load atlas with mock texture loader + var textureLoader = new MockTextureLoader(); + var atlasContent = File.getContent(atlasPath); + var atlas = new TextureAtlas(atlasContent, textureLoader); + + // Load skeleton data + var skeletonData:SkeletonData; + var attachmentLoader = new AtlasAttachmentLoader(atlas); + + if (StringTools.endsWith(skeletonPath, ".json")) { + var loader = new SkeletonJson(attachmentLoader); + var jsonContent = File.getContent(skeletonPath); + skeletonData = loader.readSkeletonData(jsonContent); + } else { + var loader = new SkeletonBinary(attachmentLoader); + var binaryContent = File.getBytes(skeletonPath); + skeletonData = loader.readSkeletonData(binaryContent); + } + + // Create serializer + var serializer = new SkeletonSerializer(); + + // Print skeleton data + Sys.println("=== SKELETON DATA ==="); + Sys.println(serializer.serializeSkeletonData(skeletonData)); + + // Create skeleton instance + var skeleton = new Skeleton(skeletonData); + + // Handle animation if provided + var state:AnimationState = null; + if (animationName != null) { + var stateData = new AnimationStateData(skeletonData); + state = new AnimationState(stateData); + + var animation = skeletonData.findAnimation(animationName); + if (animation == null) { + Sys.stderr().writeString('Animation not found: $animationName\n'); + Sys.exit(1); + } + + state.setAnimation(0, animation, true); + state.update(0.016); + state.apply(skeleton); + } + + // Update world transforms (following the pattern from other HeadlessTests) + skeleton.updateWorldTransform(Physics.update); + + // Print skeleton state + Sys.println("\n=== SKELETON STATE ==="); + Sys.println(serializer.serializeSkeleton(skeleton)); + + // Print animation state if present + if (state != null) { + Sys.println("\n=== ANIMATION STATE ==="); + Sys.println(serializer.serializeAnimationState(state)); + } + } catch (e:Dynamic) { + Sys.stderr().writeString('Error: $e\n'); + Sys.exit(1); + } + } +} diff --git a/tests/haxe-serializer.md b/tests/haxe-serializer.md index f42ad613f..3dc603d7b 100644 --- a/tests/haxe-serializer.md +++ b/tests/haxe-serializer.md @@ -212,125 +212,122 @@ When implementing the Haxe serializer generator, these patterns should be applie --- -# Haxe Serializer Generator Implementation Plan +# Revised Implementation Plan: Reflection-Based Haxe Serializer -Based on the comprehensive pattern analysis above, here's the implementation plan for a new Haxe serializer generator: +## Key Insight -## Architecture Overview +Instead of maintaining complex mapping tables, we can leverage Haxe's dynamic reflection capabilities to automatically resolve field vs method access at runtime. -The new generator will use a **rule-based transformation system** with the following components: +## Simplified Architecture -1. **Mapping Database**: Load java-haxe-diff.md mappings into a structured lookup table -2. **Context-Aware Transformer**: Apply transformations based on class context -3. **Type System**: Handle Java-to-Haxe type conversions -4. **Code Generator**: Produce clean, idiomatic Haxe code +### Core Approach: Runtime Property Resolution + +```haxe +private function getPropertyValue(obj:Dynamic, javaGetter:String):Dynamic { + // Extract property name from Java getter + var propName = extractPropertyName(javaGetter); // getName() → "name" + + // 1. Try direct field access first (most common case) + if (Reflect.hasField(obj, propName)) { + return Reflect.field(obj, propName); + } + + // 2. Try special field variations + var specialNames = getSpecialFieldNames(javaGetter, propName); + for (name in specialNames) { + if (Reflect.hasField(obj, name)) { + return Reflect.field(obj, name); + } + } + + // 3. Try method access (for computed properties) + if (Reflect.hasField(obj, javaGetter.replace("()", ""))) { + return Reflect.callMethod(obj, Reflect.field(obj, javaGetter.replace("()", "")), []); + } + + // 4. Handle property syntax (get, never) + // This would need special handling or we just access the underlying getter + + throw 'Property ${javaGetter} not found on object'; +} +``` + +### Special Name Mappings + +Based on the pattern analysis, we only need to handle these special cases: + +```haxe +private function getSpecialFieldNames(javaGetter:String, defaultName:String):Array { + return switch(javaGetter) { + case "getInt()": ["intValue"]; + case "getFloat()": ["floatValue"]; + case "getString()": ["stringValue"]; + case "getPhysicsConstraints()": ["physics"]; + case "getUpdateCache()": ["_updateCache"]; + case "getSetupPose()": ["setup"]; + case "getAppliedPose()": ["applied"]; + default: []; + } +} +``` ## Implementation Steps -### Phase 1: Build Mapping Infrastructure +### Phase 1: Core Reflection System +1. Implement `getPropertyValue` with fallback chain +2. Handle special field name mappings +3. Test with known edge cases -1. **Parse java-haxe-diff.md** - - Extract all type mappings into a structured format - - Create lookup table: `Map>` - - Store mapping type (field, method, property) and Haxe type info - -2. **Create Transformation Rules Engine** - - Rule priority system (specific → general) - - Context-aware lookups (class + getter combination) - - Fallback to general patterns - -### Phase 2: Implement Core Transformations - -1. **Getter-to-Field Transformer** - - Check mapping database first - - Apply general pattern: `getX()` → `x` - - Handle special cases (getInt → intValue, etc.) - -2. **Type Transformer** - - Java primitives → Haxe types - - Array handling (including nested arrays) - - Generic type resolution - -3. **Access Pattern Resolver** - - Determine if result is field access or method call - - Handle property syntax `name(get, never)` - - Preserve method calls where needed +### Phase 2: Type Handling +1. Keep existing Java → Haxe type transformations +2. Use `Dynamic` for runtime resolution +3. Cast results when needed for type safety ### Phase 3: Code Generation +1. Generate simpler code using reflection helpers +2. No need for complex getter-to-field mappings +3. Handle enums with runtime type checking -1. **Property Code Generator** - - Generate correct Haxe syntax based on mapping type - - Handle nullable types properly - - Generate enum switch statements with correct Haxe enum syntax +## Advantages -2. **Method Generator** - - Handle abstract types with `Std.isOfType` - - Generate proper casting syntax - - Implement special methods (writeSkin, writeSkinEntry) +1. **Simplicity**: No need to parse mapping files or maintain lookup tables +2. **Robustness**: Automatically handles API changes +3. **Correctness**: Runtime resolution ensures we get the right value +4. **Maintainability**: Minimal special cases to maintain -### Phase 4: Validation and Testing +## Trade-offs -1. **Compile-time Validation** - - Generate code and attempt Haxe compilation - - Report type errors with context +1. **Performance**: Reflection is slower than direct access (acceptable for serialization) +2. **Type Safety**: Less compile-time checking (mitigated by runtime tests) +3. **Debugging**: Harder to trace field access (can add logging) -2. **Runtime Testing** - - Compare serialization output with Java reference - - Ensure all fields are properly serialized +## Example Generated Code -## Key Design Decisions - -1. **Data-Driven Approach**: Use the mapping file as the source of truth rather than hardcoded rules -2. **Explicit Over Implicit**: When in doubt, use the exact mapping from java-haxe-diff.md -3. **Fail-Fast**: If a mapping is missing or ambiguous, fail with a clear error message -4. **Type Safety**: Leverage Haxe's type system to catch errors at compile time - -## Implementation Details - -### Mapping Database Structure -```typescript -interface HaxeMapping { - kind: 'field' | 'method' | 'property'; - haxeName: string; - haxeType: string; - propertyGetter?: string; // for (get, never) syntax -} - -interface ClassMappings { - className: string; - getters: Map; +```haxe +private function writeAnimation(obj:Animation):Void { + // ... cycle detection ... + + json.writeObjectStart(); + json.writeName("type"); + json.writeValue("Animation"); + + // Use reflection for all properties + json.writeName("timelines"); + writeArray(getPropertyValue(obj, "getTimelines()"), writeTimeline); + + json.writeName("duration"); + json.writeValue(getPropertyValue(obj, "getDuration()")); + + json.writeName("bones"); + writeIntArray(getPropertyValue(obj, "getBones()")); + + json.writeName("name"); + json.writeValue(getPropertyValue(obj, "getName()")); + + json.writeObjectEnd(); } ``` -### Transformation Algorithm -``` -1. Load all mappings from java-haxe-diff.md -2. For each property in IR: - a. Look up exact class + getter combination - b. If not found, check for class-level patterns - c. If not found, apply general transformation rules - d. Transform type from Java to Haxe - e. Generate appropriate access code -``` +## Summary -### Special Handling - -1. **Timeline Classes**: All timeline getters follow consistent patterns -2. **Constraint Classes**: Handle getData/getPose/getAppliedPose consistently -3. **Array Properties**: Detect 1D vs 2D arrays based on context -4. **Enum Values**: Generate proper Haxe enum access syntax -5. **Circular References**: Maintain visitedObjects tracking - -## Error Handling - -1. **Missing Mappings**: Log unmapped getters with class context -2. **Type Mismatches**: Detect and report Java/Haxe type incompatibilities -3. **Compilation Errors**: Capture and display Haxe compiler output - -## Testing Strategy - -1. **Unit Tests**: Test individual transformation rules -2. **Integration Tests**: Generate full serializer and compile -3. **Snapshot Tests**: Compare output with reference implementation - -This approach ensures accuracy, maintainability, and extensibility while leveraging the comprehensive mapping data we've collected. \ No newline at end of file +This reflection-based approach eliminates the complexity of maintaining mapping tables while preserving correctness. The patterns we analyzed show that most getters follow predictable conventions, with only a handful of special cases that can be handled with a simple switch statement. \ No newline at end of file diff --git a/tests/package-lock.json b/tests/package-lock.json index efec99714..1c1176929 100644 --- a/tests/package-lock.json +++ b/tests/package-lock.json @@ -16,9 +16,9 @@ } }, "node_modules/@biomejs/biome": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.1.2.tgz", - "integrity": "sha512-yq8ZZuKuBVDgAS76LWCfFKHSYIAgqkxVB3mGVVpOe2vSkUTs7xG46zXZeNPRNVjiJuw0SZ3+J2rXiYx0RUpfGg==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.1.3.tgz", + "integrity": "sha512-KE/tegvJIxTkl7gJbGWSgun7G6X/n2M6C35COT6ctYrAy7SiPyNvi6JtoQERVK/VRbttZfgGq96j2bFmhmnH4w==", "dev": true, "license": "MIT OR Apache-2.0", "bin": { @@ -32,20 +32,20 @@ "url": "https://opencollective.com/biome" }, "optionalDependencies": { - "@biomejs/cli-darwin-arm64": "2.1.2", - "@biomejs/cli-darwin-x64": "2.1.2", - "@biomejs/cli-linux-arm64": "2.1.2", - "@biomejs/cli-linux-arm64-musl": "2.1.2", - "@biomejs/cli-linux-x64": "2.1.2", - "@biomejs/cli-linux-x64-musl": "2.1.2", - "@biomejs/cli-win32-arm64": "2.1.2", - "@biomejs/cli-win32-x64": "2.1.2" + "@biomejs/cli-darwin-arm64": "2.1.3", + "@biomejs/cli-darwin-x64": "2.1.3", + "@biomejs/cli-linux-arm64": "2.1.3", + "@biomejs/cli-linux-arm64-musl": "2.1.3", + "@biomejs/cli-linux-x64": "2.1.3", + "@biomejs/cli-linux-x64-musl": "2.1.3", + "@biomejs/cli-win32-arm64": "2.1.3", + "@biomejs/cli-win32-x64": "2.1.3" } }, "node_modules/@biomejs/cli-darwin-arm64": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.1.2.tgz", - "integrity": "sha512-leFAks64PEIjc7MY/cLjE8u5OcfBKkcDB0szxsWUB4aDfemBep1WVKt0qrEyqZBOW8LPHzrFMyDl3FhuuA0E7g==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.1.3.tgz", + "integrity": "sha512-LFLkSWRoSGS1wVUD/BE6Nlt2dSn0ulH3XImzg2O/36BoToJHKXjSxzPEMAqT9QvwVtk7/9AQhZpTneERU9qaXA==", "cpu": [ "arm64" ], @@ -60,9 +60,9 @@ } }, "node_modules/@biomejs/cli-darwin-x64": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.1.2.tgz", - "integrity": "sha512-Nmmv7wRX5Nj7lGmz0FjnWdflJg4zii8Ivruas6PBKzw5SJX/q+Zh2RfnO+bBnuKLXpj8kiI2x2X12otpH6a32A==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.1.3.tgz", + "integrity": "sha512-Q/4OTw8P9No9QeowyxswcWdm0n2MsdCwWcc5NcKQQvzwPjwuPdf8dpPPf4r+x0RWKBtl1FLiAUtJvBlri6DnYw==", "cpu": [ "x64" ], @@ -77,9 +77,9 @@ } }, "node_modules/@biomejs/cli-linux-arm64": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.1.2.tgz", - "integrity": "sha512-NWNy2Diocav61HZiv2enTQykbPP/KrA/baS7JsLSojC7Xxh2nl9IczuvE5UID7+ksRy2e7yH7klm/WkA72G1dw==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.1.3.tgz", + "integrity": "sha512-2hS6LgylRqMFmAZCOFwYrf77QMdUwJp49oe8PX/O8+P2yKZMSpyQTf3Eo5ewnsMFUEmYbPOskafdV1ds1MZMJA==", "cpu": [ "arm64" ], @@ -94,9 +94,9 @@ } }, "node_modules/@biomejs/cli-linux-arm64-musl": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.1.2.tgz", - "integrity": "sha512-qgHvafhjH7Oca114FdOScmIKf1DlXT1LqbOrrbR30kQDLFPEOpBG0uzx6MhmsrmhGiCFCr2obDamu+czk+X0HQ==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.1.3.tgz", + "integrity": "sha512-KXouFSBnoxAWZYDQrnNRzZBbt5s9UJkIm40hdvSL9mBxSSoxRFQJbtg1hP3aa8A2SnXyQHxQfpiVeJlczZt76w==", "cpu": [ "arm64" ], @@ -111,9 +111,9 @@ } }, "node_modules/@biomejs/cli-linux-x64": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.1.2.tgz", - "integrity": "sha512-Km/UYeVowygTjpX6sGBzlizjakLoMQkxWbruVZSNE6osuSI63i4uCeIL+6q2AJlD3dxoiBJX70dn1enjQnQqwA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.1.3.tgz", + "integrity": "sha512-NxlSCBhLvQtWGagEztfAZ4WcE1AkMTntZV65ZvR+J9jp06+EtOYEBPQndA70ZGhHbEDG57bR6uNvqkd1WrEYVA==", "cpu": [ "x64" ], @@ -128,9 +128,9 @@ } }, "node_modules/@biomejs/cli-linux-x64-musl": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.1.2.tgz", - "integrity": "sha512-xlB3mU14ZUa3wzLtXfmk2IMOGL+S0aHFhSix/nssWS/2XlD27q+S6f0dlQ8WOCbYoXcuz8BCM7rCn2lxdTrlQA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.1.3.tgz", + "integrity": "sha512-KaLAxnROouzIWtl6a0Y88r/4hW5oDUJTIqQorOTVQITaKQsKjZX4XCUmHIhdEk8zMnaiLZzRTAwk1yIAl+mIew==", "cpu": [ "x64" ], @@ -145,9 +145,9 @@ } }, "node_modules/@biomejs/cli-win32-arm64": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.1.2.tgz", - "integrity": "sha512-G8KWZli5ASOXA3yUQgx+M4pZRv3ND16h77UsdunUL17uYpcL/UC7RkWTdkfvMQvogVsAuz5JUcBDjgZHXxlKoA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.1.3.tgz", + "integrity": "sha512-V9CUZCtWH4u0YwyCYbQ3W5F4ZGPWp2C2TYcsiWFNNyRfmOW1j/TY/jAurl33SaRjgZPO5UUhGyr9m6BN9t84NQ==", "cpu": [ "arm64" ], @@ -162,9 +162,9 @@ } }, "node_modules/@biomejs/cli-win32-x64": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.1.2.tgz", - "integrity": "sha512-9zajnk59PMpjBkty3bK2IrjUsUHvqe9HWwyAWQBjGLE7MIBjbX2vwv1XPEhmO2RRuGoTkVx3WCanHrjAytICLA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.1.3.tgz", + "integrity": "sha512-dxy599q6lgp8ANPpR8sDMscwdp9oOumEsVXuVCVT9N2vAho8uYXlCz53JhxX6LtJOXaE73qzgkGQ7QqvFlMC0g==", "cpu": [ "x64" ], diff --git a/tests/src/generate-haxe-serializer.ts b/tests/src/generate-haxe-serializer.ts index f9a827f9e..83ea20c3e 100644 --- a/tests/src/generate-haxe-serializer.ts +++ b/tests/src/generate-haxe-serializer.ts @@ -8,385 +8,433 @@ import type { Property, SerializerIR } from './types'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -function transformType(javaType: string): string { - // Java → Haxe type mappings - const primitiveMap: Record = { - 'String': 'String', - 'int': 'Int', - 'float': 'Float', - 'boolean': 'Bool', - 'short': 'Int', - 'byte': 'Int', - 'double': 'Float', - 'long': 'Int' - }; +function transformType (javaType: string): string { + // Java → Haxe type mappings + const primitiveMap: Record = { + 'String': 'String', + 'int': 'Int', + 'float': 'Float', + 'boolean': 'Bool', + 'short': 'Int', + 'byte': 'Int', + 'double': 'Float', + 'long': 'Int' + }; - // Remove package prefixes and map primitives - const simpleName = javaType.includes('.') ? javaType.split('.').pop()! : javaType; - - if (primitiveMap[simpleName]) { - return primitiveMap[simpleName]; - } + // Remove package prefixes and map primitives + const simpleName = javaType.includes('.') ? javaType.split('.').pop()! : javaType; - // Handle arrays: Java T[] → Haxe Array - if (simpleName.endsWith('[]')) { - const baseType = simpleName.slice(0, -2); - return `Array<${transformType(baseType)}>`; - } + if (primitiveMap[simpleName]) { + return primitiveMap[simpleName]; + } - // Java Array stays Array in Haxe - if (simpleName.startsWith('Array<')) { - return simpleName; - } + // Handle arrays: Java T[] → Haxe Array + if (simpleName.endsWith('[]')) { + const baseType = simpleName.slice(0, -2); + return `Array<${transformType(baseType)}>`; + } - // Handle special generic types - if (simpleName === 'Constraint') { - return 'Constraint'; // Use Any for generic parameters - } - if (simpleName === 'ConstraintData') { - return 'ConstraintData'; // Use Any for generic parameters - } + // Java Array stays Array in Haxe + if (simpleName.startsWith('Array<')) { + const match = simpleName.match(/Array<(.+)>/); + if (match) { + return `Array<${transformType(match[1])}>`; + } + } - // Object types: keep class name, remove package - return simpleName; + // Handle special generic types + if (simpleName === 'Constraint') { + return 'Constraint'; + } + if (simpleName === 'ConstraintData') { + return 'ConstraintData'; + } + + // Handle TransformConstraintData inner classes + if (['FromProperty', 'FromRotate', 'FromScaleX', 'FromScaleY', 'FromShearY', 'FromX', 'FromY', + 'ToProperty', 'ToRotate', 'ToScaleX', 'ToScaleY', 'ToShearY', 'ToX', 'ToY'].includes(simpleName)) { + return 'spine.TransformConstraintData.' + simpleName; + } + + // Object types: keep class name, remove package + return simpleName; } -function mapJavaGetterToHaxeField(javaGetter: string, objName: string): string { - // Map Java getter methods to Haxe field access - // Based on analysis of existing Haxe classes in spine-haxe/spine-haxe/spine/ - - if (javaGetter.endsWith('()')) { - const methodName = javaGetter.slice(0, -2); - - // Remove get/is prefix and convert to camelCase field - if (methodName.startsWith('get')) { - const fieldName = methodName.slice(3); - const haxeField = fieldName.charAt(0).toLowerCase() + fieldName.slice(1); - return `${objName}.${haxeField}`; - } - - if (methodName.startsWith('is')) { - const fieldName = methodName.slice(2); - const haxeField = fieldName.charAt(0).toLowerCase() + fieldName.slice(1); - return `${objName}.${haxeField}`; - } - - // Some methods might be direct field names - return `${objName}.${methodName}`; - } - - // Direct field access (already in correct format) - return `${objName}.${javaGetter}`; +function generateReflectionBasedHaxe (ir: SerializerIR): string { + const lines: string[] = []; + + // File header + lines.push('package spine.utils;'); + lines.push(''); + lines.push('import haxe.ds.ObjectMap;'); + lines.push('import spine.*;'); + lines.push('import spine.animation.*;'); + lines.push('import spine.attachments.*;'); + lines.push(''); + lines.push('class SkeletonSerializer {'); + lines.push(' private var visitedObjects:ObjectMap = new ObjectMap();'); + lines.push(' private var nextId:Int = 1;'); + lines.push(' private var json:JsonWriter;'); + lines.push(''); + lines.push(' public function new() {}'); + lines.push(''); + + // Generate public methods + for (const method of ir.publicMethods) { + const haxeParamType = transformType(method.paramType); + lines.push(` public function ${method.name}(${method.paramName}:${haxeParamType}):String {`); + lines.push(' visitedObjects = new ObjectMap();'); + lines.push(' nextId = 1;'); + lines.push(' json = new JsonWriter();'); + lines.push(` ${method.writeMethodCall}(${method.paramName});`); + lines.push(' return json.getString();'); + lines.push(' }'); + lines.push(''); + } + + // Core reflection helper methods + lines.push(' // Core reflection helpers'); + lines.push(' private function extractPropertyName(javaGetter:String):String {'); + lines.push(' var getter = javaGetter;'); + lines.push(' if (getter.indexOf("()") != -1) getter = getter.substr(0, getter.length - 2);'); + lines.push(' '); + lines.push(' if (getter.substr(0, 3) == "get") {'); + lines.push(' var prop = getter.substr(3);'); + lines.push(' return prop.charAt(0).toLowerCase() + prop.substr(1);'); + lines.push(' }'); + lines.push(' if (getter.substr(0, 2) == "is") {'); + lines.push(' var prop = getter.substr(2);'); + lines.push(' return prop.charAt(0).toLowerCase() + prop.substr(1);'); + lines.push(' }'); + lines.push(' return getter;'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function getSpecialFieldNames(javaGetter:String):Array {'); + lines.push(' return switch(javaGetter) {'); + lines.push(' case "getInt()": ["intValue"];'); + lines.push(' case "getFloat()": ["floatValue"];'); + lines.push(' case "getString()": ["stringValue"];'); + lines.push(' case "getPhysicsConstraints()": ["physics"];'); + lines.push(' case "getUpdateCache()": ["_updateCache"];'); + lines.push(' case "getSetupPose()": ["setup"];'); + lines.push(' case "getAppliedPose()": ["applied"];'); + lines.push(' default: [];'); + lines.push(' }'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function getPropertyValue(obj:Dynamic, javaGetter:String):Dynamic {'); + lines.push(' var propName = extractPropertyName(javaGetter);'); + lines.push(' '); + lines.push(' // Try direct field access first'); + lines.push(' if (Reflect.hasField(obj, propName)) {'); + lines.push(' return Reflect.field(obj, propName);'); + lines.push(' }'); + lines.push(' '); + lines.push(' // Try special field variations'); + lines.push(' var specialNames = getSpecialFieldNames(javaGetter);'); + lines.push(' for (name in specialNames) {'); + lines.push(' if (Reflect.hasField(obj, name)) {'); + lines.push(' return Reflect.field(obj, name);'); + lines.push(' }'); + lines.push(' }'); + lines.push(' '); + lines.push(' // Try method access (remove parentheses)'); + lines.push(' var methodName = javaGetter;'); + lines.push(' if (methodName.indexOf("()") != -1) {'); + lines.push(' methodName = methodName.substr(0, methodName.length - 2);'); + lines.push(' }'); + lines.push(' if (Reflect.hasField(obj, methodName)) {'); + lines.push(' var method = Reflect.field(obj, methodName);'); + lines.push(' if (Reflect.isFunction(method)) {'); + lines.push(' return Reflect.callMethod(obj, method, []);'); + lines.push(' }'); + lines.push(' }'); + lines.push(' '); + lines.push(' // Last resort: return null and let the caller handle it'); + lines.push(' return null;'); + lines.push(' }'); + lines.push(''); + + // Generate write methods + for (const method of ir.writeMethods) { + const shortName = method.paramType.split('.').pop(); + const haxeType = transformType(method.paramType); + + lines.push(` private function ${method.name}(obj:Dynamic):Void {`); + + if (method.isAbstractType) { + // Handle abstract types with Std.isOfType chain + if (method.subtypeChecks && method.subtypeChecks.length > 0) { + let first = true; + for (const subtype of method.subtypeChecks) { + const subtypeHaxeName = transformType(subtype.typeName); + + if (first) { + lines.push(` if (Std.isOfType(obj, ${subtypeHaxeName})) {`); + first = false; + } else { + lines.push(` } else if (Std.isOfType(obj, ${subtypeHaxeName})) {`); + } + lines.push(` ${subtype.writeMethodCall}(obj);`); + } + lines.push(' } else {'); + lines.push(` throw new spine.SpineException("Unknown ${shortName} type");`); + lines.push(' }'); + } else { + lines.push(' json.writeNull(); // No concrete implementations'); + } + } else { + // Handle concrete types + lines.push(' if (visitedObjects.exists(obj)) {'); + lines.push(' json.writeValue(visitedObjects.get(obj));'); + lines.push(' return;'); + lines.push(' }'); + lines.push(''); + + // Generate reference string + const hasNameProperty = method.properties.some(p => + p.name === 'name' && p.valueType === 'String' + ); + + if (hasNameProperty) { + lines.push(' var nameValue = getPropertyValue(obj, "getName()");'); + lines.push(` var refString = nameValue != null ? "<${shortName}-" + nameValue + ">" : "<${shortName}-" + nextId++ + ">";`); + } else { + lines.push(` var refString = "<${shortName}-" + nextId++ + ">";`); + } + + lines.push(' visitedObjects.set(obj, refString);'); + lines.push(''); + lines.push(' json.writeObjectStart();'); + lines.push(' json.writeName("refString");'); + lines.push(' json.writeValue(refString);'); + lines.push(' json.writeName("type");'); + lines.push(` json.writeValue("${shortName}");`); + + // Write properties using reflection + for (const property of method.properties) { + lines.push(''); + lines.push(` json.writeName("${property.name}");`); + lines.push(` writeProperty(obj, "${property.getter}", ${JSON.stringify(property)});`); + } + + lines.push(''); + lines.push(' json.writeObjectEnd();'); + } + + lines.push(' }'); + lines.push(''); + } + + // Generic property writer using reflection + lines.push(' private function writeProperty(obj:Dynamic, javaGetter:String, propertyInfo:Dynamic):Void {'); + lines.push(' var value = getPropertyValue(obj, javaGetter);'); + lines.push(' '); + lines.push(' if (value == null) {'); + lines.push(' json.writeNull();'); + lines.push(' return;'); + lines.push(' }'); + lines.push(' '); + lines.push(' switch (propertyInfo.kind) {'); + lines.push(' case "primitive":'); + lines.push(' json.writeValue(value);'); + lines.push(' '); + lines.push(' case "object":'); + lines.push(' var writeMethod = Reflect.field(this, propertyInfo.writeMethodCall);'); + lines.push(' if (writeMethod != null) {'); + lines.push(' Reflect.callMethod(this, writeMethod, [value]);'); + lines.push(' } else {'); + lines.push(' json.writeValue("<" + propertyInfo.valueType + ">");'); + lines.push(' }'); + lines.push(' '); + lines.push(' case "enum":'); + lines.push(' // Handle enum-like classes with name property'); + lines.push(' if (Reflect.hasField(value, "name")) {'); + lines.push(' json.writeValue(Reflect.field(value, "name"));'); + lines.push(' } else {'); + lines.push(' // Fallback for actual Haxe enums'); + lines.push(' var enumValue = Type.enumConstructor(value);'); + lines.push(' json.writeValue(enumValue != null ? enumValue : "unknown");'); + lines.push(' }'); + lines.push(' '); + lines.push(' case "array":'); + lines.push(' writeArray(value, propertyInfo);'); + lines.push(' '); + lines.push(' case "nestedArray":'); + lines.push(' writeNestedArray(value);'); + lines.push(' }'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function writeArray(arr:Dynamic, propertyInfo:Dynamic):Void {'); + lines.push(' if (arr == null) {'); + lines.push(' json.writeNull();'); + lines.push(' return;'); + lines.push(' }'); + lines.push(' '); + lines.push(' json.writeArrayStart();'); + lines.push(' for (item in cast(arr, Array)) {'); + lines.push(' if (propertyInfo.elementKind == "primitive") {'); + lines.push(' json.writeValue(item);'); + lines.push(' } else if (propertyInfo.writeMethodCall != null) {'); + lines.push(' var writeMethod = Reflect.field(this, propertyInfo.writeMethodCall);'); + lines.push(' if (writeMethod != null) {'); + lines.push(' Reflect.callMethod(this, writeMethod, [item]);'); + lines.push(' } else {'); + lines.push(' json.writeValue(item);'); + lines.push(' }'); + lines.push(' } else {'); + lines.push(' json.writeValue(item);'); + lines.push(' }'); + lines.push(' }'); + lines.push(' json.writeArrayEnd();'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function writeNestedArray(arr:Dynamic):Void {'); + lines.push(' if (arr == null) {'); + lines.push(' json.writeNull();'); + lines.push(' return;'); + lines.push(' }'); + lines.push(' '); + lines.push(' json.writeArrayStart();'); + lines.push(' for (nestedArray in cast(arr, Array)) {'); + lines.push(' if (nestedArray == null) {'); + lines.push(' json.writeNull();'); + lines.push(' } else {'); + lines.push(' json.writeArrayStart();'); + lines.push(' for (elem in cast(nestedArray, Array)) {'); + lines.push(' json.writeValue(elem);'); + lines.push(' }'); + lines.push(' json.writeArrayEnd();'); + lines.push(' }'); + lines.push(' }'); + lines.push(' json.writeArrayEnd();'); + lines.push(' }'); + lines.push(''); + + // Special type helpers + lines.push(' // Helper methods for special types'); + lines.push(' private function writeColor(obj:Dynamic):Void {'); + lines.push(' if (obj == null) {'); + lines.push(' json.writeNull();'); + lines.push(' return;'); + lines.push(' }'); + lines.push(' json.writeObjectStart();'); + lines.push(' json.writeName("r");'); + lines.push(' json.writeValue(Reflect.field(obj, "r"));'); + lines.push(' json.writeName("g");'); + lines.push(' json.writeValue(Reflect.field(obj, "g"));'); + lines.push(' json.writeName("b");'); + lines.push(' json.writeValue(Reflect.field(obj, "b"));'); + lines.push(' json.writeName("a");'); + lines.push(' json.writeValue(Reflect.field(obj, "a"));'); + lines.push(' json.writeObjectEnd();'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function writeTextureRegion(obj:Dynamic):Void {'); + lines.push(' json.writeValue("");'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function writeIntArray(obj:Dynamic):Void {'); + lines.push(' if (obj == null) {'); + lines.push(' json.writeNull();'); + lines.push(' return;'); + lines.push(' }'); + lines.push(' // IntArray in Java might be a custom type, try to get its array data'); + lines.push(' var items = getPropertyValue(obj, "getItems()");'); + lines.push(' if (items != null) {'); + lines.push(' writeArray(items, {elementKind: "primitive"});'); + lines.push(' } else {'); + lines.push(' // Fallback: assume it\'s already an array'); + lines.push(' writeArray(obj, {elementKind: "primitive"});'); + lines.push(' }'); + lines.push(' }'); + lines.push(''); + + lines.push(' private function writeFloatArray(obj:Dynamic):Void {'); + lines.push(' if (obj == null) {'); + lines.push(' json.writeNull();'); + lines.push(' return;'); + lines.push(' }'); + lines.push(' // FloatArray in Java might be a custom type, try to get its array data'); + lines.push(' var items = getPropertyValue(obj, "getItems()");'); + lines.push(' if (items != null) {'); + lines.push(' writeArray(items, {elementKind: "primitive"});'); + lines.push(' } else {'); + lines.push(' // Fallback: assume it\'s already an array'); + lines.push(' writeArray(obj, {elementKind: "primitive"});'); + lines.push(' }'); + lines.push(' }'); + + lines.push('}'); + + return lines.join('\n'); } -function generatePropertyCode(property: Property, indent: string, enumMappings: { [enumName: string]: { [javaValue: string]: string } }): string[] { - const lines: string[] = []; - const accessor = mapJavaGetterToHaxeField(property.getter, 'obj'); +async function validateGeneratedHaxeCode (haxeCode: string, outputPath: string): Promise { + // Write code to file + fs.writeFileSync(outputPath, haxeCode); - switch (property.kind) { - case "primitive": - lines.push(`${indent}json.writeValue(${accessor});`); - break; + try { + // Basic syntax validation + execSync('haxe -cp spine-haxe --no-output -main spine.utils.JsonWriter', { + cwd: path.resolve(__dirname, '../../spine-haxe'), + stdio: 'pipe' + }); - case "object": - if (property.isNullable) { - lines.push(`${indent}if (${accessor} == null) {`); - lines.push(`${indent} json.writeNull();`); - lines.push(`${indent}} else {`); - lines.push(`${indent} ${property.writeMethodCall}(${accessor});`); - lines.push(`${indent}}`); - } else { - lines.push(`${indent}${property.writeMethodCall}(${accessor});`); - } - break; + console.log('✓ Generated Haxe serializer syntax validates successfully'); - case "enum": { - const enumName = property.enumName; - const enumMap = enumMappings[enumName]; - - if (property.isNullable) { - lines.push(`${indent}if (${accessor} == null) {`); - lines.push(`${indent} json.writeNull();`); - lines.push(`${indent}} else {`); - } - - if (enumMap && Object.keys(enumMap).length > 0) { - // Generate switch statement for enum mapping - lines.push(`${indent}${property.isNullable ? ' ' : ''}switch (${accessor}) {`); - - for (const [javaValue, haxeValue] of Object.entries(enumMap)) { - lines.push(`${indent}${property.isNullable ? ' ' : ''} case ${haxeValue}: json.writeValue("${javaValue}");`); - } - - lines.push(`${indent}${property.isNullable ? ' ' : ''} default: json.writeValue("unknown");`); - lines.push(`${indent}${property.isNullable ? ' ' : ''}}`); - } else { - // Fallback using Type.enumConstructor or similar - lines.push(`${indent}${property.isNullable ? ' ' : ''}json.writeValue(Type.enumConstructor(${accessor}));`); - } - - if (property.isNullable) { - lines.push(`${indent}}`); - } - break; - } - - case "array": { - if (property.isNullable) { - lines.push(`${indent}if (${accessor} == null) {`); - lines.push(`${indent} json.writeNull();`); - lines.push(`${indent}} else {`); - lines.push(`${indent} json.writeArrayStart();`); - lines.push(`${indent} for (item in ${accessor}) {`); - } else { - lines.push(`${indent}json.writeArrayStart();`); - lines.push(`${indent}for (item in ${accessor}) {`); - } - - const itemIndent = property.isNullable ? `${indent} ` : `${indent} `; - if (property.elementKind === "primitive") { - lines.push(`${itemIndent}json.writeValue(item);`); - } else { - lines.push(`${itemIndent}${property.writeMethodCall}(item);`); - } - - if (property.isNullable) { - lines.push(`${indent} }`); - lines.push(`${indent} json.writeArrayEnd();`); - lines.push(`${indent}}`); - } else { - lines.push(`${indent}}`); - lines.push(`${indent}json.writeArrayEnd();`); - } - break; - } - - case "nestedArray": { - if (property.isNullable) { - lines.push(`${indent}if (${accessor} == null) {`); - lines.push(`${indent} json.writeNull();`); - lines.push(`${indent}} else {`); - } - - const outerIndent = property.isNullable ? `${indent} ` : indent; - lines.push(`${outerIndent}json.writeArrayStart();`); - lines.push(`${outerIndent}for (nestedArray in ${accessor}) {`); - lines.push(`${outerIndent} if (nestedArray == null) {`); - lines.push(`${outerIndent} json.writeNull();`); - lines.push(`${outerIndent} } else {`); - lines.push(`${outerIndent} json.writeArrayStart();`); - lines.push(`${outerIndent} for (elem in nestedArray) {`); - lines.push(`${outerIndent} json.writeValue(elem);`); - lines.push(`${outerIndent} }`); - lines.push(`${outerIndent} json.writeArrayEnd();`); - lines.push(`${outerIndent} }`); - lines.push(`${outerIndent}}`); - lines.push(`${outerIndent}json.writeArrayEnd();`); - - if (property.isNullable) { - lines.push(`${indent}}`); - } - break; - } - } - - return lines; + } catch (error: any) { + console.log('⚠ Haxe serializer validation had issues (may still work):'); + console.log(error.message.split('\n').slice(0, 3).join('\n')); + } } -function generateHaxeFromIR(ir: SerializerIR): string { - const haxeOutput: string[] = []; +async function main (): Promise { + try { + // Read the IR file + const irFile = path.resolve(__dirname, '../output/serializer-ir.json'); + if (!fs.existsSync(irFile)) { + console.error('Serializer IR not found. Run generate-serializer-ir.ts first.'); + process.exit(1); + } - // Generate Haxe file header - haxeOutput.push('package spine.utils;'); - haxeOutput.push(''); - haxeOutput.push('import haxe.ds.StringMap;'); - haxeOutput.push('import spine.*;'); - haxeOutput.push('import spine.animation.*;'); - haxeOutput.push('import spine.attachments.*;'); - haxeOutput.push(''); - haxeOutput.push('class SkeletonSerializer {'); - haxeOutput.push(' private var visitedObjects:StringMap = new StringMap();'); - haxeOutput.push(' private var nextId:Int = 1;'); - haxeOutput.push(' private var json:JsonWriter;'); - haxeOutput.push(''); - haxeOutput.push(' public function new() {}'); - haxeOutput.push(''); + const ir: SerializerIR = JSON.parse(fs.readFileSync(irFile, 'utf8')); - // Generate public methods - for (const method of ir.publicMethods) { - const haxeParamType = transformType(method.paramType); - haxeOutput.push(` public function ${method.name}(${method.paramName}:${haxeParamType}):String {`); - haxeOutput.push(' visitedObjects = new StringMap();'); - haxeOutput.push(' nextId = 1;'); - haxeOutput.push(' json = new JsonWriter();'); - haxeOutput.push(` ${method.writeMethodCall}(${method.paramName});`); - haxeOutput.push(' return json.getString();'); - haxeOutput.push(' }'); - haxeOutput.push(''); - } + // Generate Haxe serializer using reflection-based approach + const haxeCode = generateReflectionBasedHaxe(ir); - // Generate write methods - for (const method of ir.writeMethods) { - const shortName = method.paramType.split('.').pop(); - const haxeType = transformType(method.paramType); + // Write the Haxe file + const haxeFile = path.resolve( + __dirname, + '../../spine-haxe/spine-haxe/spine/utils/SkeletonSerializer.hx' + ); - haxeOutput.push(` private function ${method.name}(obj:${haxeType}):Void {`); + fs.mkdirSync(path.dirname(haxeFile), { recursive: true }); - if (method.isAbstractType) { - // Handle abstract types with Std.isOfType chain (Haxe equivalent of instanceof) - if (method.subtypeChecks && method.subtypeChecks.length > 0) { - let first = true; - for (const subtype of method.subtypeChecks) { - const subtypeHaxeName = transformType(subtype.typeName); + // Validate generated code + await validateGeneratedHaxeCode(haxeCode, haxeFile); - if (first) { - haxeOutput.push(` if (Std.isOfType(obj, ${subtypeHaxeName})) {`); - first = false; - } else { - haxeOutput.push(` } else if (Std.isOfType(obj, ${subtypeHaxeName})) {`); - } - haxeOutput.push(` ${subtype.writeMethodCall}(cast(obj, ${subtypeHaxeName}));`); - } - haxeOutput.push(' } else {'); - haxeOutput.push(` throw new spine.SpineException("Unknown ${shortName} type");`); - haxeOutput.push(' }'); - } else { - haxeOutput.push(' json.writeNull(); // No concrete implementations after filtering exclusions'); - } - } else { - // Handle concrete types - add cycle detection - haxeOutput.push(' if (visitedObjects.exists(obj)) {'); - haxeOutput.push(' json.writeValue(visitedObjects.get(obj));'); - haxeOutput.push(' return;'); - haxeOutput.push(' }'); + console.log(`Generated reflection-based Haxe serializer: ${haxeFile}`); + console.log(`- ${ir.publicMethods.length} public methods`); + console.log(`- ${ir.writeMethods.length} write methods`); + console.log(`- Uses runtime reflection for property access`); - // Generate reference string - const nameGetter = method.properties.find(p => - (p.kind === 'object' || p.kind === "primitive") && - p.getter === 'getName()' && - p.valueType === 'String' - ); - - if (nameGetter) { - const nameAccessor = mapJavaGetterToHaxeField('getName()', 'obj'); - haxeOutput.push(` var refString = ${nameAccessor} != null ? "<${shortName}-" + ${nameAccessor} + ">" : "<${shortName}-" + (nextId++) + ">";`); - } else { - haxeOutput.push(` var refString = "<${shortName}-" + (nextId++) + ">";`); - } - haxeOutput.push(' visitedObjects.set(obj, refString);'); - haxeOutput.push(''); - - haxeOutput.push(' json.writeObjectStart();'); - - // Write reference string and type - haxeOutput.push(' json.writeName("refString");'); - haxeOutput.push(' json.writeValue(refString);'); - haxeOutput.push(' json.writeName("type");'); - haxeOutput.push(` json.writeValue("${shortName}");`); - - // Write properties - for (const property of method.properties) { - haxeOutput.push(''); - haxeOutput.push(` json.writeName("${property.name}");`); - const propertyLines = generatePropertyCode(property, ' ', ir.enumMappings); - haxeOutput.push(...propertyLines); - } - - haxeOutput.push(''); - haxeOutput.push(' json.writeObjectEnd();'); - } - - haxeOutput.push(' }'); - haxeOutput.push(''); - } - - // Add helper methods for special types (following C++ pattern) - haxeOutput.push(' // Helper methods for special types'); - haxeOutput.push(' private function writeColor(obj:spine.Color):Void {'); - haxeOutput.push(' if (obj == null) {'); - haxeOutput.push(' json.writeNull();'); - haxeOutput.push(' } else {'); - haxeOutput.push(' json.writeObjectStart();'); - haxeOutput.push(' json.writeName("r");'); - haxeOutput.push(' json.writeValue(obj.r);'); - haxeOutput.push(' json.writeName("g");'); - haxeOutput.push(' json.writeValue(obj.g);'); - haxeOutput.push(' json.writeName("b");'); - haxeOutput.push(' json.writeValue(obj.b);'); - haxeOutput.push(' json.writeName("a");'); - haxeOutput.push(' json.writeValue(obj.a);'); - haxeOutput.push(' json.writeObjectEnd();'); - haxeOutput.push(' }'); - haxeOutput.push(' }'); - haxeOutput.push(''); - - haxeOutput.push('}'); - - return haxeOutput.join('\n'); -} - -async function validateGeneratedHaxeCode(haxeCode: string, outputPath: string): Promise { - // Write code to file - fs.writeFileSync(outputPath, haxeCode); - - try { - // Basic syntax validation by attempting to parse with Haxe compiler - // Use JsonWriter.hx as main to avoid framework dependencies - execSync('haxe -cp spine-haxe --no-output -main spine.utils.JsonWriter', { - cwd: path.resolve(__dirname, '../../spine-haxe'), - stdio: 'pipe' - }); - - console.log('✓ Generated Haxe serializer syntax validates successfully'); - - } catch (error: any) { - // Don't fail immediately - the serializer might still work despite validation issues - // This is because the Haxe runtime has optional dependencies for different frameworks - console.log('⚠ Haxe serializer validation had issues (may still work):'); - console.log(error.message.split('\n').slice(0, 3).join('\n')); - } -} - -async function main(): Promise { - try { - // Read the IR file - const irFile = path.resolve(__dirname, '../output/serializer-ir.json'); - if (!fs.existsSync(irFile)) { - console.error('Serializer IR not found. Run generate-serializer-ir.ts first.'); - process.exit(1); - } - - const ir: SerializerIR = JSON.parse(fs.readFileSync(irFile, 'utf8')); - - // Generate Haxe serializer from IR - const haxeCode = generateHaxeFromIR(ir); - - // Write the Haxe file - const haxeFile = path.resolve( - __dirname, - '../../spine-haxe/spine-haxe/spine/utils/SkeletonSerializer.hx' - ); - - fs.mkdirSync(path.dirname(haxeFile), { recursive: true }); - - // Validate generated code compiles before writing - await validateGeneratedHaxeCode(haxeCode, haxeFile); - - console.log(`Generated Haxe serializer from IR: ${haxeFile}`); - console.log(`- ${ir.publicMethods.length} public methods`); - console.log(`- ${ir.writeMethods.length} write methods`); - console.log(`- ${Object.keys(ir.enumMappings).length} enum mappings`); - - } catch (error: any) { - console.error('Error:', error.message); - console.error('Stack:', error.stack); - process.exit(1); - } + } catch (error: any) { + console.error('Error:', error.message); + console.error('Stack:', error.stack); + process.exit(1); + } } // Allow running as a script or importing the function if (import.meta.url === `file://${process.argv[1]}`) { - main(); + main(); } -export { generateHaxeFromIR }; \ No newline at end of file +export { generateReflectionBasedHaxe }; \ No newline at end of file diff --git a/tests/src/java-haxe-diff.ts b/tests/src/java-haxe-diff.ts index 401fadd66..f988418ea 100644 --- a/tests/src/java-haxe-diff.ts +++ b/tests/src/java-haxe-diff.ts @@ -13,7 +13,7 @@ interface TypeLocation { line: number; } -function findTypeInJava(typeName: string): TypeLocation | null { +function findTypeInJava (typeName: string): TypeLocation | null { try { // Search for class, interface, or enum definitions const result = execSync( @@ -34,7 +34,7 @@ function findTypeInJava(typeName: string): TypeLocation | null { return null; } -function findTypeInHaxe(typeName: string): TypeLocation | null { +function findTypeInHaxe (typeName: string): TypeLocation | null { try { // Search for class, interface, enum, typedef, or abstract definitions const result = execSync( @@ -55,7 +55,7 @@ function findTypeInHaxe(typeName: string): TypeLocation | null { return null; } -async function main(): Promise { +async function main (): Promise { // Read the IR file const irFile = path.resolve(__dirname, '../output/serializer-ir.json'); if (!fs.existsSync(irFile)) {