Zum Inhalt springen

Modul:File link: Unterschied zwischen den Versionen

move duplicate size error checks to the setting functions, fix the alignment error message
(fix read-only behaviour and remove the test function)
(move duplicate size error checks to the setting functions, fix the alignment error message)
Zeile 34: Zeile 34:
error('invalid format')
error('invalid format')
end
end
end
local function sizeError(methodName)
-- Used for formatting duplication errors in size-related methods.
error(string.format(
"duplicate size argument detected in '%s'"
.. " ('upright' cannot be used in conjunction with height or width)",
methodName
), 3)
end
end
Zeile 39: Zeile 48:
checkSelf(self, 'width')
checkSelf(self, 'width')
checkType('width', 1, px, 'number')
checkType('width', 1, px, 'number')
if data.isUpright then
sizeError('width')
end
data.theWidth = px
data.theWidth = px
end
end
Zeile 45: Zeile 57:
checkSelf(self, 'height')
checkSelf(self, 'height')
checkType('height', 1, px, 'number')
checkType('height', 1, px, 'number')
if data.isUpright then
sizeError('height')
end
data.theHeight = px
data.theHeight = px
end
end
Zeile 51: Zeile 66:
checkSelf(self, 'upright')
checkSelf(self, 'upright')
checkType('upright', 1, factor, 'number', true)
checkType('upright', 1, factor, 'number', true)
if data.theWidth or data.theHeight then
sizeError('upright')
end
data.isUpright = true
data.isUpright = true
data.uprightFactor = factor
data.uprightFactor = factor
Zeile 98: Zeile 116:
else
else
error(string.format(
error(string.format(
"bad argument #1 to 'alignment' ('%s' is not a valid alignment)"
"bad argument #1 to 'alignment' ('%s' is not a valid alignment)",
s
))
))
end
end
Zeile 155: Zeile 174:
-- Size
-- Size
if data.isUpright and (data.theWidth or data.theHeight) then
if data.isUpright and data.uprightFactor then
error("duplicate size value detected in 'render' (height/width cannot be used at the same time as 'upright')")
elseif data.isUpright and data.uprightFactor then
ret[#ret + 1] = 'upright=' .. tostring(data.uprightFactor)
ret[#ret + 1] = 'upright=' .. tostring(data.uprightFactor)
elseif data.isUpright then
elseif data.isUpright then
Anonymer Benutzer