You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the latest version of Devel::ParseXS, this one.
I wrote the following small script and named it test.pl. This script uses Devel::ParseXS to parse an XS file which it takes from ARGV. After it's parsed, a traversal of the AST is made. I was interested in nodes with func_name, I wanted to see what kind of attributes the nodes have.
#!/usr/bin/env perl
use strict;
use warnings;
use lib './local/lib/perl5';
use Devel::XS::AST::Boot;
use Devel::ParseXS;
use Scalar::Util qw/blessed/;
use Data::Dumper;
my $parser = Devel::ParseXS->new();
#$parser->parse_file( "/tmp/Gtk2-1.249/xs/GtkCombo.xs" );
$parser->parse_file( $ARGV[0] );
my $ast = $parser->tree;
sub traverse {
print ref($_[0])."\n";
my $blacklist = {
"ARRAY" => 1,
"HASH" => 1,
};
###################################
# Go over all keys of the current node(the one that was
# passed as a parameter to travers )
# and print the attributes
###################################
for my $k (%{$_[0]}) {
next if !defined($k);
next if !defined($_[0]->{$k});
next if $blacklist->{ref($_[0]->{$k})};
next if blessed($_[0]->{$k});
print " [ $k ; $_[0]->{$k} ]\n";
};
###################################
# Recurse
###################################
for my $c (@{$_[0]->{contents}}) {
next if !blessed($c);
traverse($c);
};
};
traverse($ast);
exit 0;
Then I ran a oneliner to find out how many of the XS files in Gtk2 it parsed without throwing an error:
And the result was this(first column is count, second column is exit value):
84 0
101 25
27 255
So 84 out of 212. So in 39% of the XS files in Gtk2, test.pl was succesful in parsing(exit value was zero), it's pretty good considering how hard XS is to parse since it's a mix of C and custom-stuff.
In the oneliner above I redirected both stdout and stderr to /dev/null. If I redirect just stdout to /dev/null, I can find what the errors were when parsing some of the XS files. I've put those here. All of the errors were thrown in parse_file on line 11 of test.pl.
I will have a closer look at it soon. But I like the module a lot and I'll play more with it soon.
Thanks a lot for writing this module 👍
The text was updated successfully, but these errors were encountered:
Cool! Thanks for poking at it. Automated testing using CPAN distributions is on my todo list, as is adding more useful tree traversal/visiting functions.
The Gtk2 xs files should parse without error now. Whether they're correctly parsed is another story. There's a primitive debug tool in tools/parse which can use Data::Dumper::GUI to display the resultant AST. I'm working on something a bit more clever.
Hi,
I played a bit with Devel::ParseXS, I like it a lot.
I tested it on Gtk2 version 1.249 (here on CPAN ).
I used the latest version of Devel::ParseXS, this one.
I wrote the following small script and named it
test.pl
. This script uses Devel::ParseXS to parse an XS file which it takes from ARGV. After it's parsed, a traversal of the AST is made. I was interested in nodes withfunc_name
, I wanted to see what kind of attributes the nodes have.Then I ran a oneliner to find out how many of the XS files in Gtk2 it parsed without throwing an error:
And the result was this(first column is count, second column is exit value):
So 84 out of 212. So in 39% of the XS files in Gtk2, test.pl was succesful in parsing(exit value was zero), it's pretty good considering how hard XS is to parse since it's a mix of C and custom-stuff.
In the oneliner above I redirected both stdout and stderr to /dev/null. If I redirect just stdout to /dev/null, I can find what the errors were when parsing some of the XS files. I've put those here. All of the errors were thrown in
parse_file
on line 11 oftest.pl
.I will have a closer look at it soon. But I like the module a lot and I'll play more with it soon.
Thanks a lot for writing this module 👍
The text was updated successfully, but these errors were encountered: