Not in any hurry, I applied the microscope to the new method and docs today. Here are his docs for the method:
new Resources ($resfile);
Creates a new resource database, initialized with the defaults for class Resources (see below for a list of them).
If a nonempty file name is specified in $resfile, it initializes the object with the content of the so named resource file. For safe (non overwriting) loading, see the load method below.
If the special file name "_RES_NODEFAULTS" is specified, the object is created completely empty, with not even the Resources class defaults in it.
Returns the new object, or undef in case of error.
To me, these docs were fraught with confusion. After looking at the source code, I have created the following docs:
The method behavior is based on:
In case 1.1, the object is created completely empty, with NO resources whatsoever.
In both case 1.2 and case 2, the "CORE" resources from Resources.pm are bound to the object. In case 1.2, the object is further initialized via a call to $res->load($resfile)
I am including the source code for his new method for your reference:
sub new { my $type = shift; my $resfile = shift; my ($name, $valdoc, $app); my $res = bless {}; $res->{Load} = 0; # 1 if loading $res->{Merge} = 0; # 1 if merging $res->{Wilds} = {}; # Wildcarded resources. $res->{Res} = {}; # Named resources. $res->{Owned} = {}; # Inverted index of member clases. $res->{Isa} = {}; # Inverted index of base classes. # Safe environment for the evaluation of constructors. $res->{Safe} = new Safe or ($res->_error("new", "can't get a Safe object."), return undef); # Hack hack - the special filename "_RES_NODEFAULTS" is # used to prevent resource initialization (e.g. when called by the # "bypattern" method unless ($resfile and $resfile eq "_RES_NODEFAULTS") { # Must make sure this is not overridden by a wildcard $res->{Wilds}->{'.*resources\.updates'} = [0]; $res->{Res}->{'resources.updates'}->[$Value] = 0; # Get appclass without extensions if (($app = $Resources{'resources.appclass'}->[$Value]) =~ /\./) + { $Resources{'resources.appclass'}->[$Value] = (split(/\./, $app))[ +0]; } # Bootstrap defaults. We don't want any subclassing here while (($name, $valdoc) = CORE::each(%Resources)) { $res->{Res}->{$name} = $valdoc; } } if ($resfile and $resfile ne "_RES_NODEFAULTS") { $res->load($resfile) || ($res->_error("new", "can't load"), return undef); } $res; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rewording the Resources docs
by graff (Chancellor) on Oct 26, 2003 at 01:12 UTC | |
|
Re: Rewording the Resources docs
by Anonymous Monk on Oct 26, 2003 at 05:46 UTC | |
|
Re: Rewording the Resources docs
by princepawn (Parson) on Oct 26, 2003 at 07:50 UTC | |
by simonm (Vicar) on Oct 26, 2003 at 22:24 UTC | |
by princepawn (Parson) on Oct 27, 2003 at 11:20 UTC |