From 16b42e0e2e1788788a0a658d6bf488a963fab1bb Mon Sep 17 00:00:00 2001 From: Steffen Mueller Date: Fri, 11 Feb 2011 19:24:21 +0100 Subject: [PATCH] Add method to get ANSIfied code This is done to all of the code in EU::PXS anyway, so why not have a nice method for it? --- .../lib/ExtUtils/Typemaps/InputMap.pm | 21 ++++++++++++++++++++- .../lib/ExtUtils/Typemaps/OutputMap.pm | 19 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm index 9a1cdcd..8c28aec 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm @@ -2,7 +2,6 @@ package ExtUtils::Typemaps::InputMap; use 5.006001; use strict; use warnings; -our $VERSION = '0.05'; use Carp qw(croak); =head1 NAME @@ -75,6 +74,26 @@ sub xstype { return $_[0]->{xstype}; } +=head2 cleaned_code + +Returns a cleaned-up copy of the code to which certain transformations +have been applied to make it more ANSI compliant. + +=cut + +sub cleaned_code { + my $self = shift; + my $code = $self->code; + + $code =~ s/;*\s+\z//; + + # Move C pre-processor instructions to column 1 to be strictly ANSI + # conformant. Some pre-processors are fussy about this. + $code =~ s/^\s+#/#/mg; + + return $code; +} + =head1 SEE ALSO L diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm index 3c04e1e..31b7312 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm @@ -2,7 +2,6 @@ package ExtUtils::Typemaps::OutputMap; use 5.006001; use strict; use warnings; -our $VERSION = '0.05'; use Carp qw(croak); =head1 NAME @@ -75,6 +74,24 @@ sub xstype { return $_[0]->{xstype}; } +=head2 cleaned_code + +Returns a cleaned-up copy of the code to which certain transformations +have been applied to make it more ANSI compliant. + +=cut + +sub cleaned_code { + my $self = shift; + my $code = $self->code; + + # Move C pre-processor instructions to column 1 to be strictly ANSI + # conformant. Some pre-processors are fussy about this. + $code =~ s/^\s+#/#/mg; + + return $code; +} + =head1 SEE ALSO L -- 2.7.4