Menu

#12 Patch for class forward declarations

v3.5.0
open
nobody
5
2001-08-25
2001-08-25
No

Submitted by James Yu on Fri, 19 May 2000 15:51:33
-0400

Tom,

I have been using perceps for a while now and here
is another problem I found.

Problem:

Perceps treat the line:
class Original;

as declaring the Orignal as a global variable with
type class, thus it changes the $itype("Original")
to be of type $GLOBAL and thus {foreach class}
loop won't return it.

Fix:

The fix is quite easy, I located the PROCVAR
function and check for lines starting with "class"
or "using" that I know it won't be a global
variable or function definition.

Here is the modified version of entire subroutine of
PROCVAR:

-James Yu

-----------

sub PROCVAR {

local($block,$npc,$useall)=@_;
local($gname,$mmem,@multidef,$type);

$block=~s/\n/ /g;

if
($block=~/^\s*([\w<>:\,\s\*&]*[\w<>:\*&]\s[\s\*&]*)(\w[\w\s\[\]\:]*)\s*(\=*\
s*[^,;]*)([,;])/) {
$type=$1;
if ($type=~/class/) {
# class formard declaration,
# ignored
}
elsif ($type=~/using/) {
# use name space,
# ignored
}

else {
$gname=$2;
$args{$gname}=$3;
if ($4 eq ",") {
@multidef=split(",",$_);
for ($mmem=1;$mmem<=$#multidef;$mmem++) {
if
($multidef[$mmem]=~/\s*([\*&]?)\s*(\w[\w\s\[\]\:]+)\s*(\=*\s*[^;]*)/
) {
$gname.=", $1$2";
$args{$gname}=$3;
}
}
}
$type{$gname}=$1;

$modtime{$gname}=$modtime;

$itype{$gname}=$GLOBAL;

push(@gvars,$gname);
push(@items,$gname);

&DOINFO($block,$gname,$npc);
}
}
}

Discussion


Log in to post a comment.