Quantcast

De-couple module dependencies so that load-order isn't as important.

Johnny C. Lam [11-17-13 - 16:29]
De-couple module dependencies so that load-order isn't as important.

- Initialize module dependencies at OnInitialize() for the module.
- Separate modules into core and non-core modules.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1189 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Ovale.toc
OvaleAura.lua
OvaleBestAction.lua
OvaleComboPoints.lua
OvaleCompile.lua
OvaleCooldown.lua
OvaleDamageTaken.lua
OvaleEclipse.lua
OvaleFuture.lua
OvaleOptions.lua
OvalePaperDoll.lua
OvalePool.lua
OvalePoolGC.lua
OvalePoolRefCount.lua
OvalePower.lua
OvaleQueue.lua
OvaleRecount.lua
OvaleRunes.lua
OvaleScore.lua
OvaleSkada.lua
OvaleSpellDamage.lua
OvaleState.lua
OvaleSwing.lua
OvaleTimeSpan.lua
compiler.pl
diff --git a/Ovale.toc b/Ovale.toc
index 2162fe2..280b66d 100644
--- a/Ovale.toc
+++ b/Ovale.toc
@@ -18,47 +18,48 @@ locales\locales.xml

 Ovale.lua

-# Modules with no dependencies
-OvaleActionBar.lua
-OvaleCondition.lua
-OvaleData.lua
-OvaleEnemies.lua
-OvaleEquipement.lua
-OvaleGUID.lua
-OvaleLatency.lua
+# Utility modules.
 OvalePool.lua
 OvalePoolGC.lua
 OvalePoolRefCount.lua
 OvaleQueue.lua
-OvaleScripts.lua
-scripts\scripts.xml
-OvaleSpellBook.lua
-OvaleStance.lua
 OvaleTimeSpan.lua
-#
-OvaleDamageTaken.lua
-OvalePaperDoll.lua
-OvaleScore.lua
-OvaleSpellDamage.lua
-OvaleState.lua
-OvaleSwing.lua
-#
+
+# Core modules.
+OvaleActionBar.lua
 OvaleAura.lua
+OvaleBestAction.lua
 OvaleComboPoints.lua
+OvaleCompile.lua
+OvaleCondition.lua
 OvaleCooldown.lua
+OvaleData.lua
+OvaleEquipement.lua
+OvaleFuture.lua
+OvaleGUID.lua
+OvaleLatency.lua
 OvaleOptions.lua
+OvalePaperDoll.lua
 OvalePower.lua
-OvaleRecount.lua
-OvaleSkada.lua
-#
-OvaleCompile.lua
-OvaleEclipse.lua
-OvaleFuture.lua
+OvaleScore.lua
+OvaleScripts.lua
+OvaleSpellBook.lua
+OvaleStance.lua
+OvaleState.lua
+
+# Core modules with dependencies.
 OvaleIcone.lua
 OvaleIcone.xml
+OvaleFrame.lua
+
+# Additional modules.
+OvaleDamageTaken.lua
+OvaleEclipse.lua
+OvaleEnemies.lua
+OvaleRecount.lua
 OvaleRunes.lua
-#
+OvaleSkada.lua
+OvaleSpellDamage.lua
+OvaleSwing.lua
 conditions\conditions.xml
-OvaleBestAction.lua
-#
-OvaleFrame.lua
+scripts\scripts.xml
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 5cb6bc1..ae79fad 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -16,12 +16,14 @@ local OvaleAura = Ovale:NewModule("OvaleAura", "AceEvent-3.0")
 Ovale.OvaleAura = OvaleAura

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvaleFuture = nil		-- forward declaration
-local OvaleGUID = Ovale.OvaleGUID
-local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvalePool = Ovale.OvalePool
-local OvaleState = Ovale.OvaleState
+
+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvaleFuture = nil
+local OvaleGUID = nil
+local OvalePaperDoll = nil
+local OvaleState = nil

 local ipairs = ipairs
 local pairs = pairs
@@ -62,7 +64,6 @@ local OVALE_DEBUFF_TYPES = {
 	Magic = true,
 	Poison = true,
 }
-local OVALE_UNIT_AURA_UNITS = OvaleGUID.UNIT_AURA_UNITS
 -- CLEU events triggered by auras being applied, removed, refreshed, or changed in stack size.
 local OVALE_CLEU_AURA_EVENTS = {
 	SPELL_AURA_APPLIED = true,
@@ -329,8 +330,16 @@ end
 --</private-static-methods>

 --<public-static-methods>
+function OvaleAura:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
+	OvaleFuture = Ovale.OvaleFuture
+	OvaleGUID = Ovale.OvaleGUID
+	OvalePaperDoll = Ovale.OvalePaperDoll
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleAura:OnEnable()
-	OvaleFuture = Ovale.OvaleFuture		-- resolve forward declaration
 	self_guid = OvaleGUID:GetGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:RegisterEvent("PLAYER_ENTERING_WORLD")
@@ -357,7 +366,7 @@ function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 		RemoveAurasForGUID(destGUID)
 	elseif OVALE_CLEU_AURA_EVENTS[event] then
 		local unitId = OvaleGUID:GetUnitId(destGUID)
-		if unitId and not OVALE_UNIT_AURA_UNITS[unitId] then
+		if unitId and not OvaleGUID.UNIT_AURA_UNITS[unitId] then
 			ScanUnitAuras(unitId, destGUID)
 		end
 	elseif mine and OVALE_CLEU_TICK_EVENTS[event] then
@@ -370,7 +379,7 @@ end
 function OvaleAura:PLAYER_ENTERING_WORLD(event)
 	Ovale:DebugPrint(OVALE_AURA_DEBUG, event)
 	-- Update auras on all visible units.
-	for unitId in pairs(OVALE_UNIT_AURA_UNITS) do
+	for unitId in pairs(OvaleGUID.UNIT_AURA_UNITS) do
 		ScanUnitAuras(unitId)
 	end
 	RemoveAurasForMissingUnits()
diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua
index 185def4..b1ff5f6 100644
--- a/OvaleBestAction.lua
+++ b/OvaleBestAction.lua
@@ -13,20 +13,22 @@ local OvaleBestAction = Ovale:NewModule("OvaleBestAction")
 Ovale.OvaleBestAction = OvaleBestAction

 --<private-static-properties>
-local OvaleActionBar = Ovale.OvaleActionBar
-local OvaleCondition = Ovale.OvaleCondition
-local OvaleCooldown = Ovale.OvaleCooldown
-local OvaleData = Ovale.OvaleData
-local OvaleEquipement = Ovale.OvaleEquipement
-local OvaleFuture = Ovale.OvaleFuture
-local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvalePool = Ovale.OvalePool
-local OvalePower = Ovale.OvalePower
-local OvaleSpellBook = Ovale.OvaleSpellBook
-local OvaleStance = Ovale.OvaleStance
-local OvaleState = Ovale.OvaleState
 local OvaleTimeSpan = Ovale.OvaleTimeSpan

+-- Forward declarations for module dependencies.
+local OvaleActionBar = nil
+local OvaleCondition = nil
+local OvaleCooldown = nil
+local OvaleData = nil
+local OvaleEquipement = nil
+local OvaleFuture = nil
+local OvalePaperDoll = nil
+local OvalePower = nil
+local OvaleSpellBook = nil
+local OvaleStance = nil
+local OvaleState = nil
+
 local abs = math.abs
 local floor = math.floor
 local ipairs = ipairs
@@ -702,6 +704,21 @@ local OVALE_COMPUTE_VISITOR =
 --</private-static-properties>

 --<public-static-methods>
+function OvaleBestAction:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleActionBar = Ovale.OvaleActionBar
+	OvaleCooldown = Ovale.OvaleCooldown
+	OvaleCondition = Ovale.OvaleCondition
+	OvaleData = Ovale.OvaleData
+	OvaleEquipement = Ovale.OvaleEquipement
+	OvaleFuture = Ovale.OvaleFuture
+	OvalePaperDoll = Ovale.OvalePaperDoll
+	OvalePower = Ovale.OvalePower
+	OvaleSpellBook = Ovale.OvaleSpellBook
+	OvaleStance = Ovale.OvaleStance
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleBestAction:StartNewAction()
 	OvaleState:Reset()
 	OvaleFuture:ApplyInFlightSpells()
diff --git a/OvaleComboPoints.lua b/OvaleComboPoints.lua
index 1076b5d..b5e3201 100644
--- a/OvaleComboPoints.lua
+++ b/OvaleComboPoints.lua
@@ -14,9 +14,10 @@ local OvaleComboPoints = Ovale:NewModule("OvaleComboPoints", "AceEvent-3.0")
 Ovale.OvaleComboPoints = OvaleComboPoints

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvaleGUID = Ovale.OvaleGUID
-local OvaleState = Ovale.OvaleState
+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvaleGUID = nil
+local OvaleState = nil

 local API_GetComboPoints = GetComboPoints
 local API_UnitClass = UnitClass
@@ -31,6 +32,13 @@ OvaleComboPoints.combo = 0
 --</public-static-properties>

 --<public-static-methods>
+function OvaleComboPoints:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
+	OvaleGUID = Ovale.OvaleGUID
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleComboPoints:OnEnable()
 	if self_class == "ROGUE" or self_class == "DRUID" then
 		self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index f69160e..cec5287 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -14,18 +14,20 @@ Ovale.OvaleCompile = OvaleCompile

 --<private-static-properties>
 local L = Ovale.L
-local OvaleCondition = Ovale.OvaleCondition
-local OvaleData = Ovale.OvaleData
-local OvaleEquipement = Ovale.OvaleEquipement
-local OvaleOptions = Ovale.OvaleOptions
-local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvalePool = Ovale.OvalePool
-local OvaleScore = Ovale.OvaleScore
-local OvaleScripts = Ovale.OvaleScripts
-local OvaleSpellBook = Ovale.OvaleSpellBook
-local OvaleStance = Ovale.OvaleStance
 local OvaleTimeSpan = Ovale.OvaleTimeSpan

+-- Forward declarations for module dependencies.
+local OvaleCondition = nil
+local OvaleData = nil
+local OvaleEquipement = nil
+local OvaleOptions = nil
+local OvalePaperDoll = nil
+local OvaleScore = nil
+local OvaleScripts = nil
+local OvaleSpellBook = nil
+local OvaleStance = nil
+
 local ipairs = ipairs
 local pairs = pairs
 local tonumber = tonumber
@@ -827,6 +829,19 @@ end
 --</private-static-methods>

 --<public-static-methods>
+function OvaleCompile:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleCondition = Ovale.OvaleCondition
+	OvaleData = Ovale.OvaleData
+	OvaleEquipement = Ovale.OvaleEquipement
+	OvaleOptions = Ovale.OvaleOptions
+	OvalePaperDoll = Ovale.OvalePaperDoll
+	OvaleScore = Ovale.OvaleScore
+	OvaleScripts = Ovale.OvaleScripts
+	OvaleSpellBook = Ovale.OvaleSpellBook
+	OvaleStance = Ovale.OvaleStance
+end
+
 function OvaleCompile:OnEnable()
 	self:RegisterMessage("Ovale_CheckBoxValueChanged", "EventHandler")
 	self:RegisterMessage("Ovale_EquipmentChanged")
diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua
index f5167a6..51ecb18 100644
--- a/OvaleCooldown.lua
+++ b/OvaleCooldown.lua
@@ -13,11 +13,12 @@ local OvaleCooldown = Ovale:NewModule("OvaleCooldown")
 Ovale.OvaleCooldown = OvaleCooldown

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvaleGUID = Ovale.OvaleGUID
-local OvalePaperDoll = Ovale.OvalePaperDoll
-local OvaleStance = Ovale.OvaleStance
-local OvaleState = Ovale.OvaleState
+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvaleGUID = nil
+local OvalePaperDoll = nil
+local OvaleStance = nil
+local OvaleState = nil

 local API_UnitHealth = UnitHealth
 local API_UnitHealthMax = UnitHealthMax
@@ -28,6 +29,15 @@ local self_class = select(2, API_UnitClass("player"))
 --</private-static-properties>

 --<public-static-methods>
+function OvaleCooldown:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
+	OvaleGUID = Ovale.OvaleGUID
+	OvalePaperDoll = Ovale.OvalePaperDoll
+	OvaleStance = Ovale.OvaleStance
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleCooldown:OnEnable()
 	OvaleState:RegisterState(self, self.statePrototype)
 end
diff --git a/OvaleDamageTaken.lua b/OvaleDamageTaken.lua
index f4a4908..17e347d 100644
--- a/OvaleDamageTaken.lua
+++ b/OvaleDamageTaken.lua
@@ -14,11 +14,13 @@ local OvaleDamageTaken = Ovale:NewModule("OvaleDamageTaken", "AceEvent-3.0")
 Ovale.OvaleDamageTaken = OvaleDamageTaken

 --<private-static-properties>
-local OvaleGUID = Ovale.OvaleGUID
-local OvaleLatency = Ovale.OvaleLatency
 local OvalePool = Ovale.OvalePool
 local OvaleQueue = Ovale.OvaleQueue

+-- Forward declarations for module dependencies.
+local OvaleGUID = nil
+local OvaleLatency = nil
+
 local select = select
 local API_GetTime = GetTime

@@ -46,6 +48,12 @@ end
 --</private-static-methods>

 --<public-static-methods>
+function OvaleDamageTaken:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleGUID = Ovale.OvaleGUID
+	OvaleLatency = Ovale.OvaleLatency
+end
+
 function OvaleDamageTaken:OnEnable()
 	self_guid = OvaleGUID:GetGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua
index aefc983..7c0edc0 100644
--- a/OvaleEclipse.lua
+++ b/OvaleEclipse.lua
@@ -16,16 +16,17 @@ local OvaleEclipse = Ovale:NewModule("OvaleEclipse", "AceEvent-3.0")
 Ovale.OvaleEclipse = OvaleEclipse

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvaleGUID = Ovale.OvaleGUID
-local OvaleSpellBook = Ovale.OvaleSpellBook
-local OvaleState = Ovale.OvaleState
-local SPELL_POWER_ECLIPSE = SPELL_POWER_ECLIPSE
+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvaleGUID = nil
+local OvaleSpellBook = nil
+local OvaleState = nil

 local select = select
 local API_GetEclipseDirection = GetEclipseDirection
 local API_UnitClass = UnitClass
 local API_UnitPower = UnitPower
+local SPELL_POWER_ECLIPSE = SPELL_POWER_ECLIPSE

 -- Player's GUID.
 local self_guid = nil
@@ -46,6 +47,14 @@ OvaleEclipse.eclipseDirection = 0
 --<public-static-properties>

 --<public-static-methods>
+function OvaleEclipse:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
+	OvaleGUID = Ovale.OvaleGUID
+	OvaleSpellBook = Ovale.OvaleSpellBook
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleEclipse:OnEnable()
 	if self_class == "DRUID" then
 		self_guid = OvaleGUID:GetGUID("player")
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 3d7249d..3a02fa4 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -15,16 +15,18 @@ local OvaleFuture = Ovale:NewModule("OvaleFuture", "AceEvent-3.0")
 Ovale.OvaleFuture = OvaleFuture

 --<private-static-properties>
-local OvaleAura = Ovale.OvaleAura
-local OvaleComboPoints = Ovale.OvaleComboPoints
-local OvaleData = Ovale.OvaleData
-local OvaleGUID = Ovale.OvaleGUID
-local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvalePool = Ovale.OvalePool
-local OvalePower = Ovale.OvalePower
-local OvaleScore = Ovale.OvaleScore
-local OvaleSpellBook = Ovale.OvaleSpellBook
-local OvaleState = Ovale.OvaleState
+
+-- Forward declarations for module dependencies.
+local OvaleAura = nil
+local OvaleComboPoints = nil
+local OvaleData = nil
+local OvaleGUID = nil
+local OvalePaperDoll = nil
+local OvalePower = nil
+local OvaleScore = nil
+local OvaleSpellBook = nil
+local OvaleState = nil

 local ipairs = ipairs
 local pairs = pairs
@@ -255,6 +257,19 @@ end
 --</private-static-methods>

 --<public-static-methods>
+function OvaleFuture:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleAura = Ovale.OvaleAura
+	OvaleComboPoints = Ovale.OvaleComboPoints
+	OvaleData = Ovale.OvaleData
+	OvaleGUID = Ovale.OvaleGUID
+	OvalePaperDoll = Ovale.OvalePaperDoll
+	OvalePower = Ovale.OvalePower
+	OvaleScore = Ovale.OvaleScore
+	OvaleSpellBook = Ovale.OvaleSpellBook
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleFuture:OnEnable()
 	self_guid = OvaleGUID:GetGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
diff --git a/OvaleOptions.lua b/OvaleOptions.lua
index adfb8ea..fc1517d 100644
--- a/OvaleOptions.lua
+++ b/OvaleOptions.lua
@@ -16,9 +16,11 @@ Ovale.OvaleOptions = OvaleOptions

 --<private-static-properties>
 local L = Ovale.L
-local OvaleScripts = Ovale.OvaleScripts
-local OvaleSpellBook = Ovale.OvaleSpellBook
-local OvaleState = Ovale.OvaleState
+
+-- Forward declarations for module dependencies.
+local OvaleScripts = nil
+local OvaleSpellBook = nil
+local OvaleState = nil

 local strgmatch = string.gmatch
 local strgsub = string.gsub
@@ -664,6 +666,11 @@ local self_options =

 --<public-static-methods>
 function OvaleOptions:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleScripts = Ovale.OvaleScripts
+	OvaleSpellBook = Ovale.OvaleSpellBook
+	OvaleState = Ovale.OvaleState
+
 	self.db = LibStub("AceDB-3.0"):New("OvaleDB",
 	{
 		profile =
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index db8c5d7..00b5505 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -14,9 +14,11 @@ local OvalePaperDoll = Ovale:NewModule("OvalePaperDoll", "AceEvent-3.0")
 Ovale.OvalePaperDoll = OvalePaperDoll

 --<private-static-properties>
-local OvaleEquipement = Ovale.OvaleEquipement
 local OvalePoolRefCount = Ovale.OvalePoolRefCount
-local OvaleStance = Ovale.OvaleStance
+
+-- Forward declarations for module dependencies.
+local OvaleEquipement = nil
+local OvaleStance = nil

 local select = select
 local tonumber = tonumber
@@ -133,14 +135,23 @@ end
 --</private-static-methods>

 --<public-static-methods>
-function OvalePaperDoll:OnEnable()
+function OvalePaperDoll:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleEquipement = Ovale.OvaleEquipement
+	OvaleStance = Ovale.OvaleStance
+
 	-- Initialize latest snapshot table.
+	if self.snapshot then
+		self.snapshot:Release()
+	end
 	self.snapshot = self_pool:Get()
 	for k, info in pairs(self.SNAPSHOT_STATS) do
 		self.snapshot[k] = info.default
 	end
 	self.snapshot.snapshotTime = 0
+end

+function OvalePaperDoll:OnEnable()
 	self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "UpdateStats")
 	self:RegisterEvent("COMBAT_RATING_UPDATE")
 	self:RegisterEvent("MASTERY_UPDATE")
diff --git a/OvalePool.lua b/OvalePool.lua
index e77b265..c33adda 100644
--- a/OvalePool.lua
+++ b/OvalePool.lua
@@ -9,7 +9,7 @@

 -- Simple resource pool.
 local _, Ovale = ...
-local OvalePool = Ovale:NewModule("OvalePool")
+local OvalePool = {}
 Ovale.OvalePool = OvalePool

 --<private-static-properties>
diff --git a/OvalePoolGC.lua b/OvalePoolGC.lua
index 90b86a5..7bb90aa 100644
--- a/OvalePoolGC.lua
+++ b/OvalePoolGC.lua
@@ -9,7 +9,7 @@

 -- This module wraps the standard Lua garbage collector using the Pool interface.
 local _, Ovale = ...
-local OvalePoolGC = Ovale:NewModule("OvalePoolGC")
+local OvalePoolGC = {}
 Ovale.OvalePoolGC = OvalePoolGC

 --<private-static-properties>
diff --git a/OvalePoolRefCount.lua b/OvalePoolRefCount.lua
index 1413f56..f9a7122 100644
--- a/OvalePoolRefCount.lua
+++ b/OvalePoolRefCount.lua
@@ -20,7 +20,7 @@
 --]]

 local _, Ovale = ...
