This repository has been archived by the owner. It is now read-only.

bindgencr

Generator of binding for the crystal language, based on castxml output.

bindgencr

Little program to generate crystal binding file for C libraries.

see also crystal-lang/crystal_lib

Installation

Usage

Not yet complete, but can still generate the binding for sqlite3 and json-c ( perhaps some others )

castxml --castxml-gccxml [HEADER] -o [OUTPUT XML FILE]

bindgencr filename.xml [-n LibName] [-l linkedlib ] [--no-prefix=prefix_]

  Usage:
    bindgencr [argument] [flags]

  Example:
    bindgencr json.xml -l json-c -n LibJsonC

  Flags:

    -h, --help                       Show this help
    -n, --name=NAME                  The module name ( lib [name] )
    -l, --link=LINK                  The library to link with (@[Link([link]) directive
    --no-prefix                      Remove the functions prefix

It will print the result to stdout for now

See spec and samples folder to see what can be done for now.

Development

TODO:

  • Generate basic structure
  • Generate simple types, pointers and struct
  • Render functions declarations in context
  • Add function pointer
  • Add arrays
  • Add CvQualifiedType
  • Add Union
  • Add Enumeration
  • Add pointer of callback
  • More and more

Samples

Samples are generated and used using those lines :

Sqlite3

castxml --castxml-gccxml /usr/include/sqlite3.h -o samples/sqlite3/libsqlite3.xml
crystal run src/bindgencr.cr -- samples/sqlite3/libsqlite3.xml -l sqlite3 -n LibSqlite3 > samples/sqlite3/lib_sqlite3.cr
crystal run samples/sqlite3/main.cr

Json-c

castxml --castxml-gccxml /usr/include/json-c/json.h -o samples/jsonc/json.xml
crystal run src/bindgencr.cr -- samples/jsonc/json.xml -l json-c -n LibJsonC > samples/jsonc/lib_jsonc.cr
crystal run samples/jsonc/main.cr

Contributing

  1. Fork it ( https://github.com/TechMagister/bindgencr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

bindgencr

Owner
Statistic
  • 2
  • 1
  • 0
  • 0
  • 0
  • almost 7 years ago
  • June 26, 2016
License

MIT License

Links
Synced at

Sat, 04 May 2024 05:12:33 GMT

Languages