Skip to content

Commit 5274995

Browse files
committed
handle mis-mangled top-level variables
1 parent df89bb3 commit 5274995

20 files changed

+55
-17
lines changed

.github/workflows/linux.yml

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
- "5.26"
2525
- "5.24"
2626
- "5.22"
27-
- "5.20"
2827

2928
env:
3029
CIP_TAG: ${{ matrix.cip_tag }}

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Revision history for {{$dist->name}}},
22

33
{{$NEXT}}
4+
- Fixup top-level variables that are incorrectly mangled (gh#8, gh#9)
5+
- Remove test dependency on YAML (gh#9)
6+
- Drop support for Perl 5.20 (gh#9)
47

58
0.01 2020-06-28 16:01:29 -0600
69
- initial version

lib/Clang/CastXML.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66
use Ref::Util qw( is_blessed_ref is_ref );
77
use Clang::CastXML::Container;

lib/Clang/CastXML/Container.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Container;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66
use XML::Parser;
77
use Clang::CastXML::Exception::ParseException;
@@ -104,7 +104,7 @@ sub to_href ($self)
104104

105105
# Fixups
106106
delete $attrs{location}; # redundant
107-
if($element eq 'Function')
107+
if($element =~ /^(Function|Variable)$/n)
108108
{
109109
# TODO: This works for current Clang (probably). If we need to
110110
# support other compiles, like Visual C++ this computed

lib/Clang/CastXML/Exception.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Exception;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66
use overload
77
'""' => sub { shift->to_string . "\n" },

lib/Clang/CastXML/Exception/ParseException.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Exception::ParseException;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66

77
# ABSTRACT: Exception for when XML parsing fails

lib/Clang/CastXML/Exception/ProcessException.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Exception::ProcessException;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66

77
# ABSTRACT: Exception for when the CastXML process fails

lib/Clang/CastXML/Exception/ProcessException/BadCastXMLVersionException.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Exception::ProcessException::BadCastXMLVersionException;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66

77
# ABSTRACT: Exception for when we can't find the CastXML version

lib/Clang/CastXML/Exception/ProcessException/IntrospectException.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Exception::ProcessException::IntrospectException;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66

77
# ABSTRACT: Exception for when castxml fails introspection

lib/Clang/CastXML/Exception/UsageException.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Exception::UsageException;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66

77
# ABSTRACT: Exception for when the Clang::CastXML is fed rubbish

lib/Clang/CastXML/Find.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package Clang::CastXML::Find;
22

33
use strict;
44
use warnings;
5-
use 5.020;
5+
use 5.022;
66
use experimental qw( signatures );
77
use File::Which ();
88
use Carp ();

lib/Clang/CastXML/Wrapper.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Wrapper;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66
use Capture::Tiny ();
77
use Clang::CastXML::Wrapper::Result;

lib/Clang/CastXML/Wrapper/Result.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Clang::CastXML::Wrapper::Result;
22

33
use Moo;
4-
use 5.020;
4+
use 5.022;
55
use experimental qw( signatures );
66

77
# ABSTRACT: The result of a Clang::CastXML::Wrapper run

t/00_diag.t

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ $modules{$_} = $_ for qw(
2222
Test::XML
2323
Throwable
2424
XML::Parser
25-
YAML
2625
);
2726

2827

t/clang_castxml.t

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use Test2::V0 -no_srand => 1;
22
use Clang::CastXML;
33
use Path::Tiny qw( path );
44
use Test::XML;
5+
use 5.022;
56

67
subtest basic => sub {
78

t/clang_castxml_container.t

+35-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use Test2::V0 -no_srand => 1;
22
use Clang::CastXML;
33
use Path::Tiny qw( path );
44
use Test::XML;
5+
use 5.022;
56
use experimental qw( postderef );
67

78
subtest 'basic' => sub {
@@ -47,8 +48,40 @@ subtest 'basic' => sub {
4748
},
4849
'work around name mangle bug',
4950
);
50-
use YAML ();
51-
note YAML::Dump(\%func);
51+
52+
};
53+
54+
subtest 'top-level variables' => sub {
55+
56+
is(
57+
{ map { $_->{name} => $_ } grep { $_->{_class} eq 'Variable' } Clang::CastXML->new->introspect(q{
58+
int foo;
59+
extern "C" int bar;
60+
namespace ns {
61+
int baz;
62+
extern "C" int frooble;
63+
}
64+
})->to_href->{inner}->@*},
65+
hash {
66+
field foo => hash {
67+
field mangled => DNE();
68+
etc;
69+
};
70+
field bar => hash {
71+
field mangled => DNE();
72+
etc;
73+
};
74+
field baz => hash {
75+
field mangled => T();
76+
etc;
77+
};
78+
field frooble => hash {
79+
field mangled => DNE();
80+
etc;
81+
};
82+
etc;
83+
}
84+
);
5285

5386
};
5487

t/clang_castxml_exception.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use Test2::V0 -no_srand => 1;
2-
use 5.020;
2+
use 5.022;
33
use experimental qw( signatures );
44
use Clang::CastXML::Exception;
55

t/clang_castxml_find.t

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use Test2::V0 -no_srand => 1;
22
use Clang::CastXML::Find;
33
use Path::Tiny qw( path );
44
use Env qw( @PATH );
5+
use 5.022;
56

67
BEGIN { $ENV{DEVEL_HIDE_VERBOSE} = 0 }
78

t/clang_castxml_wrapper.t

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use Test2::V0 -no_srand => 1;
22
use Clang::CastXML::Wrapper;
3+
use 5.022;
34

45
subtest basic => sub {
56

t/clang_castxml_wrapper_result.t

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use Test2::V0 -no_srand => 1;
22
use Clang::CastXML::Wrapper::Result;
3+
use 5.022;
34

45
is(
56
Clang::CastXML::Wrapper::Result->new(

0 commit comments

Comments
 (0)