Language::Befunge::Vector::XS - Language::Befunge::Vector rewritten for speed


Language-Befunge-Vector-XS documentation Contained in the Language-Befunge-Vector-XS distribution.

Index


Code Index:

NAME

Top

Language::Befunge::Vector::XS - Language::Befunge::Vector rewritten for speed

DESCRIPTION

Top

The Language::Befunge module makes heavy use of n-dims vectors, mapped to the Language::Befunge::Vector class. This allows to abstract the funge dimension while still keeping the same code for the operations.

However, such an heavy usage does have some impact on the performances. Therefore, this modules is basically a rewrite of LBV in XS. If installed, then LBV will automagically load it and replace its own functions with the XS ones.

METHODS

Top

This module implements exactly the same api as LBV. Please refer to this module for more information on the following methods:

new()
new_zeroes()
copy()
as_string()
get_dims()
get_component()
get_all_components()
clear()
set_component()
bounds_check()
rasterize()
standard mathematical operations
inplace mathematical operations
comparison operations

SEE ALSO

Top

Language::Befunge::Vector

AUTHOR

Top

Jerome Quelin, <jquelin@cpan.org>

Development is discussed on <language-befunge@mongueurs.net>

COPYRIGHT & LICENSE

Top


Language-Befunge-Vector-XS documentation Contained in the Language-Befunge-Vector-XS distribution.

#
# This file is part of Language::Befunge::Vector::XS.
# Copyright (c) 2008 Jerome Quelin, all rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
#

package Language::Befunge::Vector::XS;

use strict;
use warnings;

use overload
	'='   => \&copy,
	'+'   => \&_add,
	'-'   => \&_substract,
	'neg' => \&_invert,
	'+='  => \&_add_inplace,
	'-='  => \&_substract_inplace,
	'<=>' => \&_compare,
	'eq'  => \&_compare_string,
	'""'  => \&as_string;

our $VERSION = '1.1.1';

require XSLoader;
XSLoader::load('Language::Befunge::Vector::XS', $VERSION);

# Preloaded methods go here.

sub as_string {
    my $self = shift;
    local $" = ',';
    return "(@$self)";
}

#
# my $bool = $v->_compare($string);
# my $bool = $v eq $string;
#
# Check whether the vector stringifies to $string.
#
sub _compare_string {
    my ($self, $str) = @_;
    return $self->as_string eq $str;
}


1;
__END__