mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 06:44:56 +08:00
68 lines
1.4 KiB
Markdown
68 lines
1.4 KiB
Markdown
# 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
|
|
|
|
```bash
|
|
# Install dependencies
|
|
npm install
|
|
|
|
# Build the generator
|
|
npm run build
|
|
```
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
# 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<T> 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:
|
|
```bash
|
|
npm run watch
|
|
```
|
|
|
|
## Integration
|
|
|
|
After generating the Dart wrappers, run ffigen to generate the raw FFI bindings:
|
|
```bash
|
|
cd ../..
|
|
./generate_bindings.sh
|
|
```
|
|
|
|
The generated Dart wrappers depend on the FFI bindings generated by ffigen. |