r24750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24749‎ | r24750 | r24751 >
Date:17:39, 13 August 2007
Author:kim
Status:old
Tags:
Comment:
Somewhat working ra3... I'm now busy messing with it while
editing all of Omegawiki at once. Bwahahahaaa POWER!
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/small/autoreplace.sh (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/small/ra3.pl (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/small/ra3.pl
@@ -40,47 +40,67 @@
4141 # trying to _cut down_ on the number of errors, we don't
4242 # eliminate them entirely, since we're just running this
4343 # script once, after all
44 - if (/\{/) {
 44+ if (/\{/) { # Block start
4545 $block_num++;
4646 unshift(@block_stack, $block_num);
4747 }
4848
49 - if (/\}/) {
 49+ if (/\}/) { #Block end
5050 my $end=shift(@block_stack);
5151 }
5252
53 - if (/\;/) {
54 - my @matches=[];
55 - $statement=~/^(\s*).*/;
56 - my $indent=$1;
57 - if ($global) {
58 - @matches=($statement=~/\$(\w+)(Attributes?|Structure)/g);
59 - if (@matches) {
60 - $globals{$block_stack[0]}=joinpairs(@matches);
61 - $statement=~s/\$(\w+)(Attributes?|Structure)\;/;/g;
62 - $statement=~s/\$(\w+)(Attributes?|Structure)\W//gm;
63 - #$statement=~s/;/ ,;/ if $statement=~/global.*\$\w*(.*);/gs; # if there are still params left, we need a comma
64 - $statement=~s/;/;\n$indent\$o=OmegaWikiAttributes::getInstance();/g;
 53+ if (/\;/) { #found a statement terminator.
 54+ if (not $statement=~/^\s*\/\// or $statement=~/^\s*\#/) {
 55+ my @matches=[];
 56+ $statement=~/^(\s*).*/;
 57+ my $indent=$1;
 58+ if ($global) {
 59+ @matches=($statement=~/\$(\w+)(Attributes?|Structure)/g);
 60+ if (@matches) {
 61+ $globals{$block_stack[0]}=joinpairs(@matches);
 62+ $statement=~s/\$(\w+)(Attributes?|Structure)\;/;/g;
 63+ $statement=~s/\$(\w+)(Attributes?|Structure)\W//gm;
 64+ #$statement=~s/;/ ,;/ if $statement=~/global.*\$\w*(.*);/gs; # if there are still params left, we need a comma
 65+ print "\n${indent}\$o=OmegaWikiAttributes::getInstance();\n";
 66+ #my $target=";\n${indent}\$o=OmegaWikiAttributes::getInstance();";
 67+ #$statement=~s/;/$target/g;
 68+
 69+ }
 70+ $statement=~s/,\s*;/;/gm; # remove redundant trailing commas
 71+ $statement=~s/.*global\s*;\s*//gs; # perhaps the global statement is entirely redundant?
 72+ $statement=~s/^\s*$//gm; # remove empty lines (redundant now?)
 73+ $global=0; # end of global statement
6574 }
66 - $statement=~s/,\s*;/;/gm; # remove redundant trailing commas
67 - $statement=~s/.*global\s*;\s*//gs; # perhaps the global statement is entirely redundant?
68 - $statement=~s/^\s*$//gm; # remove empty lines (redundant now?)
69 - $global=0; # end of global statement
 75+ #$statement=~s/\$o\s*=\s*\$omegaWikiAttributes;/\$o=OmegaWikiAttributes::getInstance();/g;
 76+
 77+ my @tomatch; #matching only those vars found in the global statement
 78+ foreach my $block (@block_stack){
 79+ #print "$block\n";
 80+ if ($globals{$block}) {
 81+ my $items=$globals{$block};
 82+ push(@tomatch, @$items);
 83+ }
 84+ }
 85+
 86+ foreach my $item (@tomatch) {
 87+ #print ">".@$item[0].",".@$item[1]."\n";
 88+ my $name=@$item[0];
 89+ my $type=@$item[1];
 90+ my $ending=$type unless $type=="Attribute";
 91+ $statement=~s/\$($name)$type(\W)/\$o\-\>${name}${ending}$2/gm;
 92+ }
 93+ $statement=~s/->getAttributeValue\(\s*\$o->(\w+)\s*\)/->$1/g;
 94+ $statement=~s/\-\>setAttributeValue\(\s*\$o->(\w+)\s*,\s*(.*)\s*\)/->$1 = $2/g;
 95+ #print $block_stack[0].": ".$statement; # and peek too
 96+ #print "[".join(", ",@block_stack)."]\n";
7097 }
71 - #$statement=~s/\$o\s*=\s*\$omegaWikiAttributes;/\$o=OmegaWikiAttributes::getInstance();/g;
72 - #$tomatch=$globals{$block_stack[0]}
73 - $statement=~s/\$(\w+)Attribute(\W)/\$o\-\>$1$2/g;
74 - $statement=~s/\$(\w+)Attributes(\W)/\$o\-\>$1Attributes$2/g;
75 - $statement=~s/\$(\w+)Structure(\W)/\$o\-\>$1Structure$2/g;
76 - $statement=~s/->getAttributeValue\(\s*\$o->(\$\w+)\s*\);/->$1;/g;
77 - $statement=~s/->setAttributeValue\(\s*\$o->(\$\w+)\s*,\s*(.*)\s*\);/->$1 = $2;/g;
78 - #print $block_stack[0].": ".$statement; # and peek too
79 - #print "[".join(", ",@block_stack)."]\n";
80 - $statement="";
 98+ print $statement; # Write out this statement
 99+
 100+ $statement=""; # and start on a new one.
81101
82102 }
83 - print $block_stack[0].": ".$_;
 103+ #print $block_stack[0].": ".$_;
84104 }
85105 print $statement; # flush out any remaining lines
86106
87 -print Dumper(%globals);
 107+#print Dumper(%globals);
Index: trunk/extensions/Wikidata/OmegaWiki/small/autoreplace.sh
@@ -1,5 +1,5 @@
22 #!/bin/bash
33 export myfile=$1;
44
5 -small/raO.pl $myfile > $myfile.new &&
 5+small/ra3.pl $myfile > $myfile.new &&
66 mv $myfile.new $myfile

Status & tagging log