<commit_before>package Inline::CPP;

#============================================================================
# Editing Best practices:
#     Unix line endings.
#     Four spaces for indentation (no tabs).
#     Conditional modifiers go on the following line, indented four spaces.
#     Others as issues reveal themselves.
#============================================================================

use strict;
use warnings;

require Inline::C;
require Inline::CPP::grammar;
use Carp;

use vars qw(@ISA $VERSION);

@ISA = qw(Inline::C);

# Development releases will have a _0xx version suffix.
# We eval the version number to accommodate dev. version numbering, as
# described in perldoc perlmodstyle.
$VERSION = '0.34_003';
$VERSION = eval $VERSION; ## no critic (eval)


my $TYPEMAP_KIND;
{
    no warnings qw/ once /; ## no critic (warnings)
    $TYPEMAP_KIND = $Inline::CPP::grammar::TYPEMAP_KIND;
}

#============================================================================
# Register Inline::CPP as an Inline language module
#============================================================================
sub register {
    use Config;
    return {
        language => 'CPP',
        aliases  =>
            [ 'cpp','C++', 'c++', 'Cplusplus', 'cplusplus', 'CXX', 'cxx' ],
        type     => 'compiled',
        suffix   => $Config{dlext},
    };
}

#============================================================================
# Validate the C++ config options: Now mostly done in Inline::C
#============================================================================
sub validate {
    my ( $o, @config_options ) = @_;
    # DO NOT ALTER THE FOLLOWING TWO LINES: Makefile.PL locates them by
    # their comment text and alters them based on install inputs.
 $o->{ILSM}{MAKEFILE}{CC} ||= 'g++'; # default compiler
 $o->{ILSM}{MAKEFILE}{LIBS} ||= ['-lstdc++']; # default libs

    # I haven't traced it out yet, but $o->{STRUCT} gets set before getting
    # properly set from Inline::C's validate().
    $o->{STRUCT} ||= {
              '.macros' => '',
              '.xs'     => '',
              '.any'    => 0,
              '.all'    => 0,
             };
    $o->{ILSM}{AUTO_INCLUDE} ||= <<'END';
#ifndef bool
#include <%iostream%>
#endif
extern "C" {
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
}
#ifdef bool
#undef bool
#include <%iostream%>
#endif


END


# Preprocessor definitions that will be defined if we're operating under
# "Standard C++", and *not* if we're operating under pre-Standard.

# DON'T EDIT THIS HERE-DOC.  These are set by Makefile.PL.  Override
# by supplying undefs in an AUTO_INCLUDE configuration.
my $flavor_defs =  <<'END_FLAVOR_DEFINITIONS';

#define __INLINE_CPP_STANDARD_HEADERS 1
#define __INLINE_CPP_NAMESPACE_STD 1

END_FLAVOR_DEFINITIONS


    # Prepend the compiler flavor (Standard versus Legacy) #define's
    # to the AUTO_INCLUDE boilerplate.  We prepend because that way
    # it's easy for a user to #undef them in a custom-supplied
    # AUTO_INCLUDE.  May be useful for overriding errant defaults,
    # or testing.
    $o->{ILSM}{AUTO_INCLUDE} =
        $flavor_defs . $o->{ILSM}{AUTO_INCLUDE};


    $o->{ILSM}{PRESERVE_ELLIPSIS} = 0
      unless defined $o->{ILSM}{PRESERVE_ELLIPSIS};

    # Filter out the parameters we treat differently than Inline::C
    my @propagate;
    while ( @config_options ) {
        my ( $key, $value )
            = (  shift( @config_options ),  shift( @config_options )  );
        if ( $key eq 'LIBS' ) {
            $value = [$value] unless ref $value eq 'ARRAY';
            my $num = scalar @{ $o->{ILSM}{MAKEFILE}{LIBS} } - 1;
            $o->{ILSM}{MAKEFILE}{LIBS}[$num] .= ' ' . $_
                for ( @$value );
            next;
        }
        if ( $key eq 'ALTLIBS' ) {
            $value = [$value] unless ref $value eq 'ARRAY';
            push @{ $o->{ILSM}{MAKEFILE}{LIBS} }, '';
            my $num = scalar @{ $o->{ILSM}{MAKEFILE}{LIBS} } - 1;
            $o->{ILSM}{MAKEFILE}{LIBS}[$num] .= ' ' . $_
                for ( @$value );
            next;
        }
        if (     $key eq 'PRESERVE_ELLIPSIS'
             or  $key eq 'STD_IOSTREAM' )
        {
            croak "Argument to $key must be 0 or 1"
                unless $value == 0
                    or $value == 1;
            $o->{ILSM}{$key} = $value;
            next;
        }
        push @propagate, $key, $value;
    }

    # Replace %iostream% with the correct iostream library

    # IT IS CRITICAL THAT THE FOLLOWING LINE NOT HAVE ITS "COMMENT"
    # ALTERED: Makefile.PL finds the line and alters the iostream name.
 my $iostream = 'iostream'; # default iostream filename

    $o->{ILSM}{AUTO_INCLUDE} =~ s|%iostream%|$iostream|g;

    # Forward all unknown requests up to Inline::C
    return $o->SUPER::validate(@propagate) if @propagate;
    return;
}

