bindgen
Bindgen - A C++ binding generator
A (as of now) C++/Qt centric binding generator.
Usage
- Add bindgen to your
shard.yml(See below). - Run
crystal depsto install it. - Copy or symlink
assets/bindgen_helper.hppinto yourext/. - Copy and customize
TEMPLATE.yml. - Run
lib/bindgen/run.sh your_template.yml
dependencies:
bindgen:
github: Papierkorb/bindgen
Note: If you intend to ship the generated code with your shard, you can
replace dependencies with development_dependencies.
Read the TEMPLATE.yml for configuration documentation.
Development dependencies
clang 4.0development headers and libraries- Other versions may or may not work.
Run-time dependencies
- The library you're wrapping. That's it.
Features
| Feature | Support |
|--------------------------------------------------|---------|
| Automatic Crystal binding generation | YES |
| Automatic Crystal wrapper generation | YES |
| Mapping classes | YES |
| +- Member methods | YES |
| +- Static methods | YES |
| +- Constructors | YES |
| +- Destructor | YES |
| +- Overloaded operators | TBD |
| +- Conversion functions | TBD |
| Overloaded methods | YES |
| Enumerations | YES |
| Copying structures | YES |
| Custom type conversions between C/++ and Crystal | YES |
| Automatic type wrapping and conversion | YES |
| Integration with Crystals GC | YES |
| C++ Template instantiation for containers types | YES |
| Virtual methods | YES |
| Override virtual methods from Crystal | YES |
| Abstract classes | YES |
| Multiple inheritance wrapping | YES |
| Qt signals | YES |
| #define fake enumerations | TBD |
| Global functions | TBD |
| Custom (de-)allocators | TBD |
| Copying in-source docs | TBD |
Name rewriting rules
The following rules are automatically applied to all bindings:
- Method names get underscored:
addWidget() -> #add_widget- Setter methods are rewritten:
setWindowTitle() -> #window_title= - Getter methods are rewritten:
getWindowTitle() -> #window_title - Bool getters are rewritten:
getAwesome() -> #awesome? isgetters are rewritten:isEmpty() -> #empty?hasgetters are rewritten:hasSpace() -> #has_space?
- Setter methods are rewritten:
- On signal methods (For Qt signals):
- Keep their name for the
emitversion:pressed() -> #pressed - Get an
on_prefix for the connect version:#on_pressed do .. end
- Keep their name for the
- Enum fields get title-cased if not already:
color0 -> Color0
Projects using bindgen
Made a published, stable-y binding with bindgen? Want to see it here? PR!
Contributing
- Talk to
Papierkorbin#crystal-langabout what you're gonna do. - You got the go-ahead? The project's in an early state: Things may change without notice under you.
- Read the
STYLEGUIDE.mdfor some tips. - Then do the rest, PR and all. You know the drill.
License
This project (bindgen) and all of its sources, except those otherwise noted,
all fall under the GPLv3 license. You can find a copy of its complete license
text in the LICENSE file.
The configuration used to generate code, and all code generated by this project,
fall under the full copyright of the user of bindgen. bindgen does not
claim any copyright, legal or otherwise, on your work. Established projects
should define a license they want to use for the generated code and
configuration.
Contributors
- Papierkorb Stefan Merettig - creator, maintainer