From bd8b2ed47374cbef028d54c467edb887e2962dfd Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 26 Nov 2013 14:04:29 +0000 Subject: [PATCH] Decorate code to identify state mix-in methods and enforce proper usage. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1204 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 3 ++- OvaleCooldown.lua | 3 ++- OvaleFuture.lua | 3 ++- OvalePaperDoll.lua | 3 ++- OvalePower.lua | 3 ++- OvaleRunes.lua | 3 ++- compiler.pl | 28 ++++++++++++++++++++++++++++ 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index eb6b880..97d04e7 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -631,7 +631,7 @@ function OvaleAura:ApplySpellOnHit(state, spellId, startCast, endCast, nextCast, end -- --- Mix-in methods for simulator state. +-- do local statePrototype = OvaleAura.statePrototype @@ -888,3 +888,4 @@ do aura.stacks = 1 end end +-- diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua index 7b17a6f..edcbd4b 100644 --- a/OvaleCooldown.lua +++ b/OvaleCooldown.lua @@ -163,7 +163,7 @@ function OvaleCooldown:ApplySpellAfterCast(state, spellId, startCast, endCast, n end -- --- Mix-in methods for simulator state. +-- do local statePrototype = OvaleCooldown.statePrototype @@ -206,3 +206,4 @@ do end end end +-- diff --git a/OvaleFuture.lua b/OvaleFuture.lua index 1aaebb1..45e9e7a 100644 --- a/OvaleFuture.lua +++ b/OvaleFuture.lua @@ -602,7 +602,7 @@ function OvaleFuture:ApplySpellStartCast(state, spellId, startCast, endCast, nex end -- --- Mix-in methods for simulator state. +-- do local statePrototype = OvaleFuture.statePrototype @@ -610,3 +610,4 @@ do return state.counter[id] and state.counter[id] or 0 end end +-- diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua index ef7c861..d308d64 100644 --- a/OvalePaperDoll.lua +++ b/OvalePaperDoll.lua @@ -508,7 +508,7 @@ function OvalePaperDoll:ResetState(state) end -- --- Mix-in methods for simulator state. +-- do local statePrototype = OvalePaperDoll.statePrototype @@ -528,3 +528,4 @@ do return 1 + state.snapshot.spellHaste / 100 end end +-- diff --git a/OvalePower.lua b/OvalePower.lua index 91c2314..9a68488 100644 --- a/OvalePower.lua +++ b/OvalePower.lua @@ -306,7 +306,7 @@ function OvalePower:ApplySpellAfterCast(state, spellId, startCast, endCast, next end -- --- Mix-in methods for simulator state. +-- do local statePrototype = OvalePower.statePrototype @@ -317,3 +317,4 @@ do end end end +-- \ No newline at end of file diff --git a/OvaleRunes.lua b/OvaleRunes.lua index 62b865e..720e1f7 100644 --- a/OvaleRunes.lua +++ b/OvaleRunes.lua @@ -219,7 +219,7 @@ function OvaleRunes:ApplySpellAfterCast(state, spellId, startCast, endCast, next end -- --- Mix-in methods for simulator state. +-- do local statePrototype = OvaleRunes.statePrototype @@ -441,3 +441,4 @@ do end end end +-- diff --git a/compiler.pl b/compiler.pl index e164ff0..d368899 100644 --- a/compiler.pl +++ b/compiler.pl @@ -16,6 +16,9 @@ -- -- + +-- +-- =cut $m{"AceAddon-3.0"}{GetModule} = true; @@ -253,6 +256,15 @@ sub ParseDirectory } } + if ($content =~ m/(.*)<\/state-methods>/s) + { + my $p = $1; + while ($p =~ m/statePrototype\.(\w+)/g) + { + $smm{$1} = true; + } + } + while ($content =~ m/\b([A-Z]\w+)\.(\w+)/g) { unless ($sp{$1}{$2} or $p{$1}{$2}) @@ -269,6 +281,14 @@ sub ParseDirectory } } + while ($content =~ m/\bstate\:(\w+)/g) + { + unless ($smm{$1}) + { + $smm{$1} = $class; + } + } + while ($content =~ m/self\.([a-z]\w*)/g) { #if ($class eq 'OvaleSwing') @@ -334,3 +354,11 @@ for my $class (keys %sp) } } } + +for my $method (keys %smm) +{ + unless ($smm{$method} eq true) + { + print "state:$method $smm{$method}\n"; + } +} -- 1.7.9.5