File: code.pm

package info (click to toggle)
libextutils-xspp-perl 0.1800-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 996 kB
  • ctags: 1,861
  • sloc: perl: 8,324; cpp: 125; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package ExtUtils::XSpp::Exception::code;
use strict;
use warnings;
use base 'ExtUtils::XSpp::Exception';

sub _dl { return defined( $_[0] ) && length( $_[0] ) ? $_[0] : undef }

sub init {
  my $this = shift;
  $this->SUPER::init(@_);
  my %args = @_;

  $this->{HANDLER_CODE} = _dl( $args{handler_code} || $args{arg1} );
}

sub handler_code {
  my $this = shift;
  my $no_spaces_indent = shift;
  $no_spaces_indent = 4 if not defined $no_spaces_indent;

  my $ctype = $this->cpp_type;
  my $user_code = $this->{HANDLER_CODE};
  $user_code =~ s/^\s+//;
  $user_code =~ s/\s+$//;
  $user_code = $this->indent_code($user_code, 2);
  my $code = <<HERE;
catch ($ctype& e) {
$user_code
}
HERE
  return $this->indent_code($code, $no_spaces_indent);
}

1;