Last active
August 29, 2015 14:22
-
-
Save plicease/b51c70df4c516a89912d to your computer and use it in GitHub Desktop.
extract_uv_handle_type.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use 5.010; | |
use Convert::Binary::C; | |
my $c = Convert::Binary::C->new; | |
$c->Include(qw( | |
/usr/include | |
/usr/include/x86_64-linux-gnu/ | |
/usr/include/linux | |
)); | |
$c->Define(qw( __x86_64__ __unix__ __POSIX__ )); | |
$c->parse('typedef unsigned long int size_t;'); | |
$c->parse_file('uv.h'); | |
foreach my $enum ($c->enum) | |
{ | |
next unless defined $enum->{enumerators}->{UV_UNKNOWN_HANDLE}; | |
foreach my $key (sort { $enum->{enumerators}->{$a} <=> $enum->{enumerators}->{$b} } keys %{ $enum->{enumerators} }) | |
{ | |
my $value = $enum->{enumerators}->{$key}; | |
say "$key = $value"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jberger this extracts the uv_handle_type enum values. It uses
Convert::Binary::C
to parse the uv.h file pretty accurately. (CBC has one failing pod test). May need to adjust the includes and defines if you aren't on 64bit Debian. If you don't have the patiences to figure out the correct settings you can also crib off of the values that I got: