2017 © Pedro Peláez
 

library hack-codegen

Hack Codegen is a library for programatically generating Hack code

image

facebook/hack-codegen

Hack Codegen is a library for programatically generating Hack code

  • Thursday, July 5, 2018
  • by alejandromarcu
  • Repository
  • 60 Watchers
  • 307 Stars
  • 9,422 Installations
  • Hack
  • 6 Dependents
  • 0 Suggesters
  • 89 Forks
  • 9 Open issues
  • 27 Versions
  • 53 % Grown

The README.md

Hack Codegen Build Status

Hack Codegen is a library for easily generating Hack code and writing it into signed files that prevent undesired modifications. The idea behind writing code that writes code is to raise the level of abstraction and reduce coupling. You can use your own way of describing a problem and generate the corresponding code. E.g. see examples/dorm. In this example, we use a schema to describe the structure of the data, and we use Hack Codegen to write the matching code., (*1)

Examples

The DORM example shows how to use the different aspects of the code generation in a simplified real-life example. The included tests also exemplify the usage of the different components., (*2)

Requirements

Hack Codegen requires: * HHVM * Composer, (*3)

Installing Hack Codegen

This package can be installed via composer:, (*4)

composer require facebook/hack-codegen

Usage

Include the autoload file generated by composer and you are ready to start using it. For example:, (*5)

<?hh
require 'vendor/autoload.php';

use Facebook\HackCodegen\HackCodegenFactory;

$cg = new HackCodegenFactory(new HackCodegenConfig());

echo $cg->codegenFile('HelloWorld.php')
  ->addClass(
    $cg->codegenClass('HelloWorld')
      ->addMethod(
        $cg->codegenMethod('sayHi')
          ->setReturnType('void')
          ->setBody(
            $cg->codegenHackBuilder()
              ->addAssignment(
                '$some_vector',
                Vector { 1, 2, 3 },
                HackBuilderValues::vector(
                  HackBuilderValues::export(),
                ),
              )
              ->addAssignment(
                '$debug_info',
                Map { 'file' => '__FILE__', 'line' => '__LINE__' },
                HackBuilderValues::map(
                  HackBuilderKeys::export(),
                  HackBuilderValues::literal(),
                ),
              )
              ->addAssignment(
                '$some_vector_of_vectors',
                Vector { Vector { 1, 2, 3 }, Vector { 4, 5, 6 } },
                HackBuilderValues::vector(
                  HackBuilderValues::vector(
                    HackBuilderValues::export(),
                  ),
                ),
              )
              ->addLine('echo "hello world\n";')
              ->getCode();
          );
      )
  )->save();

Configuration

You can configure some options such as the maximum line width, spacing and headers by implementing IHackCodegenConfig and passing an instance to HackCodegenFactory's constructor., (*6)

License

Hack Codegen is MIT-licensed., (*7)

The Versions

05/07 2018

v3.x-dev

3.9999999.9999999.9999999-dev

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

05/07 2018

v3.1.1

3.1.1.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

05/07 2018

dev-master

9999999-dev

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

05/07 2018

v3.1.0

3.1.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

18/05 2018

v3.0.8

3.0.8.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

28/02 2018

v3.0.6

3.0.6.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

28/02 2018

v3.0.7

3.0.7.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

09/02 2018

v3.0.5

3.0.5.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

09/01 2018

v3.0.3

3.0.3.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

09/01 2018

v3.0.2

3.0.2.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

15/11 2017

v3.0.1

3.0.1.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

14/11 2017

v3.0.0

3.0.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

07/08 2017

v2.x-dev

2.9999999.9999999.9999999-dev

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm ^3.12

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

21/02 2017

v2.2.1

2.2.1.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm ^3.12

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

20/02 2017

v2.2.0

2.2.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm ^3.12

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

19/02 2017

v2.1.0

2.1.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm ^3.12

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

15/02 2017

v2.0.0

2.0.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm ^3.12

 

The Development Requires

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin
by Fred Emmott

hack code generation

15/02 2017

v1.x-dev

1.9999999.9999999.9999999-dev

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

15/02 2017

v1.1.5

1.1.5.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

27/09 2016

v1.1.4

1.1.4.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

25/01 2016

v1.1.3

1.1.3.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

14/01 2016

v1.1.2

1.1.2.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

13/10 2015

v1.1.1

1.1.1.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

25/08 2015

v1.1

1.1.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

20/08 2015

v1.0.1

1.0.1.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

20/08 2015

v1.0

1.0.0.0

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

by Drew Hoskins
by Alejandro Marcu
by Matthieu Martin

hack code generation

07/08 2015

v0.9-beta

0.9.0.0-beta

Hack Codegen is a library for programatically generating Hack code

  Sources   Download

The Requires

  • hhvm *

 

hack code generation