Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

oprypin/crystalize.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crystalize.py

This is a Python script that generates lib definitions in Crystal programming language based on C header files.

Requires Python 3.4+ and gcc in PATH.
Also supports Python 3.3 and 2.7 if pathlib is installed.
A dependency, pycparser, is included as a submodule. Just installing this Python module will not work, because the headers in pycparser/utils/fake_libc_include are needed.

Installation: install dependencies, git clone --recursive

Usage: ./crystalize.py path/to/header.h > output.cr

Configuration: edit the script itself. Even the most intricate config file cannot replace editing the code.

Use the wiki to find and share ideas.

Very few libraries will work without manually modifying the result, but almost all the tedious work is done automatically.

Supports the following top-level declarations:

  • Function declarations → fun
  • Structs (incl. nested) → struct
  • Enums → enum
  • Unions → union
  • Typedefs → alias
  • Constants → CONSTANT = ...
  • Variables → $var = ...
  • Macros → CONSTANT = ...; can be problematic
  • Function definitions → def; just dumps C code as the function's body

About

Generator of Crystal lib definitions

Resources

License

Stars

Watchers

Forks

Languages