NAME

XS::JIT::Header::Parser - C header file parser for XS::JIT::Header

SYNOPSIS

use XS::JIT::Header::Parser;

my $parser = XS::JIT::Header::Parser->new(
    include => ['/usr/local/include'],
    define  => { VERSION => '1.0' },
);

$parser->parse_file('/usr/include/math.h');

# Get all functions
my %funcs = $parser->functions;
for my $name (sort keys %funcs) {
    my $f = $funcs{$name};
    print "$f->{return_type} $name(",
          join(', ', @{$f->{param_types}}), ")\n";
}

# Get specific function
my $sin = $parser->function('sin');
# { name => 'sin', return_type => 'double', params => [...] }

# Get constants
my %consts = $parser->constants;
my $pi = $parser->constant('M_PI');

DESCRIPTION

This module parses C header files to extract function declarations, constants, and enums. It uses the system C preprocessor to handle includes and macros, then applies regex patterns to extract declarations.

METHODS

new(%options)

Creates a new parser instance.

Options:

include

Arrayref of include directories.

define

Hashref of preprocessor defines.

parse_file($path)

Parses a header file at the given path.

parse_string($code)

Parses header content from a string.

functions()

Returns hash of all parsed functions.

function($name)

Returns info for a specific function.

function_names()

Returns sorted list of function names.

constants()

Returns hash of all parsed constants.

constant($name)

Returns info for a specific constant.

constant_names()

Returns sorted list of constant names.

enums()

Returns hash of all parsed enums.

enum($name)

Returns values for a specific enum.

AUTHOR

LNATION <email@lnation.org>