go2hx

caution: this program uses gorename to rename package uppercase/lowercase conflicts, it only renames non exported methods so it shouldn't break any libraries, however no guarantee.

Getting started

  • if you don't have Golang download it here
  • if you don't have lix run: npm install lix -g
  • lix scope create
  • lix install https://github.com/PXshadow/go2hx
  • lix run ./main.go or lix run github.com/tidwall/btree

Roadmap

  • Finish writing go's core standard library in haxe e.g strconv, strings, utf8, os, net, encoding, a lot of crypto.
  • Go routines using haxe 4.2's coroutines.
  • Pass the test suite

Code Overview

  • A packages are generated by arguments and flags.
  • The packages are loaded and are passed through a loadImporter that runs a gorename checker function to make sure no names will conflict, and then loadImports any imports of the package if they have not already been loaded.
  • If the gorenamer is executed the packages are regenerated.
  • The packages are loaded and their paths are normalized for haxe's syntax.
  • Package (A group of go files with the same package scope) are merged into a single file.
  • The file is added as a source data type.
  • The sources are compiled and switch iterated through the file's AST that goes through multiple steps and is eventually added into the exportData structure to be exported out to export.bson
  • The haxe side then reads the export.bson and writes the data into Haxe files, and attempts to properly structure the project for ease of use.

Code Structure

  • gostd: go's standard library written in haxe (only the low level is written i.e uses internal or syscall with certain exceptions). gostd.Go holds the internal language functionality that Haxe does not have (example: c style for loops, multi returns). gostd.Builtin holds the built in functions that go has such as len, cap, make.
  • packages.go: called go4x as the name implies is Go code for Haxe usage, go2hx passes command line arguments to it such as flags and library paths and in return go4hx produces an export.bson that go2hx uses to finish the generation.
  • src: The haxe side of the tool that handles the uses input and completes the generation from the output by go4hx (export.bson)

Inspiration

GitHub