v1.1.1
[language-befunge-vector-xs.git] / lib / Language / Befunge / Vector / XS.pm
bloba764c9cfd387eac466f0ad37d4cec46f9d5d4932
2 # This file is part of Language::Befunge::Vector::XS.
3 # Copyright (c) 2008 Jerome Quelin, all rights reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the same terms as Perl itself.
10 package Language::Befunge::Vector::XS;
12 use strict;
13 use warnings;
15 use overload
16 '=' => \&copy,
17 '+' => \&_add,
18 '-' => \&_substract,
19 'neg' => \&_invert,
20 '+=' => \&_add_inplace,
21 '-=' => \&_substract_inplace,
22 '<=>' => \&_compare,
23 'eq' => \&_compare_string,
24 '""' => \&as_string;
26 our $VERSION = '1.1.1';
28 require XSLoader;
29 XSLoader::load('Language::Befunge::Vector::XS', $VERSION);
31 # Preloaded methods go here.
33 sub as_string {
34 my $self = shift;
35 local $" = ',';
36 return "(@$self)";
40 # my $bool = $v->_compare($string);
41 # my $bool = $v eq $string;
43 # Check whether the vector stringifies to $string.
45 sub _compare_string {
46 my ($self, $str) = @_;
47 return $self->as_string eq $str;
52 __END__
54 =head1 NAME
56 Language::Befunge::Vector::XS - Language::Befunge::Vector rewritten for speed
60 =head1 DESCRIPTION
62 The C<Language::Befunge> module makes heavy use of n-dims vectors,
63 mapped to the C<Language::Befunge::Vector> class. This allows to
64 abstract the funge dimension while still keeping the same code for the
65 operations.
67 However, such an heavy usage does have some impact on the performances.
68 Therefore, this modules is basically a rewrite of LBV in XS. If
69 installed, then LBV will automagically load it and replace its own
70 functions with the XS ones.
74 =head1 METHODS
76 This module implements exactly the same api as LBV. Please refer to this
77 module for more information on the following methods:
79 =over 4
81 =item new()
83 =item new_zeroes()
85 =item copy()
87 =item as_string()
89 =item get_dims()
91 =item get_component()
93 =item get_all_components()
95 =item clear()
97 =item set_component()
99 =item bounds_check()
101 =item rasterize()
103 =item standard mathematical operations
105 =item inplace mathematical operations
107 =item comparison operations
109 =back
112 =head1 SEE ALSO
114 L<Language::Befunge::Vector>
117 =head1 AUTHOR
119 Jerome Quelin, E<lt>jquelin@cpan.orgE<gt>
121 Development is discussed on E<lt>language-befunge@mongueurs.netE<gt>
124 =head1 COPYRIGHT & LICENSE
126 Copyright (c) 2008 Jerome Quelin, all rights reserved.
128 This program is free software; you can redistribute it and/or modify
129 it under the same terms as Perl itself.
132 =cut