codegen

A macro tool to generate haxe and none-haxe codes from existing haxe source codes.
https://bitbucket.org/yar3333/haxe-codegen

To install, run:

haxelib install codegen 1.6.0 

See using Haxelib in Haxelib documentation for more information.

README.md

codegen

A macro tool to generate codes (haxe and none-haxe) from existing haxe source codes.

Useful if you want to split your project into several separate-compiled parts and you want to have common api (extern classes).

Usage

Compile your project with -lib codegen and one of the generation macro:

  • --macro "CodeGen.haxeExtern(outPath,?applyNatives,?topLevelPackage,?filterFile,?mapperFile,?includePrivate,?requireNodeModule)" - generate haxe extern classes like haxe compiler '--gen-hx-classes' option;
  • --macro "CodeGen.typescriptExtern(outPath,?topLevelPackage,?filterFile,?mapperFile,?includePrivate)" - generate typescript extern classes.

Other arguments details:

  • outPath - path to output directory (for haxeExtern) or output file (for typescriptExtern);
  • applyNatives - are resolve @:native metas (default is false for haxeExtern and always true for typescriptExtern);
  • topLevelPackage - a simple way to filter generated types (specify '' to not exclude any packages);
  • filterFile - path to a text file with lines prefixed with "+" to include or "-" to exclude specified package/type (one per line);
  • mapperFile - path to a text file with lines in 'FromType => ToType' format (use to map types);
  • includePrivate - include private class members into output (default is false);
  • requireNodeModule - module name to generate @:jsRequire meta for classes.

You can mark types/fields with @:noapi meta to exclude them from output.

Example

haxe -lib mylib -cp src -main Main -js dummy.js -lib codegen --macro "CodeGen.haxeExtern('hxclasses','','myproj.filter','myproj.mapper')" 

myproj.filter file example:

+mypack
# comment
-mypack.ClassToExclude

myproj.mapper file example:

mypack.MyTypeA => mypack.MyType1
# comment
mypack.MyTypeB => mypack.MyType2
Contributors
yar3333
Version
1.6.0
Published
3 weeks ago
License
LGPL

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github