Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build a Smaller Godot Binding

Reconstruction projectSafe wrapper over foreign ownershipAnalysis first

Use a tiny fake C engine rather than Godot itself.

  1. Export C functions that create, call, retain, and destroy opaque objects.
  2. Wrap the pointer as EnginePtr<T> with an explicit ownership strategy.
  3. Add a generation/liveness registry and checked downcasting.
  4. Store a Rust user value behind a runtime borrow cell; expose bind guards.
  5. Generate one callback trampoline that converts arguments and catches panics.
  6. Register a class and virtual callback through a static descriptor.
  7. Add a main-thread-only local future awakened by a foreign callback.
  8. Demonstrate and reject a guard held across suspension.
  9. Unregister classes and invalidate handles during simulated reload.

Tests should cover double free, dead handles, wrong dynamic type, re-entrant mutable borrow, callback panic, thread misuse, and unload with live objects.

Production godot-rust adds the full versioned Godot API, procedural macros, inheritance metadata, signals, properties, RPCs, editor integration, generated documentation, platform ABI differences, and extensive integration/sanitizer testing.