Godot Bindings Generator for Haxe

December 1, 2023 · View on GitHub

Generates target-agnostic Godot bindings for Haxe.

Most Godot binding generators for Haxe are built for a specific Haxe target (Haxe/C++, Haxe/C#, etc.) The goal of this project is to create generic bindings that can work as a base for other projects to avoid reinventing the wheel.

This is achieved by converting Godot's extension_api.json data to TypeDefinition representations of the generated Haxe types. From there, one can manipulate the TypeDefinitions to work best for their desired Haxe target. This project will then take care of generating the .hx files.

If you just want un-modified, basic Godot bindings, you can do that too!

 

Installation Table of Epicness

First install via git.

haxelib git godot-api-generator https://github.com/SomeRanDev/Haxe-GodotBindingsGenerator

 

Next you can either generate basic bindings...

haxelib run godot-api-generator [path-to-json] [output-dir]

 

Or you can install the library and create your own generator.

#What to doWhat to write
1Add the lib to your .hxml file or compile command.
-lib godot-api-generator
2Get the TypeDefinitions and modify to your liking.
final haxeTypes: Array<TypeDefinition> = godot.Bindings.generate("path-to-json");
3Output the bindings to a folder.
godot.Bindings.output("output-folder", haxeTypes);

 

Godot-CPP Data

If you wish to include additional godot-cpp binding information such as @:includes and @:natives, add the --cpp flag or cpp option.

Command Line

haxelib run godot-api-generator [path-to-json] [output-dir] --cpp

Haxe

godot.Bindings.generate("path-to-json", { cpp: true });