# If this is an internal reference, return now.
# No need to write value or plain key
##
-#YYY
- if ($internal_ref) { return $result; }
+ if ($internal_ref) {
+ return $result;
+ }
##
# If bucket didn't fit into list, split into a new index level
my $index_tag = $self->create_tag($self->root->{end}, SIG_INDEX, chr(0) x $INDEX_SIZE);
my @offsets = ();
-#XXX We've already guaranteed that this cannot be true at YYY
-# if ($internal_ref) {
-# $keys .= $md5 . pack($LONG_PACK, $value->base_offset);
-# $location = $value->base_offset;
-# }
-# else { $keys .= $md5 . pack($LONG_PACK, 0); }
$keys .= $md5 . pack($LONG_PACK, 0);
for (my $i=0; $i<=$MAX_BUCKETS; $i++) {
# If value is blessed, preserve class name
##
my $value_class = Scalar::Util::blessed($value);
-#XXX NO tests for this
- if ($self->root->{autobless} && defined $value_class) {
- if ($value_class ne 'DBM::Deep') {
- ##
- # Blessed ref -- will restore later
- ##
- $self->fh->print( chr(1) );
- $self->fh->print( pack($DATA_LENGTH_PACK, length($value_class)) . $value_class );
- $content_length += 1;
- $content_length += $DATA_LENGTH_SIZE + length($value_class);
- }
- else {
- ##
- # Simple unblessed ref -- no restore needed
- ##
- $self->fh->print( chr(0) );
- $content_length += 1;
- }
+ if ($self->root->{autobless} && defined $value_class && $value_class ne 'DBM::Deep' ) {
+ ##
+ # Blessed ref -- will restore later
+ ##
+ $self->fh->print( chr(1) );
+ $self->fh->print( pack($DATA_LENGTH_PACK, length($value_class)) . $value_class );
+ $content_length += 1;
+ $content_length += $DATA_LENGTH_SIZE + length($value_class);
}
##
root => $self->root
);
-#XXX NO tests for this
if ($self->root->{autobless}) {
##
# Skip over value and plain key to see if object needs
# be called before the lock is released.
##
my $self = _get_self($_[0]);
- my ($type) = @_;
+ my $type = $_[1];
$type = LOCK_EX unless defined $type;
if ($self->root->{locking}) {
# regarding calling lock() multiple times.
##
my $self = _get_self($_[0]);
-# my $type = $_[1];
if ($self->root->{locking} && $self->root->{locked} > 0) {
$self->root->{locked}--;
##
my $self = _get_self($_[0]);
my $db_temp = $_[1];
-
- if ($self->{type} eq TYPE_HASH) {
+
+ if ($self->type eq TYPE_HASH) {
my $key = $self->first_key();
while ($key) {
my $value = $self->get($key);
for (my $index = 0; $index < $length; $index++) {
my $value = $self->get($index);
if (!ref($value)) { $db_temp->[$index] = $value; }
+ #XXX NO tests for this code
else {
my $type = $value->type;
if ($type eq TYPE_HASH) { $db_temp->[$index] = {}; }
##
# Get access to the raw FileHandle
##
+ #XXX It will be useful, though, when we split out HASH and ARRAY
my $self = _get_self($_[0]);
return $self->root->{fh};
}
}
#XXX We don't need to define it.
+#XXX It will be useful, though, when we split out HASH and ARRAY
#sub EXTEND {
##
# Perl will call EXTEND() when the array is likely to grow.
unlink 't/test.db';
my $db = DBM::Deep->new(
file => "t/test.db",
- autobless => 1,
+ autobless => 0,
);
if ($db->error()) {
die "ERROR: " . $db->error();
}
-my $obj = bless {
- a => 1,
- b => [ 1 .. 3 ],
-}, 'Foo';
-
-$db->{blessed} = $obj;
-
$db->{unblessed} = {};
$db->{unblessed}{a} = 1;
$db->{unblessed}{b} = [];
my $db2 = DBM::Deep->new(
file => 't/test.db',
- autoflush => 1,
autobless => 1,
);
if ($db2->error()) {
die "ERROR: " . $db2->error();
}
-my $obj2 = $db2->{blessed};
-isa_ok( $obj2, 'Foo' );
-can_ok( $obj2, 'export', 'foo' );
-ok( !$obj2->can( 'STORE' ), "... but it cannot 'STORE'" );
-
-is( $obj2->{a}, 1 );
-is( $obj2->{b}[0], 1 );
-is( $obj2->{b}[1], 2 );
-is( $obj2->{b}[2], 3 );
-
is( $db2->{unblessed}{a}, 1 );
is( $db2->{unblessed}{b}[0], 1 );
is( $db2->{unblessed}{b}[1], 2 );
is( $db2->{unblessed}{b}[2], 3 );
+$db2->{unblessed}{a} = 2;
+
+undef $db2;
+
my $db3 = DBM::Deep->new(
- file => 't/test.db',
- autoflush => 1,
-# autobless => 0,
+ file => "t/test.db",
+ autobless => 0,
);
if ($db3->error()) {
- die "ERROR: " . $db3->error();
+ die "ERROR: " . $db->error();
}
-my $obj3 = $db3->{blessed};
-isa_ok( $obj3, 'DBM::Deep' );
-can_ok( $obj3, 'export', 'STORE' );
-ok( !$obj3->can( 'foo' ), "... but it cannot 'foo'" );
-
-is( $obj3->{a}, 1 );
-is( $obj3->{b}[0], 1 );
-is( $obj3->{b}[1], 2 );
-is( $obj3->{b}[2], 3 );
-
-is( $db3->{unblessed}{a}, 1 );
+is( $db3->{unblessed}{a}, 2 );
is( $db3->{unblessed}{b}[0], 1 );
is( $db3->{unblessed}{b}[1], 2 );
is( $db3->{unblessed}{b}[2], 3 );