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:

  1. Reuses spine-c's C++ type extraction and IR generation
  2. Generates clean, type-safe Dart wrapper classes
  3. 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:

  1. Extract types from spine-cpp headers
  2. Generate C intermediate representation
  3. Create Dart wrapper classes in lib/src/generated/

Generated Files

  • lib/src/generated/ - Contains all generated wrapper classes
  • lib/src/generated/array.dart - Generic Array implementation
  • lib/src/generated/*.dart - Individual wrapper classes for each Spine type
  • lib/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.