This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Replace :: with __ in THIS like it's done for parameters/return values
authorMattia Barbon <mattia@barbon.org>
Sun, 3 Jan 2016 20:54:31 +0000 (21:54 +0100)
committerSteffen Mueller <smueller@cpan.org>
Sun, 3 Jan 2016 21:06:28 +0000 (22:06 +0100)
Apart from being more consistent, this simplifies writing XS code
wrapping C++ classes into a nested Perl namespace (it reqquires only
a typedef for Foo__Bar rather than two, one for Foo_Bar and the other
for Foo::Bar).

Impact is likely to be minimmal: it will only affect classes:
- in C++ extensions (there is no way to make Foo::Bar *THIS compile in C)
- that use Foo::Bar only as a receiver (if they use it as a
  parameter/return value the typedef is already there)

Given that a class is always used as the return valus in a normal
constructor, this case should be relatively rare.

given this Foo.xs file:

    MODULE=Foo PACKAGE=Foo::Bar

    TYPEMAP: <<EOT
    TYPEMAP
    Foo::Bar * T_PTRREF
    EOT

    Foo::Bar *
    Foo::Bar::moo(Foo::Bar *foo)

the output of

     perl -Ilib lib/ExtUtils/xsubpp -prototypes Foo.xs
        | grep -A8 moo | head -n 10

changes from:

    XS_EUPXS(XS_Foo__Bar_moo); /* prototype to pass -Wmissing-prototypes */
    XS_EUPXS(XS_Foo__Bar_moo)
    {
        dVAR; dXSARGS;
        if (items != 2)
            croak_xs_usage(cv,  "THIS, foo");
        {
            Foo::Bar *      THIS;
            Foo__Bar *      RETVAL;
            Foo__Bar *      foo;

to:

    XS_EUPXS(XS_Foo__Bar_moo); /* prototype to pass -Wmissing-prototypes */
    XS_EUPXS(XS_Foo__Bar_moo)
    {
        dVAR; dXSARGS;
        if (items != 2)
           croak_xs_usage(cv,  "THIS, foo");
        {
            Foo__Bar *      THIS;
            Foo__Bar *      RETVAL;
            Foo__Bar *      foo;

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/CountLines.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/Cmd.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm
dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/Type.pm

index f67a82d..32d74e1 100644 (file)
@@ -11,7 +11,7 @@ use Symbol;
 
 our $VERSION;
 BEGIN {
-  $VERSION = '3.30';
+  $VERSION = '3.31';
 }
 use ExtUtils::ParseXS::Constants $VERSION;
 use ExtUtils::ParseXS::CountLines $VERSION;
@@ -579,7 +579,7 @@ EOF
           } );
         }
         else {
-          print "\t$class *";
+          print "\t" . map_type($self, "$class *");
           $self->{var_types}->{"THIS"} = "$class *";
           $self->generate_init( {
             type          => "$class *",
index 8856551..2319a24 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 use Symbol;
 
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 =head1 NAME
 
index 2f45292..222a95c 100644 (file)
@@ -1,7 +1,7 @@
 package ExtUtils::ParseXS::CountLines;
 use strict;
 
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 our $SECTION_END_MARKER;
 
index 8c075a3..7315332 100644 (file)
@@ -2,7 +2,7 @@ package ExtUtils::ParseXS::Eval;
 use strict;
 use warnings;
 
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 =head1 NAME
 
index 4de9f4e..41a9f6d 100644 (file)
@@ -5,7 +5,7 @@ use Exporter;
 use File::Spec;
 use ExtUtils::ParseXS::Constants ();
 
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 our (@ISA, @EXPORT_OK);
 @ISA = qw(Exporter);
index a16ae06..48d623e 100644 (file)
@@ -2,7 +2,7 @@ package ExtUtils::Typemaps;
 use 5.006001;
 use strict;
 use warnings;
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 require ExtUtils::ParseXS;
 require ExtUtils::ParseXS::Constants;
index ccd5efe..ffed504 100644 (file)
@@ -2,7 +2,7 @@ package ExtUtils::Typemaps::Cmd;
 use 5.006001;
 use strict;
 use warnings;
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 use ExtUtils::Typemaps;
 
index 67ea1c2..86c646d 100644 (file)
@@ -2,7 +2,7 @@ package ExtUtils::Typemaps::InputMap;
 use 5.006001;
 use strict;
 use warnings;
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 =head1 NAME
 
index 42cbe5c..32cf9f9 100644 (file)
@@ -2,7 +2,7 @@ package ExtUtils::Typemaps::OutputMap;
 use 5.006001;
 use strict;
 use warnings;
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 =head1 NAME
 
index 7e0f4ba..abe93cb 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 require ExtUtils::Typemaps;
 
-our $VERSION = '3.30';
+our $VERSION = '3.31';
 
 =head1 NAME