Skip to content

Instantly share code, notes, and snippets.

@plicease
Last active August 29, 2015 14:22
Show Gist options
  • Save plicease/b51c70df4c516a89912d to your computer and use it in GitHub Desktop.
Save plicease/b51c70df4c516a89912d to your computer and use it in GitHub Desktop.
extract_uv_handle_type.pl
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";
}
}
@jberger
Copy link

jberger commented Jun 10, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment