bindgen

C/C++/Qt binding and wrapper generator binding-generator wrapper-generator cpp c-plus-plus c
0.1.0 released
Papierkorb/bindgen
179 17 25
Stefan Merettig

Bindgen - A C++ binding generator

A (as of now) C++/Qt centric binding generator.

Usage

  1. Add bindgen to your shard.yml (See below).
  2. Run crystal deps to install it.
  3. Copy or symlink assets/bindgen_helper.hpp into your ext/.
  4. Copy and customize TEMPLATE.yml.
  5. 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.0 development 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?
    • is getters are rewritten: isEmpty() -> #empty?
    • has getters are rewritten: hasSpace() -> #has_space?
  • On signal methods (For Qt signals):
    • Keep their name for the emit version: pressed() -> #pressed
    • Get an on_ prefix for the connect version: #on_pressed do .. end
  • 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

  1. Talk to Papierkorb in #crystal-lang about what you're gonna do.
  2. You got the go-ahead? The project's in an early state: Things may change without notice under you.
  3. Read the STYLEGUIDE.md for some tips.
  4. 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
bindgen:
  github: Papierkorb/bindgen
  version: ~> 0.1.0
License GPLv3
Crystal 0.23.1

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently