Raku Land

Libclang

cpan:AZAWAWI

Libclang

Build Status Build status

Perl 6 bindings for libclang

Note: This is currently experimental and API may change. Please DO NOT use in a production environment.

Example

use v6;
use Libclang;

my $index = Libclang::Index.new;
LEAVE $index.destroy if $index.defined;

my $file-name        = $*SPEC.catfile($*PROGRAM.IO.parent, "header.hpp");
my $translation-unit = Libclang::TranslationUnit.new($index, $file-name);
LEAVE $translation-unit.destroy if $translation-unit.defined;

my $cursor = $translation-unit.cursor;
LEAVE $cursor.destroy if $cursor.defined;

$cursor.visit-children(sub ($cursor, $parent) {
  printf("Cursor '%15s' of kind '%s'\n", $cursor.spelling,
    $cursor.kind-spelling);
  return child-visit-recurse;
});

Dependencies

Please follow the instructions below based on your platform to install libclang development libraries / headers:

PlatformInstallation command
Debianapt-get install libclang-dev
macOSbrew update;
brew install llvm --with-clang
WindowsInstall mingw-w64-install.exe.
Install Clang for Windows 64-bit.

Installation

$ zef install Libclang

Testing

$ AUTHOR_TESTING=1 zef test --verbose .
$ zef install Test::META
$ AUTHOR_TESTING=1 prove -e "perl6 -Ilib"

See Also

Author

Ahmad M. Zawawi, azawawi on #perl6.

License

MIT License