Install subversion 1.4.6 + its perl bindings (for git-svn)
[git/jnareb-git.git] / lib / perl5 / site_perl / 5.8.8 / msys / SVN / Base.pm
blobaa9fb562c2258877649b6dfece624d7ad8f0e751
1 package SVN::Base;
3 =head1 NAME
5 SVN::Base - Base class for importing symbols for svn modules
7 =head1 SYNOPSIS
9 # Load the svn_ra_* functions into the SVN::Ra namespace.
10 package SVN::Ra;
11 use SVN::Base qw(Ra svn_ra_);
13 # Load svn_config_t structure accessors in the magic namcespace
14 # provided by swig, so we could use it returned by other functions
15 package _p_svn_config_t;
16 use SVN::Base qw(Core svn_config_);
18 =head1 DESCRIPTION
20 SVN::Base is a module importing the subversion perl bindings raw
21 symbols created by swig, into proper namespace and make them easier to
22 use.
24 It will also find the accessors for members of a C struct, create an
25 simpler accessor function like C<$data-E<gt>field()> and
26 C<$data-E<gt>field($new_value)>.
28 Once you understand the convention of subversion functions in perl
29 bindings, you could look at the subversion api and write them in perl.
30 The API is available in the source header files or online at
31 http://svn.collab.net/svn-doxygen/.
33 =head1 INTERNALS
35 The perl bindings of swig wraps raw functions into different perl
36 modules, for example, SVN::_Core, SVN::_Repos. Upon import, SVN::Base
37 bootstrap the requested module if it's not yet loaded, and iterate
38 over the symbols provided in that module, it them puts the function
39 with prefix trimmed in the namespace of the caller for this import.
41 The 3rd through the last parameter is a list of symbol endings that
42 you wish for SVN::Base not to import into your namespace. This is useful
43 for cases where you may want to import certaion symbols differently than
44 normally.
46 =head1 CAVEATS
48 SVN::Base consider a function as structure member accessor if it is
49 postfixed ``_get'' or ``_set''. Real functions with this postfixes
50 will need extra handling.
52 =cut
54 sub import {
55 my (undef, $pkg, $prefix, @ignore) = @_;
56 no warnings 'uninitialized';
57 unless (${"SVN::_${pkg}::ISA"}[0] eq 'DynaLoader') {
58 @{"SVN::_${pkg}::ISA"} = qw(DynaLoader);
59 eval qq'
60 package SVN::_$pkg;
61 require DynaLoader;
62 bootstrap SVN::_$pkg;
64 ' or die $@;
67 my $caller = caller(0);
69 my $prefix_re = qr/(?i:$prefix)/;
70 my $ignore_re = join('|', @ignore);
71 for (keys %{"SVN::_${pkg}::"}) {
72 my $name = $_;
73 next unless s/^$prefix_re//;
74 next if $ignore_re && m/$ignore_re/;
76 # insert the accessor
77 if (m/(.*)_get$/) {
78 my $member = $1;
79 *{"${caller}::$1"} = sub {
80 &{"SVN::_${pkg}::${prefix}${member}_".
81 (@_ > 1 ? 'set' : 'get')} (@_)
84 elsif (m/(.*)_set$/) {
86 else {
87 *{"${caller}::$_"} = ${"SVN::_${pkg}::"}{$name};
93 =head1 AUTHORS
95 Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
97 =head1 COPYRIGHT
99 Copyright (c) 2003 CollabNet. All rights reserved.
101 This software is licensed as described in the file COPYING, which you
102 should have received as part of this distribution. The terms are also
103 available at http://subversion.tigris.org/license-1.html. If newer
104 versions of this license are posted there, you may use a newer version
105 instead, at your option.
107 This software consists of voluntary contributions made by many
108 individuals. For exact contribution history, see the revision history
109 and logs, available at http://subversion.tigris.org/.
111 =cut