Remove gears.debug.assert

Lua provides an assert() function already, so let's just use that.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2015-09-06 13:23:05 +02:00
parent 2330040eb5
commit 14be909206
4 changed files with 4 additions and 18 deletions

View File

@ -14,17 +14,6 @@ local pairs = pairs
local debug = {}
--- Check that the given condition holds true, else throw an error
--
-- @param cond If this is false, throw a lua error with a backtrace.
-- @param[opt] message Message to print in the error.
function debug.assert(cond, message)
local message = message or cond
if not cond then
error(traceback("Assertion failed: '" .. tostring(message) .. "'"))
end
end
--- Given a table (or any other data) return a string that contains its
-- tag, value and type. If data is a table then recursively call `dump_raw`
-- on each of its values.

View File

@ -6,14 +6,13 @@
---------------------------------------------------------------------------
local cairo = require("lgi").cairo
local debug = require("gears.debug")
local matrix = {}
--- Copy a cairo matrix
-- @param matrix The matrix to copy.
-- @return A copy of the given cairo matrix.
function matrix.copy(matrix)
debug.assert(cairo.Matrix:is_type_of(matrix), "Argument should be a cairo matrix")
assert(cairo.Matrix:is_type_of(matrix), "Argument should be a cairo matrix")
local ret = cairo.Matrix()
ret:init(matrix.xx, matrix.yx, matrix.xy, matrix.yy, matrix.x0, matrix.y0)
return ret

View File

@ -15,7 +15,6 @@ local capi = {
local beautiful = require("beautiful")
local cairo = require("lgi").cairo
local color = require("gears.color")
local debug = require("gears.debug")
local object = require("gears.object")
local sort = require("gears.sort")
local surface = require("gears.surface")
@ -133,7 +132,7 @@ local function do_redraw(self)
self.drawable:refresh()
debug.assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status)
assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status)
end
local function find_widgets(drawable, result, hierarchy, x, y)

View File

@ -5,7 +5,6 @@
-- @module wibox.widget.base
---------------------------------------------------------------------------
local debug = require("gears.debug")
local object = require("gears.object")
local cache = require("gears.cache")
local matrix = require("gears.matrix")
@ -440,9 +439,9 @@ end
--- Do some sanity checking on widget. This function raises a lua error if
-- widget is not a valid widget.
function base.check_widget(widget)
debug.assert(type(widget) == "table")
assert(type(widget) == "table")
for k, func in pairs({ "add_signal", "connect_signal", "disconnect_signal" }) do
debug.assert(type(widget[func]) == "function", func .. " is not a function")
assert(type(widget[func]) == "function", func .. " is not a function")
end
end