A light-weight wrapper for Ruby exposing libclang. This project is currently tested with Clang/libclang 18 and higher.
Add this line to your application's Gemfile:
gem 'ffi-clang'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ffi-clang
Please see the project documentation for more details.
The following environment variables can be used to configure how ffi-clang finds libclang and its resources:
| Variable | Description |
|---|---|
LLVM_CONFIG | Path to the llvm-config binary. Used to locate the libclang shared library and clang binary. |
LLVM_VERSION | Target LLVM version (e.g., 17). When set, disables auto-detection of llvm-config. |
LIBCLANG | Direct path to the libclang shared library (e.g., /usr/lib/libclang.so). Overrides llvm-config based library discovery. |
LIBCLANG_RESOURCE_DIR | Path to the clang resource directory containing compiler-intrinsic headers (stddef.h, stdarg.h, etc.). Use this if libclang cannot find its own headers. |
For example, to use a specific LLVM installation:
LLVM_CONFIG=llvm-config-17 bundle exec bake test
Please see the project releases for all releases.
FFI::Clang::Types::Type#intrinsic_type, which strips references and follows pointer indirection until reaching a non-pointer type and then drops cv-qualifiers.FFI::Clang::Types::Type#reference?, a one-liner predicate over :type_lvalue_ref and :type_rvalue_ref.FFI::Clang::Cursor#copyable? and FFI::Clang::Types::Type#copyable?, predicates that return true when a class/struct has an accessible copy constructor (none deleted, private, or protected) and every base class is copyable.FFI::Clang::Cursor#copy_assignable? and FFI::Clang::Types::Type#copy_assignable?, predicates that return true when a class/struct has an accessible copy assignment operator (none deleted, private, or protected) and every base class is copy-assignable.FFI::Clang::Types::Type#fully_qualified_name now works on libclang versions earlier than 21 via a Ruby shim that composes existing libclang APIs (declaration, qualified_name, template arguments, pointer/array/reference unwrapping).FFI::Clang::Types::Type#unqualified_type against :type_invalid input.FFI::Clang::Types::Type#non_reference_type against :type_invalid input.-isystem instead of -I for auto-discovered MSVC system include paths so that in_system_header? correctly identifies system headers.FFI::Clang::Cursor#qualified_display_name.clang_Type_getNamedType. (#90)LIBCLANG and LLVM_CONFIG overrides over Xcode. (#88)visit_children method. Fixes #82. (#84)Type::Function args and expose Lib.get_non_reference_type. (#85)FFI::Clang::Type into a number of more cohesive subclasses inheriting from FFI::Clang::Types::Type. (#81)clang_getEnumDeclIntegerType. (#67)parse_translation_unit2 API. (#70)FFI::Clang::CodeCompletion::Results. (#74)CXCursor_TranslationUnit enum value to 350. (#61)Cursor#hash and Cursor#eql?. (#62)cursor_translation_unit enum value based on the Clang version. (#64)We welcome contributions to this project.
git checkout -b my-new-feature).git commit -am 'Add some feature').git push origin my-new-feature).To run the test suite:
bundle exec sus
To make a new release:
bundle exec bake gem:release:patch # or minor or major
In order to protect users of this project, we require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
Ruby
97.5%
C++
2.0%
A light-weight wrapper for Ruby exposing libclang. This project is currently tested with Clang/libclang 18 and higher.
Add this line to your application's Gemfile:
gem 'ffi-clang'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ffi-clang
Please see the project documentation for more details.
The following environment variables can be used to configure how ffi-clang finds libclang and its resources:
| Variable | Description |
|---|---|
LLVM_CONFIG | Path to the llvm-config binary. Used to locate the libclang shared library and clang binary. |
LLVM_VERSION | Target LLVM version (e.g., 17). When set, disables auto-detection of llvm-config. |
LIBCLANG | Direct path to the libclang shared library (e.g., /usr/lib/libclang.so). Overrides llvm-config based library discovery. |
LIBCLANG_RESOURCE_DIR | Path to the clang resource directory containing compiler-intrinsic headers (stddef.h, stdarg.h, etc.). Use this if libclang cannot find its own headers. |
For example, to use a specific LLVM installation:
LLVM_CONFIG=llvm-config-17 bundle exec bake test
Please see the project releases for all releases.
FFI::Clang::Types::Type#intrinsic_type, which strips references and follows pointer indirection until reaching a non-pointer type and then drops cv-qualifiers.FFI::Clang::Types::Type#reference?, a one-liner predicate over :type_lvalue_ref and :type_rvalue_ref.FFI::Clang::Cursor#copyable? and FFI::Clang::Types::Type#copyable?, predicates that return true when a class/struct has an accessible copy constructor (none deleted, private, or protected) and every base class is copyable.FFI::Clang::Cursor#copy_assignable? and FFI::Clang::Types::Type#copy_assignable?, predicates that return true when a class/struct has an accessible copy assignment operator (none deleted, private, or protected) and every base class is copy-assignable.FFI::Clang::Types::Type#fully_qualified_name now works on libclang versions earlier than 21 via a Ruby shim that composes existing libclang APIs (declaration, qualified_name, template arguments, pointer/array/reference unwrapping).FFI::Clang::Types::Type#unqualified_type against :type_invalid input.FFI::Clang::Types::Type#non_reference_type against :type_invalid input.-isystem instead of -I for auto-discovered MSVC system include paths so that in_system_header? correctly identifies system headers.FFI::Clang::Cursor#qualified_display_name.clang_Type_getNamedType. (#90)LIBCLANG and LLVM_CONFIG overrides over Xcode. (#88)visit_children method. Fixes #82. (#84)Type::Function args and expose Lib.get_non_reference_type. (#85)FFI::Clang::Type into a number of more cohesive subclasses inheriting from FFI::Clang::Types::Type. (#81)clang_getEnumDeclIntegerType. (#67)parse_translation_unit2 API. (#70)FFI::Clang::CodeCompletion::Results. (#74)CXCursor_TranslationUnit enum value to 350. (#61)Cursor#hash and Cursor#eql?. (#62)cursor_translation_unit enum value based on the Clang version. (#64)We welcome contributions to this project.
git checkout -b my-new-feature).git commit -am 'Add some feature').git push origin my-new-feature).To run the test suite:
bundle exec sus
To make a new release:
bundle exec bake gem:release:patch # or minor or major
In order to protect users of this project, we require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
Ruby
97.5%
C++
2.0%