color and module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-11-08 02:46:31 +01:00
parent 92acec09a6
commit a93fc5d8ec
7 changed files with 65 additions and 126 deletions
+6 -3
View File
@@ -11,9 +11,12 @@ function define(self, k, v, private)
if type(k) ~= 'string' or not strfind(k, '^[_%a][_%w]*') then error('Invalid identifier "%s".', k) end
local _, _, prefix, suffix = strfind(k, '^(.?.?.?.?)([_%a].*)')
local module = loaded[self]
module.defined[k] = module.defined[k] and error('Duplicate identifier "%s".', k) or true
module.fields[k] = v
if prefix == 'get_' then module.accessors[suffix] = v elseif prefix == 'set_' then module.mutators[suffix] = v end
local signature = (private and '-' or '+') .. k
module.defined[signature] = module.defined[signature] and error('Duplicate identifier "%s".', signature) or true
if private or not module.defined['-' .. k] then
module.fields[k] = v
if prefix == 'get_' then module.accessors[suffix] = v elseif prefix == 'set_' then module.mutators[suffix] = v end
end
if not private then
module.public_fields[k] = v
if prefix == 'get_' then module.public_accessors[suffix] = v elseif prefix == 'set_' then module.public_mutators[suffix] = v end