🌻 📖 Clang::CastXML

NAME

Clang::CastXML - C-family abstract syntax tree output tool

VERSION

version 0.02

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:

Clang::CastXML::Exception::UsageException

If you pass in a $source or $dest of the wrong type.

Clang::CastXML::Exception::ProcessException::IntrospectException

If there is an error running the castxml executable.

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.