From: dpvc v. a. <we...@ma...> - 2005-08-13 17:31:18
|
Log Message: ----------- Fixed a problem with redefine when used with classes that store their data in a on-standard form (i.e., by overridding the create() method). Now they can define uncreate() to get the original data back for use with redefine(). Modified Files: -------------- pg/lib/Parser/Context: Constants.pm Variables.pm pg/lib/Value/Context: Data.pm Revision Data ------------- Index: Constants.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Constants.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/Parser/Context/Constants.pm -Llib/Parser/Context/Constants.pm -u -r1.3 -r1.4 --- lib/Parser/Context/Constants.pm +++ lib/Parser/Context/Constants.pm @@ -16,12 +16,13 @@ } # -# Create data for constants +# Create/Uncreate data for constants # sub create { my $self = shift; my $value = shift; return {value => $value, keepName => 1}; } +sub uncreate {shift; (shift)->{value}} # # Return a constant's value Index: Variables.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Variables.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -Llib/Parser/Context/Variables.pm -Llib/Parser/Context/Variables.pm -u -r1.8 -r1.9 --- lib/Parser/Context/Variables.pm +++ lib/Parser/Context/Variables.pm @@ -61,6 +61,7 @@ } return {type => $value, @extra}; } +sub uncreate {shift; (shift)->{type}}; # # Return a variable's type Index: Data.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Context/Data.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Value/Context/Data.pm -Llib/Value/Context/Data.pm -u -r1.7 -r1.8 --- lib/Value/Context/Data.pm +++ lib/Value/Context/Data.pm @@ -26,6 +26,7 @@ # sub init {} sub create {shift; shift} +sub uncreate {shift; shift} # # Sort names so that they can be joined for regexp matching @@ -158,7 +159,7 @@ Value::Error("No definition for %s '%s' in the given context",$self->{name},$y) unless $from->{$self->{dataName}}{$y}; push(@remove,$x) if $self->get($x); - push(@data,$x => $from->{$self->{dataName}}{$y}); + push(@data,$x => $self->uncreate($from->{$self->{dataName}}{$y})); } $self->remove(@remove); $self->add(@data); |