• Stars
    star
    46
  • Rank 593,545 (Top 13 %)
  • Language
    Crystal
  • License
    Other
  • Created over 6 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

libclang bindings for crystal (including automatic C bindings generator)

libclang bindings for Crystal

Usage:

require "clang"

index = Clang::Index.new

files = [
  #Clang::UnsavedFile.new("input.c", "#include <pcre.h>\n"),
  Clang::UnsavedFile.new("input.c", "#include <clang/Basic/ABI.h>\n"),
]
tu = Clang::TranslationUnit.from_source(index, files, [
  "-I/usr/include",
  "-I/usr/lib/llvm-5.0/include",
])

tu.cursor.visit_children do |cursor|
  p cursor

  Clang::ChildVisitResult::Continue
end

Samples

See the samples folder for some example usages:

  • samples/debug.cr will print the AST of C or C++ headers as they are parsed;
  • samples/c2cr.cr will automatically generate Crystal bindings for a C header.

For example:

$ shards build --release

$ bin/c2cr -I/usr/lib/llvm-5.0/include llvm-c/Core.h \
    --remove-enum-prefix=LLVM --remove-enum-suffix > llvm-c/Core.cr

$ bin/c2cr -I/usr/lib/llvm-5.0/include clang-c/Index.h \
    --remove-enum-prefix > clang-c/Index.cr

$ bin/c2cr gtk-2.0/gtk/gtkenums.h --remove-enum-prefix > gtk/enums.cr

Reference

License

Distributed under the Apache 2.0 license.

More Repositories

1

crystal

The Crystal Programming Language
Crystal
19,110
star
2

shards

Dependency manager for the Crystal language
Crystal
753
star
3

crystal-book

Crystal reference with language specification, manuals and learning materials
Makefile
384
star
4

crystal-db

Common db api for crystal
Crystal
297
star
5

crystal_lib

Automatic binding generator for native libraries in Crystal
Crystal
139
star
6

crystal-sqlite3

SQLite3 bindings for Crystal
Crystal
131
star
7

heroku-buildpack-crystal

Heroku buildpack for Crystal
Shell
123
star
8

crystal-mysql

MySQL connector for Crystal
Crystal
106
star
9

install-crystal

GitHub Action: Install Crystal programming language
JavaScript
67
star
10

html_builder

DSL for creating HTML
Crystal
62
star
11

crystal-website

crystal-lang.org website
SCSS
56
star
12

crystal-presents

Playground for creating crystal presentations with live coding
CSS
40
star
13

distribution-scripts

Shell
39
star
14

crystal-molinillo

A generic dependency resolution algorithm. Ported from https://github.com/CocoaPods/Molinillo/
Crystal
29
star
15

omnibus-crystal

Omnibus builder for Crystal
Ruby
25
star
16

perf-tools

An assortment of tools to track resources in Crystal applications
Crystal
23
star
17

bootstrap-script

Automated script to bootstrap the crystal compiler from source
Shell
22
star
18

crystal-readline

Crystal bindings to GNU Readline Library
Crystal
21
star
19

json_mapping.cr

Crystal
18
star
20

rfcs

RFCs repository for Crystal
14
star
21

crystal-env

Crystal
13
star
22

logger.cr

Crystal
13
star
23

homebrew-crystal

Homebrew Tap for Crystal development
Ruby
13
star
24

yaml_mapping.cr

Crystal
8
star
25

crystal-dist

Docker workspace to sign and release Crystal binaries to repositories
Shell
7
star
26

test-ecosystem

Shell
6
star
27

crystal-infrastructure

Infrastructure automation for Crystal related resources
Jinja
4
star
28

crystal-random

Crystal
3
star
29

osc-docker

Dockerfile for pushing to Open Build Service
Dockerfile
1
star
30

.github

Default community health files
1
star