Front page | perl.perl5.porters |
Postings from October 2003
Making Storable use the reference I provide from STORABLE_thaw
Thread Next
From:
Dave Rolsky
Date:
October 4, 2003 12:33
Subject:
Making Storable use the reference I provide from STORABLE_thaw
Message ID:
Pine.LNX.4.58.0310041354520.5779@urth.org
diff -u ../Storable-2.08/Storable.pm ./Storable.pm
--- ../Storable-2.08/Storable.pm 2003-07-29 02:06:35.000000000 -0500
+++ ./Storable.pm 2003-10-04 14:28:13.000000000 -0500
@@ -688,6 +688,10 @@
It is up to you to use this information to populate I<obj> the way you want.
+If you want to substitute a I<different> object for the one storable
+creates, you can assign directly to C<$_[0]>, and storable will return
+the object assigned to $_[0] from the results of the thawing operation.
+
Returned value: none.
=back
diff -u ../Storable-2.08/Storable.xs ./Storable.xs
--- ../Storable-2.08/Storable.xs 2003-09-05 13:42:41.000000000 -0500
+++ ./Storable.xs 2003-10-04 14:20:28.000000000 -0500
@@ -3757,6 +3757,7 @@
SV *hook;
SV *sv;
SV *rv;
+ SV *return_sv;
int obj_type;
int clone = cxt->optype & ST_CLONE;
char mtype = '\0';
@@ -4035,6 +4036,9 @@
rv = newRV(sv);
(void) scalar_call(rv, hook, clone, av, G_SCALAR|G_DISCARD);
+
+ return_sv = SvRV(rv);
+
SvREFCNT_dec(rv);
/*
@@ -4053,25 +4057,25 @@
*/
if (!extra_type)
- return sv;
+ return return_sv;
- TRACEME(("retrieving magic object for 0x%"UVxf"...", PTR2UV(sv)));
+ TRACEME(("retrieving magic object for 0x%"UVxf"...", PTR2UV(return_sv)));
rv = retrieve(cxt, 0); /* Retrieve <magic object> */
TRACEME(("restoring the magic object 0x%"UVxf" part of 0x%"UVxf,
- PTR2UV(rv), PTR2UV(sv)));
+ PTR2UV(rv), PTR2UV(return_sv)));
switch (extra_type) {
case SHT_TSCALAR:
- sv_upgrade(sv, SVt_PVMG);
+ sv_upgrade(return_sv, SVt_PVMG);
break;
case SHT_TARRAY:
- sv_upgrade(sv, SVt_PVAV);
- AvREAL_off((AV *)sv);
+ sv_upgrade(return_sv, SVt_PVAV);
+ AvREAL_off((AV *)return_sv);
break;
case SHT_THASH:
- sv_upgrade(sv, SVt_PVHV);
+ sv_upgrade(return_sv, SVt_PVHV);
break;
default:
CROAK(("Forgot to deal with extra type %d", extra_type));
@@ -4100,10 +4104,10 @@
* into the existing design. -- RAM, 17/02/2001
*/
- sv_magic(sv, rv, mtype, Nullch, 0);
+ sv_magic(return_sv, rv, mtype, Nullch, 0);
SvREFCNT_dec(rv); /* Undo refcnt inc from sv_magic() */
- return sv;
+ return return_sv;
}
/*
Only in .: storable-patch
Common subdirectories: ../Storable-2.08/t and ./t
Thread Next
-
Making Storable use the reference I provide from STORABLE_thaw
by Dave Rolsky