-local OvalePoolRefCount = Ovale:NewModule("OvalePoolRefCount")
+local OvalePoolRefCount = {}
 Ovale.OvalePoolRefCount = OvalePoolRefCount

 --<private-static-properties>
diff --git a/OvalePower.lua b/OvalePower.lua
index 26bae13..7eb026a 100644
--- a/OvalePower.lua
+++ b/OvalePower.lua
@@ -13,8 +13,9 @@ local OvalePower = Ovale:NewModule("OvalePower", "AceEvent-3.0")
 Ovale.OvalePower = OvalePower

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvaleState = Ovale.OvaleState
+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvaleState = nil

 local pairs = pairs
 local select = select
@@ -85,6 +86,12 @@ end
 --</public-static-properties>

 --<public-static-methods>
+function OvalePower:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
+	OvaleState = Ovale.OvaleState
+end
+
 function OvalePower:OnEnable()
 	self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "EventHandler")
 	self:RegisterEvent("PLAYER_ALIVE", "EventHandler")
diff --git a/OvaleQueue.lua b/OvaleQueue.lua
index 8b3170f..3693a49 100644
--- a/OvaleQueue.lua
+++ b/OvaleQueue.lua
@@ -9,7 +9,7 @@

 -- Double-ended queue.
 local _, Ovale = ...
-local OvaleQueue = Ovale:NewModule("OvaleQueue")
+local OvaleQueue = {}
 Ovale.OvaleQueue = OvaleQueue

 --<private-static-properties>
diff --git a/OvaleRecount.lua b/OvaleRecount.lua
index d9ff529..01e2c20 100644
--- a/OvaleRecount.lua
+++ b/OvaleRecount.lua
@@ -14,7 +14,7 @@ Ovale.OvaleRecount = OvaleRecount

 --<private-static-properties>
 local L = LibStub("AceLocale-3.0"):GetLocale("Recount", true)
-local OvaleScore = Ovale.OvaleScore
+local OvaleScore = nil
 local Recount = LibStub("AceAddon-3.0"):GetAddon("Recount", true)
 --</private-static-properties>

@@ -47,6 +47,7 @@ end

 --<public-static-methods>
 function OvaleRecount:OnInitialize()
+	OvaleScore = Ovale.OvaleScore
 	if Recount then
 		if not L then
 			L = setmetatable({}, { __index = function(t, k) t[k] = k; return k; end })
diff --git a/OvaleRunes.lua b/OvaleRunes.lua
index 32feb8a..af69526 100644
--- a/OvaleRunes.lua
+++ b/OvaleRunes.lua
@@ -17,12 +17,13 @@ local OvaleRunes = Ovale:NewModule("OvaleRunes", "AceEvent-3.0")
 Ovale.OvaleRunes = OvaleRunes

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvalePaperDoll = Ovale.OvalePaperDoll
-local OvalePower = Ovale.OvalePower
-local OvaleSpellBook = Ovale.OvaleSpellBook
-local OvaleStance = Ovale.OvaleStance
-local OvaleState = Ovale.OvaleState
+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvalePaperDoll = nil
+local OvalePower = nil
+local OvaleSpellBook = nil
+local OvaleStance = nil
+local OvaleState = nil

 local ipairs = ipairs
 local pairs = pairs
@@ -82,6 +83,16 @@ OvaleRunes.RUNE_TYPE = RUNE_TYPE
 --</public-static-properties>

 --<public-static-methods>
+function OvaleRunes:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
+	OvalePaperDoll = Ovale.OvalePaperDoll
+	OvalePower = Ovale.OvalePower
+	OvaleSpellBook = Ovale.OvaleSpellBook
+	OvaleStance = Ovale.OvaleStance
+	OvaleState = Ovale.OvaleState
+end
+
 function OvaleRunes:OnEnable()
 	if self_class == "DEATHKNIGHT" then
 		-- Initialize rune database.
diff --git a/OvaleScore.lua b/OvaleScore.lua
index c266472..2af313f 100644
--- a/OvaleScore.lua
+++ b/OvaleScore.lua
@@ -33,13 +33,16 @@ local OvaleScore = Ovale:NewModule("OvaleScore", "AceEvent-3.0")
 Ovale.OvaleScore = OvaleScore

 --<private-static-properties>
-local OvaleGUID = Ovale.OvaleGUID
+-- Forward declarations for module dependencies.
+local OvaleGUID = nil

 local pairs = pairs
 local strsplit = string.split
 local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
 local API_SendAddonMessage = SendAddonMessage

+-- Player's GUID.
+local self_guid = nil
 -- self_damageMeter[moduleName] = module
 local self_damageMeter = {}
 -- self_damageMeterMethod[moduleName] = methodName or function
@@ -56,7 +59,13 @@ local self_scoredSpell = {}
 --</public-static-properties>

 --<public-static-methods>
+function OvaleScore:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleGUID = Ovale.OvaleGUID
+end
+
 function OvaleScore:OnEnable()
+	self_guid = OvaleGUID:GetGUID("player")
 	API_RegisterAddonMessagePrefix("Ovale")
 	self:RegisterEvent("CHAT_MSG_ADDON")
 	self:RegisterEvent("PLAYER_REGEN_ENABLED")
@@ -83,7 +92,7 @@ function OvaleScore:PLAYER_REGEN_ENABLED()
 	-- Broadcast the player's own score for damage meters when combat ends.
 	-- Broadcast message is "score;maxScore;playerGUID"
 	if self_maxScore > 0 then
-		local message = self_score .. ";" .. self_maxScore .. ";" .. OvaleGUID:GetGUID("player")
+		local message = self_score .. ";" .. self_maxScore .. ";" .. self_guid
 		API_SendAddonMessage("Ovale", message, "RAID")
 	end
 end
@@ -120,7 +129,7 @@ function OvaleScore:ScoreSpell(spellId)
 		if scored then
 			self_score = self_score + scored
 			self_maxScore = self_maxScore + 1
-			self:SendScore(self_playerName, OvaleGUID:GetGUID("player"), scored, 1)
+			self:SendScore(self_playerName, self_guid, scored, 1)
 		end
 	end
 end
diff --git a/OvaleSkada.lua b/OvaleSkada.lua
index 55ec55e..2f3edd8 100644
--- a/OvaleSkada.lua
+++ b/OvaleSkada.lua
@@ -14,7 +14,8 @@ local OvaleSkada = Skada and Skada:NewModule("Ovale Spell Priority") or Ovale:Ne
 Ovale.OvaleSkada = OvaleSkada

 --<private-static-properties>
-local OvaleScore = Ovale.OvaleScore
+-- Forward declarations for module dependencies.
+local OvaleScore = nil

 local ipairs = ipairs
 local floor = math.floor
@@ -36,6 +37,11 @@ end
 --</private-static-methods>

 --<public-static-methods>
+function OvaleSkada:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleScore = Ovale.OvaleScore
+end
+
 function OvaleSkada:OnEnable()
 	self.metadata = { showspots = true }
 	if Skada then
diff --git a/OvaleSpellDamage.lua b/OvaleSpellDamage.lua
index 24f7a6f..a486c47 100644
--- a/OvaleSpellDamage.lua
+++ b/OvaleSpellDamage.lua
@@ -15,19 +15,27 @@ local OvaleSpellDamage = Ovale:NewModule("OvaleSpellDamage", "AceEvent-3.0")
 Ovale.OvaleSpellDamage = OvaleSpellDamage

 --<private-static-properties>
-local OvaleGUID = Ovale.OvaleGUID
+-- Forward declarations for module dependencies.
+local OvaleGUID = nil

 local select = select
 local strfind = string.find
+
+-- Player's GUID.
+local self_guid = nil
 --</private-static-properties>

 --<public-static-properties>
 OvaleSpellDamage.value = {}
 --</public-static-properties>

--- Events
 --<public-static-methods>
+function OvaleSpellDamage:OnInitialize()
+	OvaleGUID = Ovale.OvaleGUID
+end
+
 function OvaleSpellDamage:OnEnable()
+	self_guid = OvaleGUID:GetGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 end

@@ -38,7 +46,7 @@ end
 function OvaleSpellDamage:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 	local time, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...)

-	if sourceGUID == OvaleGUID:GetGUID("player") then
+	if sourceGUID == self_guid then
 		if strfind(event, "SPELL_PERIODIC_DAMAGE")==1 or strfind(event, "SPELL_DAMAGE")==1 then
 			local spellId, spellName, spellSchool, amount = select(12, ...)
 			self.value[spellId] = amount
diff --git a/OvaleState.lua b/OvaleState.lua
index 4f87ed2..a62fb8c 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -17,10 +17,12 @@ local OvaleState = Ovale:NewModule("OvaleState")
 Ovale.OvaleState = OvaleState

 --<private-static-properties>
-local OvaleData = Ovale.OvaleData
-local OvaleFuture = nil		-- forward declaration
 local OvaleQueue = Ovale.OvaleQueue

+-- Forward declarations for module dependencies.
+local OvaleData = nil
+local OvaleFuture = nil
+
 local pairs = pairs
 local API_GetTime = GetTime

@@ -53,6 +55,7 @@ OvaleState.state = {
 --<public-static-methods>
 function OvaleState:OnInitialize()
 	-- Resolve module dependencies.
+	OvaleData = Ovale.OvaleData
 	OvaleFuture = Ovale.OvaleFuture
 end

diff --git a/OvaleSwing.lua b/OvaleSwing.lua
index 46083c0..a125213 100644
--- a/OvaleSwing.lua
+++ b/OvaleSwing.lua
@@ -30,7 +30,8 @@ local OvaleSwing = Ovale:NewModule("OvaleSwing", "AceEvent-3.0")
 Ovale.OvaleSwing = OvaleSwing

 --<private-static-properties>
-local OvaleGUID = Ovale.OvaleGUID
+-- Forward declarations for module dependencies.
+local OvaleGUID = nil

 local math_abs = math.abs
 local unpack = unpack
@@ -41,6 +42,9 @@ local API_UnitAttackSpeed = UnitAttackSpeed
 local API_UnitRangedDamage = UnitRangedDamage
 local BOOKTYPE_SPELL = BOOKTYPE_SPELL

+-- Player's GUID.
+local self_guid = nil
+
 local OVALE_AUTOSHOT_NAME = API_GetSpellInfo(75)
 local OVALE_RESET_SPELLS = {}
 local OVALE_DELAY_SPELLS = {
@@ -62,7 +66,14 @@ OvaleSwing.swingmode = nil
 --</public-static-properties>

 --<public-static-methods>
+function OvaleSwing:OnInitialize()
+	-- Resolve module dependencies.
+	OvaleGUID = Ovale.OvaleGUID
+end
+
 function OvaleSwing:OnEnable()
+	self_guid = OvaleGUID:GetGUID("player")
+
 	self.ohNext = false
 	-- fired when autoattack is enabled/disabled.
 	self:RegisterEvent("PLAYER_ENTER_COMBAT")
diff --git a/OvaleTimeSpan.lua b/OvaleTimeSpan.lua
index 88d6b1b..30dcb3d 100644
--- a/OvaleTimeSpan.lua
+++ b/OvaleTimeSpan.lua
@@ -21,7 +21,7 @@
 --]]

 local _, Ovale = ...
-local OvaleTimeSpan = Ovale:NewModule("OvaleTimeSpan")
+local OvaleTimeSpan = {}
 Ovale.OvaleTimeSpan = OvaleTimeSpan

 --<private-static-properties>
diff --git a/compiler.pl b/compiler.pl
index bf8b2f5..e164ff0 100644
--- a/compiler.pl
+++ b/compiler.pl
@@ -94,7 +94,12 @@ $m{Skada}{get_player} = true;
 $p{Skada}{current} = true;
 $p{Skada}{total} = true;

+$sp{Ovale}{OvalePool} = true;
+$sp{Ovale}{OvalePoolGC} = true;
+$sp{Ovale}{OvalePoolRefCount} = true;
+$sp{Ovale}{OvaleQueue} = true;
 $sp{Ovale}{OvaleSkada} = true;
+$sp{Ovale}{OvaleTimeSpan} = true;

 $sp{OvaleCondition}{Compare} = true;
 $sp{OvaleCondition}{ParseCondition} = true;