3 # This file is part of Language::Befunge::Vector::XS.
4 # Copyright (c) 2008 Jerome Quelin, all rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
20 void* intArrayPtr(int num) {
22 mortal = sv_2mortal( NEWSV(0, num * sizeof(intArray)) );
27 MODULE = Language::Befunge::Vector::XS PACKAGE = Language::Befunge::Vector::XS
33 # my $vec = LB::Vector->new( $x [, $y, ...] );
35 # Create a new vector. The arguments are the actual vector data; one
36 # integer per dimension.
39 new( class, array, ... )
50 /* create the object and populate it */
52 for ( i=0; i<ix_array; i++ ) {
53 val = newSViv( array[i] );
57 /* Return a blessed reference to the AV */
58 RETVAL = newRV_noinc( (SV *)self );
59 stash = gv_stashpv( class, TRUE );
60 sv_bless( (SV *)RETVAL, stash );
67 # my $vec = Language::Befunge::Vector::XS->new_zeroes( $dims );
69 # Create a new vector, set to the origin. The only argument is the dimension of
70 # the vector to be created.
72 # ->new_zeroes(2) is exactly equivalent to ->new([0,0])
75 new_zeroes( class, dimension )
86 /* create the object and populate it */
88 for ( i=0; i<dimension; i++ ) {
93 /* return a blessed reference to the AV */
94 RETVAL = newRV_noinc( (SV *)self );
95 stash = gv_stashpv( class, TRUE );
96 sv_bless( (SV *)RETVAL, stash );
106 # my $dims = $vec->get_dims;
108 # Return the number of dimensions, an integer.
115 RETVAL = av_len(self) + 1;
121 # my $val = $vec->get_component( $index );
123 # Return the value for dimension $index.
126 get_component( self, index )
134 val = av_fetch(self, index, 0);