Skip to content

C-family abstract syntax tree output tool

Notifications You must be signed in to change notification settings

PerlFFI/Clang-CastXML

Repository files navigation

Clang::CastXML linux windows macos

C-family abstract syntax tree output tool

SYNOPSIS

use Clang::CastXML;
use Path::Tiny qw( path );

my $castxml = Clang::CastXML->new;
my $container = $castxml->introspect( path('foo.C') );
my $raw_xml = $container->to_xml;

DESCRIPTION

This class provides an interface to CastXML for introspecting C/C++ code. This can be useful for writing FFI or XS bindings.

PROPERTIES

wrapper

my $wrapper = $castxml->wrapper;

Returns the Clang::CastXML::Wrapper instance. The default is usually reasonable.

METHODS

introspect

my $container = $castxml->introspect($source);
my $container = $castxml->introspect($source, $dest);

This runs CastXML on the given source and returns an XML container which can be used to get the raw XML, or to convert it to a more useful format.

$source should be either a Path::Tiny object for the C/C++ source file, or a string containing the C/C++ source.

$dest is optional, and if provided should be a Path::Tiny object where the XML will be written. If not provided, then a temporary file will be created.

$container is an instance of Clang::CastXML::Container.

May throw an exception:

AUTHOR

Graham Ollis plicease@cpan.org

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

About

C-family abstract syntax tree output tool

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages