Quantcast

Decorate code to identify state mix-in methods and enforce proper usage.

Johnny C. Lam [11-26-13 - 14:04]
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
Filename
OvaleAura.lua
OvaleCooldown.lua
OvaleFuture.lua
OvalePaperDoll.lua
OvalePower.lua
OvaleRunes.lua
compiler.pl
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
 --</public-static-methods>

--- Mix-in methods for simulator state.
+--<state-methods>
 do
 	local statePrototype = OvaleAura.statePrototype

@@ -888,3 +888,4 @@ do
 		aura.stacks = 1
 	end
 end
+--</state-methods>
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
 --</public-static-methods>

--- Mix-in methods for simulator state.
+--<state-methods>
 do
 	local statePrototype = OvaleCooldown.statePrototype

@@ -206,3 +206,4 @@ do
 		end
 	end
 end
+--</state-methods>
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
 --</public-static-methods>

--- Mix-in methods for simulator state.
+--<state-methods>
 do
 	local statePrototype = OvaleFuture.statePrototype

@@ -610,3 +610,4 @@ do
 		return state.counter[id] and state.counter[id] or 0
 	end
 end
+--</state-methods>
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
 --</public-static-methods>

--- Mix-in methods for simulator state.
+--<state-methods>
 do
 	local statePrototype = OvalePaperDoll.statePrototype

@@ -528,3 +528,4 @@ do
 		return 1 + state.snapshot.spellHaste / 100
 	end
 end
+--</state-methods>
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
 --</public-static-methods>

--- Mix-in methods for simulator state.
+--<state-methods>
 do
 	local statePrototype = OvalePower.statePrototype

@@ -317,3 +317,4 @@ do
 		end
 	end
 end
+--</state-methods>
\ 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
 --</public-static-methods>

--- Mix-in methods for simulator state.
+--<state-methods>
 do
 	local statePrototype = OvaleRunes.statePrototype

@@ -441,3 +441,4 @@ do
 		end
 	end
 end
+--</state-methods>
diff --git a/compiler.pl b/compiler.pl
index e164ff0..d368899 100644
--- a/compiler.pl
+++ b/compiler.pl
@@ -16,6 +16,9 @@

 --<public-properties>
 --</public-properties>
+
+--<state-methods>
+--</state-methods>
 =cut

 $m{"AceAddon-3.0"}{GetModule} = true;
@@ -253,6 +256,15 @@ sub ParseDirectory
 				}
 			}

+			if ($content =~ m/<state-methods>(.*)<\/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";
+	}
+}