#============================================================================
# Print a small report if PRINT_INFO option is set
#============================================================================
sub info {
    my $o     = shift;
    my $info  = '';

    $o->parse unless $o->{ILSM}{parser};
    my $data = $o->{ILSM}{parser}{data};

    my ( @class, @func );
    if ( defined $data->{classes} ) {
        for my $class ( sort @{ $data->{classes} } ) {
            my @parents =
                grep { $_->{thing} eq 'inherits' } @{$data->{class}{$class}};
            push @class, "\tclass $class";
            push @class,
                ( ' : '
                    . join (', ',
                      map { $_->{scope} . ' ' . $_->{name} } @parents ) )
                if @parents;
            push @class, " {\n";
            for my $thing (
                sort { $a->{name} cmp $b->{name} }
                @{ $data->{class}{$class} }
            ) {
                my ( $name, $scope, $type )
                    = @{$thing}{ qw(name scope thing) };
                next unless $scope eq 'public' and $type eq 'method';
                next unless $o->check_type(
                    $thing,
                    $name eq $class,
                    $name eq "~$class",
                );
                my $rtype = $thing->{rtype} || '';
                push @class, "\t\t$rtype" . ( $rtype ? ' ' : '' );
                push @class, $class . "::$name(";
                my @args = grep { $_->{name} ne '...' } @{$thing->{args}};
                my $ellipsis =
                    ( scalar @{ $thing->{args} } - scalar @args ) != 0;
                push @class,
                    join ', ',
                        (
                            map { "$_->{type} $_->{name}" } @args
                        ),
                        $ellipsis ? '...' : ();
                push @class, ");\n";
            }
            push @class, "\t};\n"
        }
    }
    if ( defined $data->{functions} ) {
        for my $function ( sort @{ $data->{functions} } ) {<commit_msg>Trial code for allowing void param.<commit_after>package Inline::CPP;

#============================================================================
# Editing Best practices:
#     Unix line endings.
#     Four spaces for indentation (no tabs).
#     Conditional modifiers go on the following line, indented four spaces.
#     Others as issues reveal themselves.
#============================================================================

use strict;
use warnings;

require Inline::C;
require Inline::CPP::grammar;
use Carp;

use vars qw(@ISA $VERSION);

@ISA = qw(Inline::C);

# Development releases will have a _0xx version suffix.
# We eval the version number to accommodate dev. version numbering, as
# described in perldoc perlmodstyle.
$VERSION = '0.34_003';
$VERSION = eval $VERSION; ## no critic (eval)


my $TYPEMAP_KIND;
{
    no warnings qw/ once /; ## no critic (warnings)
    $TYPEMAP_KIND = $Inline::CPP::grammar::TYPEMAP_KIND;
}

#============================================================================
# Register Inline::CPP as an Inline language module
#============================================================================
sub register {
    use Config;
    return {
        language => 'CPP',
        aliases  =>
            [ 'cpp','C++', 'c++', 'Cplusplus', 'cplusplus', 'CXX', 'cxx' ],
        type     => 'compiled',
        suffix   => $Config{dlext},
    };
}

#============================================================================
# Validate the C++ config options: Now mostly done in Inline::C
#============================================================================
sub validate {
    my ( $o, @config_options ) = @_;
    # DO NOT ALTER THE FOLLOWING TWO LINES: Makefile.PL locates them by
    # their comment text and alters them based on install inputs.
 $o->{ILSM}{MAKEFILE}{CC} ||= 'g++'; # default compiler
 $o->{ILSM}{MAKEFILE}{LIBS} ||= ['-lstdc++']; # default libs

    # I haven't traced it out yet, but $o->{STRUCT} gets set before getting
    # properly set from Inline::C's validate().
    $o->{STRUCT} ||= {
              '.macros' => '',
              '.xs'     => '',
              '.any'    => 0,
              '.all'    => 0,
             };
    $o->{ILSM}{AUTO_INCLUDE} ||= <<'END';
#ifndef bool
#include <%iostream%>
#endif
extern "C" {
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
}
#ifdef bool
#undef bool
#include <%iostream%>
#endif


END


# Preprocessor definitions that will be defined if we're operating under
# "Standard C++", and *not* if we're operating under pre-Standard.

# DON'T EDIT THIS HERE-DOC.  These are set by Makefile.PL.  Override
# by supplying undefs in an AUTO_INCLUDE configuration.
my $flavor_defs =  <<'END_FLAVOR_DEFINITIONS';

#define __INLINE_CPP_STANDARD_HEADERS 1
#define __INLINE_CPP_NAMESPACE_STD 1

END_FLAVOR_DEFINITIONS


    # Prepend the compiler flavor (Standard versus Legacy) #define's
    # to the AUTO_INCLUDE boilerplate.  We prepend because that way
    # it's easy for a user to #undef them in a custom-supplied
    # AUTO_INCLUDE.  May be useful for overriding errant defaults,
    # or testing.
    $o->{ILSM}{AUTO_INCLUDE} =
        $flavor_defs . $o->{ILSM}{AUTO_INCLUDE};


    $o->{ILSM}{PRESERVE_ELLIPSIS} = 0
      unless defined $o->{ILSM}{PRESERVE_ELLIPSIS};

    # Filter out the parameters we treat differently than Inline::C
    my @propagate;
    while ( @config_options ) {
        my ( $key, $value )
            = (  shift( @config_options ),  shift( @config_options )  );
        if ( $key eq 'LIBS' ) {
            $value = [$value] unless ref $value eq 'ARRAY';
            my $num = scalar @{ $o->{ILSM}{MAKEFILE}{LIBS} } - 1;
            $o->{ILSM}{MAKEFILE}{LIBS}[$num] .= ' ' . $_
                for ( @$value );
            next;
        }
        if ( $key eq 'ALTLIBS' ) {
            $value = [$value] unless ref $value eq 'ARRAY';
            push @{ $o->{ILSM}{MAKEFILE}{LIBS} }, '';
            my $num = scalar @{ $o->{ILSM}{MAKEFILE}{LIBS} } - 1;
            $o->{ILSM}{MAKEFILE}{LIBS}[$num] .= ' ' . $_
                for ( @$value );
            next;
        }
        if (     $key eq 'PRESERVE_ELLIPSIS'
             or  $key eq 'STD_IOSTREAM' )
        {
            croak "Argument to $key must be 0 or 1"
                unless $value == 0
                    or $value == 1;
            $o->{ILSM}{$key} = $value;
            next;
        }
        push @propagate, $key, $value;
    }

    # Replace %iostream% with the correct iostream library

    # IT IS CRITICAL THAT THE FOLLOWING LINE NOT HAVE ITS "COMMENT"
    # ALTERED: Makefile.PL finds the line and alters the iostream name.
 my $iostream = 'iostream'; # default iostream filename

    $o->{ILSM}{AUTO_INCLUDE} =~ s|%iostream%|$iostream|g;

    # Forward all unknown requests up to Inline::C
    return $o->SUPER::validate(@propagate) if @propagate;
    return;
}

#============================================================================
# Print a small report if PRINT_INFO option is set
#============================================================================
sub info {
    my $o     = shift;
    my $info  = '';

    $o->parse unless $o->{ILSM}{parser};
    my $data = $o->{ILSM}{parser}{data};

    my ( @class, @func );
    if ( defined $data->{classes} ) {
        for my $class ( sort @{ $data->{classes} } ) {
            my @parents =
                grep { $_->{thing} eq 'inherits' } @{$data->{class}{$class}};
            push @class, "\tclass $class";
            push @class,
                ( ' : '
                    . join (', ',
                      map { $_->{scope} . ' ' . $_->{name} } @parents ) )
                if @parents;
            push @class, " {\n";
            for my $thing (
                sort { $a->{name} cmp $b->{name} }
                @{ $data->{class}{$class} }
            ) {
                my ( $name, $scope, $type )
                    = @{$thing}{ qw(name scope thing) };
                next unless $scope eq 'public' and $type eq 'method';
                next unless $o->check_type(
                    $thing,
                    $name eq $class,
                    $name eq "~$class",
                );
                my $rtype = $thing->{rtype} || '';
                push @class, "\t\t$rtype" . ( $rtype ? ' ' : '' );
                push @class, $class . "::$name(";
                my @args = grep { $_->{name} ne '...' and $_->{name} ne 'void' } @{$thing->{args}};
                my $ellipsis =
                    ( scalar @{ $thing->{args} } - scalar @args ) != 0;
                push @class,
                    join ', ',
                        (
                            map { "$_->{type} $_->{name}" } @args
                        ),
                        $ellipsis ? '...' : ();
                push @class, ");\n";
            }
            push @class, "\t};\n"
        }
    }
    if ( defined $data->{functions} ) {
        for my $function ( sort @{ $data->{functions} } ) {
{'fraction_non_alphanumeric': 0.22712033668592624, 'fraction_numerical': 0.002710607033311934, 'mean_word_length': 2.1633574007220218, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 100, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6547666', 'n_tokens_mistral': 4395, 'n_tokens_neox': 4111, 'n_words': 1157}