Class, Debug: Minor changes, mainly cosmetic, merged in from tekUI
authorTimm S. Mueller <tmueller@neoscientists.org>
Tue, 11 Aug 2009 15:24:02 +0200
changeset 25563e76b4e3956
parent 254 21aabb5e37a6
child 256 8cd1538fbd18
Class, Debug: Minor changes, mainly cosmetic, merged in from tekUI
cgi-bin/tek/class.lua
cgi-bin/tek/lib/debug.lua
     1.1 --- a/cgi-bin/tek/class.lua	Fri Jan 23 13:22:15 2009 +0100
     1.2 +++ b/cgi-bin/tek/class.lua	Tue Aug 11 15:24:02 2009 +0200
     1.3 @@ -5,8 +5,7 @@
     1.4  --	See copyright notice in COPYRIGHT
     1.5  --
     1.6  --	LINEAGE::
     1.7 ---		[[#ClassOverview]] :
     1.8 ---		Class
     1.9 +--		[[#ClassOverview]] : Class
    1.10  --
    1.11  --	OVERVIEW::
    1.12  --		This module implements inheritance and the creation of objects
    1.13 @@ -16,7 +15,7 @@
    1.14  --		- Class:checkDescend() - Checks if an object descends from a class
    1.15  --		- Class:getClass() - Returns the class of an object, or the super
    1.16  --		class of a class
    1.17 ---		- Class:getClassName() - Returns class name of an object or class
    1.18 +--		- Class:getClassName() - Returns the class name of an object or class
    1.19  --		- Class:getSuper() - Returns the super class of an object or class
    1.20  --		- Class.new() - Creates and returns a new object
    1.21  --		- Class.newClass() - Creates a child class from a super class
    1.22 @@ -36,11 +35,11 @@
    1.23  local DEBUG = true
    1.24  
    1.25  module "tek.class"
    1.26 -_VERSION = "Class 6.2"
    1.27 +_VERSION = "Class 6.3"
    1.28  
    1.29  local Class = _M
    1.30  
    1.31 -Class.__index = _M
    1.32 +Class.__index = Class
    1.33  
    1.34  if PROXY then
    1.35  
    1.36 @@ -74,12 +73,12 @@
    1.37  	end
    1.38  
    1.39  	function Class:getClass()
    1.40 -		mt = getmetatable(self)
    1.41 +		local mt = getmetatable(self)
    1.42  		return mt.__class or mt
    1.43  	end
    1.44  
    1.45  	function Class:setClass(class)
    1.46 -		mt = getmetatable(self)
    1.47 +		local mt = getmetatable(self)
    1.48  		mt.__class = class
    1.49  		setmetatable(mt, class)
    1.50  	end
    1.51 @@ -93,8 +92,8 @@
    1.52  -------------------------------------------------------------------------------
    1.53  --	object = Class.new(class[, object]):
    1.54  --	Creates and returns a new object of the given {{class}}. Optionally,
    1.55 ---	it just prepares the specified table {{object}} for inheritance and
    1.56 ---	attaches the class methods and data.
    1.57 +--	it just prepares the specified {{object}} (a table) for inheritance and
    1.58 +--	attaches the {{class}}' methods and data.
    1.59  -------------------------------------------------------------------------------
    1.60  
    1.61  	function Class.new(class, self)
    1.62 @@ -103,8 +102,8 @@
    1.63  
    1.64  -------------------------------------------------------------------------------
    1.65  --	class = object:getClass():
    1.66 ---	This function returns the class of the specified object. If applied to
    1.67 ---	a class instead of an object, it returns its super class, e.g.:
    1.68 +--	This function returns the class of an {{object}}. If applied to a
    1.69 +--	class instead of an object, it returns its super class, e.g.:
    1.70  --			superclass = Class.getClass(class)
    1.71  -------------------------------------------------------------------------------
    1.72  
    1.73 @@ -122,9 +121,9 @@
    1.74  	end
    1.75  
    1.76  -------------------------------------------------------------------------------
    1.77 ---	object:getSuper(): Gets the super class of an object (or class).
    1.78 ---	For example, this is how a call to method can be forwarded to its
    1.79 ---	super class:
    1.80 +--	object:getSuper(): Gets the super class of an object or class.
    1.81 +--	For example, to forward a call to a {{method}} to its super class,
    1.82 +--	without knowing its class:
    1.83  --			self:getSuper().method(self, ...)
    1.84  -------------------------------------------------------------------------------
    1.85  
    1.86 @@ -137,12 +136,11 @@
    1.87  -------------------------------------------------------------------------------
    1.88  --	class = Class.newClass(superclass[, class]):
    1.89  --	Derives a new class from the specified {{superclass}}. Optionally,
    1.90 ---	an existing class table can be used. In this case, if a {{_NAME}}
    1.91 ---	attribute exists in the class table, it will be used. Otherwise, or if
    1.92 ---	a new class is being created, {{class._NAME}} will be composed from
    1.93 ---	{{superclass._NAME}} and an unique identifier. The same functionality
    1.94 ---	can be achieved by calling a class like a function, so these invocations
    1.95 ---	are equivalent:
    1.96 +--	an existing {{class}} (a table) can be specified. If a {{_NAME}} field
    1.97 +--	exists in this class, it will be used. Otherwise, or if a new class is
    1.98 +--	created, {{class._NAME}} will be composed from {{superclass._NAME}} and
    1.99 +--	an unique identifier. The same functionality can be achieved by calling
   1.100 +--	a class like a function, so the following invocations are equivalent:
   1.101  --			class = Class.newClass(superclass)
   1.102  --			class = superclass()
   1.103  --	The second notation allows a super class to be passed as the second
   1.104 @@ -161,7 +159,8 @@
   1.105  
   1.106  -------------------------------------------------------------------------------
   1.107  --	name = object:getClassName(): This function returns the {{_NAME}}
   1.108 ---	attribute of the specified class or object's class.
   1.109 +--	attribute of the {{object}}'s class. It is also possible to apply this
   1.110 +--	function to a class instead of an object.
   1.111  -------------------------------------------------------------------------------
   1.112  
   1.113  function Class:getClassName()
   1.114 @@ -190,5 +189,5 @@
   1.115  --	make Class and its descendants functors:
   1.116  -------------------------------------------------------------------------------
   1.117  
   1.118 -__call = Class.newClass
   1.119 -setmetatable(_M, { __call = newClass })
   1.120 +__call = newClass
   1.121 +setmetatable(Class, { __call = newClass })
     2.1 --- a/cgi-bin/tek/lib/debug.lua	Fri Jan 23 13:22:15 2009 +0100
     2.2 +++ b/cgi-bin/tek/lib/debug.lua	Tue Aug 11 15:24:02 2009 +0200
     2.3 @@ -13,7 +13,7 @@
     2.4  --	10 || ERROR || something went wrong, e.g. resource unavailable
     2.5  --	20 || FAIL  || something went wrong that can't be coped with
     2.6  --
     2.7 ---	The default debug level is 10 {{ERROR}}. To set the debug level
     2.8 +--	The default debug level is 5 {{WARN}}. To set the debug level
     2.9  --	globally, e.g.:
    2.10  --			db = require "tek.lib.debug"
    2.11  --			db.level = db.INFO
    2.12 @@ -24,16 +24,16 @@
    2.13  --			db.out = io.open("logfile", "w")
    2.14  --
    2.15  --	FUNCTIONS::
    2.16 ---		- debug.console() - Enter debug console
    2.17 ---		- debug.dump() - Dump a table recursively
    2.18 ---		- debug.error() - Print a text in the {{ERROR}} debug level
    2.19 ---		- debug.execute() - Execute a function in the specified debug level
    2.20 ---		- debug.fail() - Print a text in the {{FAIL}} debug level
    2.21 ---		- debug.info() - Print a text in the {{INFO}} debug level
    2.22 ---		- debug.print() - Print a text in the specified debug level
    2.23 ---		- debug.stacktrace() - Print a stacktrace in the specified debug level
    2.24 ---		- debug.trace() - Print a text in the {{TRACE}} debug level
    2.25 ---		- debug.warn() - Print a text in the {{WARN}} debug level
    2.26 +--		- debug.console() - Enters the debug console
    2.27 +--		- debug.dump() - Dumps a table recursively
    2.28 +--		- debug.error() - Prints a text in the {{ERROR}} debug level
    2.29 +--		- debug.execute() - Executes a function in the specified debug level
    2.30 +--		- debug.fail() - Prints a text in the {{FAIL}} debug level
    2.31 +--		- debug.info() - Prints a text in the {{INFO}} debug level
    2.32 +--		- debug.print() - Prints a text in the specified debug level
    2.33 +--		- debug.stacktrace() - Prints a stacktrace in the specified debug level
    2.34 +--		- debug.trace() - Prints a text in the {{TRACE}} debug level
    2.35 +--		- debug.warn() - Prints a text in the {{WARN}} debug level
    2.36  --
    2.37  -------------------------------------------------------------------------------
    2.38  
    2.39 @@ -50,7 +50,7 @@
    2.40  local unpack = unpack
    2.41  
    2.42  module "tek.lib.debug"
    2.43 -_VERSION = "Debug 4.1"
    2.44 +_VERSION = "Debug 4.3"
    2.45  
    2.46  -- symbolic:
    2.47  
    2.48 @@ -62,7 +62,7 @@
    2.49  
    2.50  -- global defaults:
    2.51  
    2.52 -level = INFO
    2.53 +level = WARN
    2.54  out = stderr
    2.55  wrout = function(...) out:write(...) end
    2.56