Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.
/ bindgencr Public archive

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

License

Notifications You must be signed in to change notification settings

TechMagister/bindgencr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published