Skip to content

Commit 3108bcc

Browse files
committed
ParseXS: fix space translation for $ntype
Variable $ntype is used in T_PACKED and T_PACKEDARRAY AS-IS making impossible to use these typemaps with any types containing spaces, like 'struct Foo'. This commit replaces spaces with underscores. Signed-off-by: Sergei Zhmylev <[email protected]>
1 parent 8d0a0f0 commit 3108bcc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,10 @@ sub lookup_input_typemap {
13821382

13831383
my $typemaps = $pxs->{typemaps_object};
13841384

1385-
# Normalised type ('Foo *' becomes 'FooPtr): one of the valid vars
1386-
# which can appear within a typemap template.
1385+
# Normalised type ('struct Foo *' becomes 'struct_FooPtr): one of
1386+
# the valid vars which can appear within a typemap template.
13871387
(my $ntype = $type) =~ s/\s*\*/Ptr/g;
1388+
$ntype =~ s/\s/_/g;
13881389

13891390
# $subtype is really just for the T_ARRAY / DO_ARRAY_ELEM code below,
13901391
# where it's the type of each array element. But it's also passed to

dist/ExtUtils-ParseXS/lib/perlxstypemap.pod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ e.g. for a type of C<Foo::Bar>, I<$type> is C<Foo__Bar>
230230

231231
=item *
232232

233-
I<$ntype> - the supplied type with C<*> replaced with C<Ptr>.
234-
e.g. for a type of C<Foo*>, I<$ntype> is C<FooPtr>
233+
I<$ntype> - the supplied type with C<*> replaced with C<Ptr> and
234+
C<\s> replaced with C<_>.
235+
e.g. for a type of C<struct Foo*>, I<$ntype> is C<struct_FooPtr>
235236

236237
=item *
237238

0 commit comments

Comments
 (0)