Mario Zechner 429ed9dd3b [tests] Complete C++ SkeletonSerializer auto-generation from Java
- Implement comprehensive C++ serializer generator (tests/generate-cpp-serializer.ts)
- Direct transformation of Java SkeletonSerializer to C++ header-only implementation
- Handle all C++-specific API differences:
  * Field access patterns (obj.field → obj->field, private fields → obj->_field)
  * Null check removal for reference-returning methods (getBones, getEdges)
  * Nested array null check elimination (getVertices, getDrawOrders)
  * Enum serialization via switch statements replacing .name() calls
  * Custom function replacement system for C++-specific implementations
- Add specialized C++ implementations:
  * writeColor: handle public Color fields (r,g,b,a without underscore)
  * writeSkin: iterate AttachmentMap::Entries and call writeSkinEntry
  * writeSkinEntry: handle AttachmentMap::Entry instead of Java SkinEntry
- Auto-generate both pointer and reference versions of all write methods
- Create JsonWriter.h as header-only port of Java JsonWriter
- Update HeadlessTest.cpp to use generated SkeletonSerializer
- Add comprehensive type analysis and enum mapping from analysis-result.json
- Implement exclusion system for filtering unwanted types/methods
- Fix Java generator nested array null checks that were incorrectly hardcoded

Generated C++ serializer produces identical JSON output to Java reference implementation.
2025-07-13 02:06:44 +02:00

69 lines
2.0 KiB
TypeScript

// Shared types for the Spine serializer generator
// Match lsp-cli's Supertype interface
export interface Supertype {
name: string;
typeArguments?: string[];
}
// Match lsp-cli's SymbolInfo interface (we call it Symbol for backward compatibility)
export interface Symbol {
name: string;
kind: string;
file: string;
preview: string;
documentation?: string;
typeParameters?: string[];
supertypes?: Supertype[];
children?: Symbol[];
// We don't need range and definition for our use case
}
export interface LspOutput {
language: string;
directory: string;
symbols: Symbol[];
}
export interface ClassInfo {
className: string;
superTypes: string[]; // Just the names for backward compatibility
superTypeDetails?: Supertype[]; // Full details with type arguments
getters: GetterInfo[];
fields: FieldInfo[];
file: string;
isAbstract: boolean;
isInterface: boolean;
isEnum: boolean;
typeParameters?: string[]; // The class's own type parameters
enumValues?: string[]; // For enums
concreteImplementations?: string[]; // For abstract classes/interfaces - only leaf concrete types
allImplementations?: string[]; // For abstract classes/interfaces - includes intermediate abstract types
}
export interface GetterInfo {
methodName: string;
returnType: string;
}
export interface FieldInfo {
fieldName: string;
fieldType: string;
isFinal: boolean;
}
export interface PropertyInfo {
name: string;
type: string;
isGetter: boolean;
inheritedFrom?: string; // Which class this property was inherited from
excluded: boolean; // Whether this property should be excluded from serialization
}
export interface AnalysisResult {
classMap: Map<string, ClassInfo>;
accessibleTypes: Set<string>;
abstractTypes: Map<string, string[]>; // abstract type -> concrete implementations
allTypesToGenerate: Set<string>; // all types that need write methods
typeProperties: Map<string, PropertyInfo[]>; // type -> all properties (including inherited)
}