Skip to content

Instantly share code, notes, and snippets.

@vietj
Last active August 29, 2015 14:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vietj/c448a24073cc00d9e554 to your computer and use it in GitHub Desktop.
Save vietj/c448a24073cc00d9e554 to your computer and use it in GitHub Desktop.
Codegen howto

Codegen

An howto for codegen.

Preliminary

Codegen is able to handle model generation for different kind of models:

  • module

  • package

  • class/interface types

  • dataobject

Any class/interface or dataobject always belons to a package and most importantly to a module

Class generation steps

  • generate the target lang class files with an empty class and make them compile: ReadStream

  • generate imports, so each target class is able to import the classes it depends on: TimeoutStream imports ReadStream

  • distinguish between concrete and abstract types: ReadStream is abstract and TimeoutStream is concrete

  • add generic support if any on class model declaration: ReadStream<T>

  • add inheritance support

    • generics: TimeoutStream extends ReadStream<Long>, etc…​

    • super concrete type and super abstract types: AsyncFile extends ReadStream<Buffer> and WriteStream<Buffer>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment