User Tools

Site Tools


info:code_generation

iMatix GSL (or "gslgen")

https://github.com/imatix/gsl

I saw a reference to this when reading about ZeroMQ (which is also by iMatix). There's some interesting writing about code generation and "Model-Oriented Programming" in the documentation.

iMatix also has released the code for a few other tools such as Libero, a code generator for state machines.

Usage (all these are projects from iMatix / Pieter Hintjens):

Cog

http://nedbatchelder.com/code/cog/

Cog seems kind of like a generic preprocessor where you write arbitrary Python code. The code is written in the comments of whatever language you're using, and the output goes right back into the same file.

Here is a Cog template for C++ in Eclipse (Preferences → C/C++ → Editor → Templates):

/*[[[cog
import cog
${cursor}
]]]*/
//[[[end]]]

Generic Templating Languages

There are plenty of these around; for the most part they seem to be used for HTML, but of course they work for any file type. I like Jinja2 (Python).

To Look At

  • Ribosome - simple code generation tool for Python, Ruby, or Node.js
  • Acceleo - appears to have some nice integration with Eclipse (the negative being that, presumably, it only runs in Eclipse)
info/code_generation.txt · Last modified: 2015-06-15 17:09 by sam