Alt-Math-Prime-FastSieve-Inline

 view release on metacpan or  search on metacpan

inc/Inline/CPP.pm  view on Meta::CPAN

#endif
extern "C" {
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
}
#ifdef bool
#undef bool
#include <%iostream%>
#endif

END

  $o->{ILSM}{AUTO_INCLUDE} ||= $auto_include;
  $o->{ILSM}{AUTO_INCLUDE} = $flavor_defs . $o->{ILSM}{AUTO_INCLUDE};

  # Replace %iostream% with the correct iostream library
  $o->{ILSM}{AUTO_INCLUDE} =~ s{%iostream%}{$iostream}xg;
  return;
}


sub _handle_config_options {
  my ($o, @config_options) = @_;
  my @propagate;

  while (@config_options) {
    my ($key, $value) = (shift @config_options, shift @config_options);
    $key = uc $key;
    if ($key eq 'NAMESPACE') {
      _handle_namespace_cfg_option($o, $value);
    }
    elsif ($key eq 'CLASSES') {
      _handle_classes_cfg_option($o, $value);
    }
    elsif ($key eq 'LIBS') {
      _handle_libs_cfg_option($o, $value);
    }
    elsif ($key eq 'ALTLIBS') {
      _handle_altlibs_cfg_option($o, $value);
    }
    elsif ($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;
    }
    else {
      push @propagate, $key, $value;
    }
  }
  return @propagate;
}

sub _handle_namespace_cfg_option {
  my ($o, $value) = @_;
  $value =~ s/^::|::$//g;
  
  # Perl 5.12 indroduced \p{XID_Start} and \p{XID_Continue}. Prior to that
  # we should downgrade gracefully.
  my $ident = $] ge '5.0120'
    ? qr{[\p{XID_Start}_][\p{XID_Continue}_]*}
    : qr{[\p{Alpha}_][\p{Alpha}\p{Digit}_]*};

  croak "$value is an invalid package name."
    unless length $value == 0
     || $value =~ m/
                    \A
                    $ident
                    (?:::$ident)*
                    \z
                  /x;
  $value ||= 'main';
  $o->{API}{pkg} = $value;
  return;
}


sub _handle_classes_cfg_option {
  my ($o, $value) = @_;
  my $ref_value = ref($value);
  croak 'CLASSES config option is not a valid code reference or hash '
    . 'reference of class mappings.'
    unless (($ref_value eq 'CODE') or ($ref_value eq 'HASH'));

  if ($ref_value eq 'HASH') {
    foreach my $cpp_class (keys %{$value}) {
      croak "$cpp_class is not a supported C++ class."
        unless defined $value->{$cpp_class}
        && length $cpp_class != 0
        && $cpp_class =~ m/[a-zA-Z]\w*/x;
      my $perl_class = $value->{$cpp_class};
      croak "$perl_class is not a supported Perl class."
        unless length $perl_class != 0 && $perl_class =~ m/[a-zA-Z]\w*/x;
    }
  }

  $o->{API}{classes_override} = $value;
  return;
}


sub _handle_libs_cfg_option {
  my ($o, $value) = @_;
  $value = _make_arrayref($value);
  _add_libs($o, $value);
  return;
}


sub _handle_altlibs_cfg_option {
  my ($o, $value) = @_;
  $value = _make_arrayref($value);
  push @{$o->{ILSM}{MAKEFILE}{LIBS}}, q{};
  _add_libs($o, $value);
  return;
}


sub _make_arrayref {
  my $value = shift;



( run in 1.440 second using v1.01-cache-2.11-cpan-ceb78f64989 )