In message <[EMAIL PROTECTED]> (on 14 December
2004 06:01:39 -0500), [EMAIL PROTECTED] (Michael G Schwern) wrote:
>On Tue, Dec 14, 2004 at 05:55:29AM -0500, Ed Allen Smith wrote:
>> >It appears something's gone wrong with the macro filtering. Do you have
>> >Filter::cpp installed? What version?
>>
>> 1.03. If this doesn't do it, perhaps Tie::VecArray should have a PREREQ_PM
>> with an adequate version number for Filter::cpp in it? I do note the date on
>> Filter::cpp 1.03's manpage as being in 1995...
>
>No, that's the latest version.
Ok.
>Tie::VecArray doesn't actually require Filter::cpp, but it uses it if
>available.
Ah! Understood.
>> In other words:
>> perl -V:cppstdin
>> cppstdin='cppstdin';
>>
>> perl -V:cppminus
>> cppminus='';
>>
>> A cpp does exist on IRIX, although it is not something I would advise using;
>> acpp (ANSI C preprocessor) is better, but may go away - cc -E is
>
>Could you send me the output of: cppstdin < lib/Tie/VecArray.pm
No problem (assuming you mean me to run this in
/.cpanplus/5.8.0/build/Tie-VecArray-0.01); see below for results:
cppstdin < lib/Tie/VecArray.pm
#line 1 ".6696.c"
package Tie::VecArray;
use strict;
use vars qw($VERSION);
$VERSION = '0.01';
use POSIX qw(ceil);
cc-1011 cc: ERROR File = .6696.c, Line = 9
The indicated directive is not a recognized preprocessing directive.
# These are protected data members.
^
use fields qw(bits vec size);
use base qw(Tie::Array);
=pod
=head1 NAME
Tie::VecArray - An array interface to a bit vector.
=head1 SYNOPSIS
require Tie::VecArray;
$vector = '';
vec($vector, 0, 32) = 33488897;
cc-1011 cc: ERROR File = .6696.c, Line = 28
The indicated directive is not a recognized preprocessing directive.
# Tie the vector to an array as 8 bits.
^
$obj = tie @array, 'Tie::VecArray', 8, $vector;
@array[0..3] = qw(1 255 256 -1);
cc-1011 cc: ERROR File = .6696.c, Line = 33
The indicated directive is not a recognized preprocessing directive.
# SURPRISE! Its 1, 255, 0, 255!
^
print @array[0..3];
cc-1011 cc: ERROR File = .6696.c, Line = 36
The indicated directive is not a recognized preprocessing directive.
# Look at the same vector as a 32 bit vector.
^
$obj->bits(32);
cc-1011 cc: ERROR File = .6696.c, Line = 39
The indicated directive is not a recognized preprocessing directive.
# Back to 33488897
^
print $array[0];
=head1 DESCRIPTION
This module implements an array interface to a bit vector.
=head2 Method
=over 4
=item B<tie>
$vec_obj = tie(@array, 'Tie::VecArray', $bits);
$vec_obj = tie(@array, 'Tie::VecArray', $bits, $vec);
Creates a new @array tied to a bit vector. $bits is the number of
bits which will be passed to C<vec()> to interpret the vector.
If $vec is given that will be used as the bit vector, otherwise the
vector will start out empty.
=item B<bits>
$bits = $vec_obj->bits;
$vec_obj->bits($bits);
Get/set the bit size we'll use to interpret the vector.
When setting the bit size the length of the array might be ambiguous.
(For instance, going from a one bit vector with five entries to a two
bit vector... do you have two or three entries?) The length of the
array will always round up. This can cause odd things to happen.
Consider:
$vec_obj = tie @vec, 'Tie::VecArray', 1;
cc-1011 cc: ERROR File = .6696.c, Line = 78
The indicated directive is not a recognized preprocessing directive.
# A one bit vector with 5 entries.
^
@vec[0..4] = (1) x 5;
cc-1011 cc: ERROR File = .6696.c, Line = 81
The indicated directive is not a recognized preprocessing directive.
# prints a size of 5, as expected.
^
print scalar @vec;
cc-1011 cc: ERROR File = .6696.c, Line = 84
The indicated directive is not a recognized preprocessing directive.
# Switch to two bit interpretation.
^
$vec_obj->bits(2);
cc-1011 cc: ERROR File = .6696.c, Line = 87
The indicated directive is not a recognized preprocessing directive.
# This returns 3 since it will round up.
^
print scalar @vec;
cc-1011 cc: ERROR File = .6696.c, Line = 90
The indicated directive is not a recognized preprocessing directive.
# Switch back to one bit.
^
$vec_obj->bits(1);
cc-1011 cc: ERROR File = .6696.c, Line = 93
The indicated directive is not a recognized preprocessing directive.
# Whoops, 6!
^
print scalar @vec;
=cut
cc-1011 cc: ERROR File = .6696.c, Line = 98
The indicated directive is not a recognized preprocessing directive.
#'#
^
cc-1011 cc: ERROR File = .6696.c, Line = 100
The indicated directive is not a recognized preprocessing directive.
# Let's not require Filter::cpp.
^
BEGIN { eval 'use Filter::cpp' }
sub _IDX2BYTES {
my Tie::VecArray $self = shift;
my $idx = shift;
cc-1040 cc: ERROR File = .6696.c, Line = 105
An identifier is expected.
#define _IDX2BYTES($self, $idx) \
^
cc-1040 cc: ERROR File = .6696.c, Line = 105
An identifier is expected.
#define _IDX2BYTES($self, $idx) \
^
}
sub _BYTES2IDX {
my Tie::VecArray $self = shift;
my $bytes = shift;
cc-1040 cc: ERROR File = .6696.c, Line = 112
An identifier is expected.
#define _BYES2IDX($self, $bytes) \
^
cc-1040 cc: ERROR File = .6696.c, Line = 112
An identifier is expected.
#define _BYES2IDX($self, $bytes) \
^
}
sub TIEARRAY {
my($class, $bits, $vec) = @_;
no strict 'refs';
my Tie::VecArray $self = bless [\%{$class.'::FIELDS'}], $class;
$vec = '' unless defined $vec;
$self->{bits} = $bits;
$self->{vec} = $vec;
$self->{size} = _BYTES2IDX($self, length $vec);
return $self;
}
sub FETCH {
my Tie::VecArray $self = shift;
return vec($self->{vec}, $_[0], $self->{bits});
}
sub STORE {
my Tie::VecArray $self = shift;
$self->{size} = $_[0] + 1 if $self->{size} < $_[0] + 1;
return vec($self->{vec}, $_[0], $self->{bits}) = $_[1];
}
sub FETCHSIZE {
my Tie::VecArray $self = shift;
return $self->{size};
}
sub STORESIZE {
my Tie::VecArray $self = shift;
my $new_size = shift;
if( $self->{size} > $new_size ) {
cc-1011 cc: ERROR File = .6696.c, Line = 152
The indicated directive is not a recognized preprocessing directive.
# clip the vector down to size.
^
cc-1055 cc: ERROR File = .6696.c, Line = 153
A macro invocation has too many arguments.
my $new_length = _IDX2BYTES($self, $new_size);
^
my $new_length = ceil($idx * ($self->{bits}/8));
substr($self->{vec}, $new_length) = '' if
$new_length < length $self->{vec};
}
$self->{size} = $new_size;
}
sub CLEAR {
my Tie::VecArray $self = shift;
$self->{vec} = '';
$self->{size} = 0;
}
sub bits {
my Tie::VecArray $self = shift;
if(@_) {
my $bits = shift;
$self->{size} = ceil($self->{size} * $self->{bits} / $bits);
$self->{bits} = $bits;
}
return $self->{bits};
}
=pod
=head1 AUTHOR
Michael G Schwern <[EMAIL PROTECTED]>
=head1 SEE ALSO
L<perlfunc/vec>, L<Tie::Array>
=cut
1;
19 errors detected in the compilation of ".6696.c".
>--
>Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern/
>"That's what Jagulars always do," said Pooh, much interested. "They call
>'Help! Help!' and then when you look up they drop down on you."
>
--
Allen Smith http://cesario.rutgers.edu/easmith/
There is only one sound argument for democracy, and that is the argument
that it is a crime for any man to hold himself out as better than other men,
and, above all, a most heinous offense for him to prove it. - H. L. Mencken