mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
1.4 KiB
1.4 KiB
spine-flutter Code Generator
This directory contains the TypeScript-based code generator that automatically creates Dart wrapper classes for the spine-flutter runtime.
Overview
The generator:
- Reuses spine-c's C++ type extraction and IR generation
- Generates clean, type-safe Dart wrapper classes
- Creates a native Dart API over the raw FFI bindings
Architecture
spine-cpp (C++ source)
↓ (spine-c type extraction)
C++ Type Information
↓ (spine-c IR generation)
C Intermediate Representation
↓ (dart-generator.ts)
Dart Wrapper Classes
Setup
# Install dependencies
npm install
# Build the generator
npm run build
Usage
# Generate Dart wrapper classes
npm run generate
This will:
- Extract types from spine-cpp headers
- Generate C intermediate representation
- Create Dart wrapper classes in
lib/src/generated/
Generated Files
lib/src/generated/- Contains all generated wrapper classeslib/src/generated/array.dart- Generic Array implementationlib/src/generated/*.dart- Individual wrapper classes for each Spine typelib/spine_flutter.dart- Main export file
Development
To watch for changes during development:
npm run watch
Integration
After generating the Dart wrappers, run ffigen to generate the raw FFI bindings:
cd ../..
./generate_bindings.sh
The generated Dart wrappers depend on the FFI bindings generated by ffigen.