source: branches/profile/PERL2ARB/ARB.pm

Last change on this file was 12888, checked in by westram, 10 years ago
  • fix #603
    • abort all TAs and close all DBs
      • in arb-perl death-handler
      • on exit (i.e. perl scripts will now abort unclosed TAs - not sure whether they did commit b4)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1package ARB;
2
3use strict;
4use vars qw($VERSION @ISA @EXPORT);
5
6require Exporter;
7require DynaLoader;
8
9@ISA = qw(Exporter DynaLoader);
10# Items to export into callers namespace by default. Note: do not export
11# names by default without a very good reason. Use EXPORT_OK instead.
12# Do not simply export all your public functions/methods/constants.
13@EXPORT = qw(
14
15);
16$VERSION = '0.01';
17
18bootstrap ARB $VERSION;
19
20# globally catch die, redirect to arb_message, then confess
21package CORE::GLOBAL;
22use subs 'die';
23my $already_dying = 0;
24
25sub show_arb_message($) {
26  my ($msg) = @_;
27  $msg =~ s/\n/\\n/g;
28  $msg =~ s/'/"/g;
29  system("arb_message '$msg'");
30}
31
32sub die {
33  if ($already_dying==0) {
34    $already_dying++; # do not recurse
35
36    ARB::prepare_to_die(); # abort all transactions and close all databases (too avoid deadlock; see #603)
37
38    my ($msg) = @_;
39    $msg =~ s/\n+$//g; # remove trailing LFs
40    if ($msg eq '') { $msg = 'Unknown macro execution error'; }
41    else { $msg = "Macro execution error: '$msg'"; }
42    show_arb_message($msg."\n(see console for details)");
43
44    use Carp;
45    Carp::confess("Macro execution error: '$msg'"); # recurses into this sub
46  }
47  else {
48    CORE::die @_;
49  }
50}
51
52# Preloaded methods go here.
53
54# Autoload methods go after =cut, and are processed by the autosplit program.
55
561;
57__END__
58# Below is the stub of documentation for your module. You better edit it!
59
60=head1 NAME
61
62ARB - Perl extension for ARB
63
64=head1 SYNOPSIS
65
66  use ARB;
67
68=head1 DESCRIPTION
69
70The ARB perl module provides access to a ARB databases.  You may
71connect to a remote database (e.g. a running instance of ARB_NTREE) or
72open your own database.
73
74=head1 AUTHOR
75
76ARB development, devel@arb-home.de
77
78=head1 SEE ALSO
79
80perl(1).
81
82=cut
Note: See TracBrowser for help on using the repository browser.