reworking signal system

This commit is contained in:
Axel Kittenberger 2018-05-22 08:44:48 +02:00
parent 14d41116c0
commit ec4940a066
4 changed files with 57 additions and 11 deletions

View File

@ -41,6 +41,7 @@ local assignAble =
status = true,
}
--
-- On accessing a nil index.
--
@ -52,6 +53,7 @@ mt.__index = function
return self[ k_nt ][ k ]
end
--
-- On assigning a new index.
--
@ -69,6 +71,7 @@ mt.__newindex = function
self[ k_nt ][ k ] = v
end
--
-- This delay is being blocked by another delay
--
@ -115,6 +118,7 @@ local function wait
self[ k_nt ].alarm = alarm
end
--
-- Creates a new delay.
--
@ -150,6 +154,7 @@ local function new
return delay
end
--
-- Exported interface
--

View File

@ -34,7 +34,7 @@ local e2d = { }
local e2d2 = { }
--
-- Allows the garbage collector to remove not refrenced
-- Allows the garbage collector to remove not referenced
-- events.
--
setmetatable( e2d, { __mode = 'k' } )

View File

@ -720,6 +720,24 @@ local function statusReport
end
--
-- Returns a user interface for this sync
--
local function getUserIntf
(
self
)
local ui = self.userIntf
if ui then return ui end
ui = { muhkuh = true }
self.userIntf = ui
return ui
end
--
-- Creates a new Sync.
--
@ -747,6 +765,7 @@ local function new
getAlarm = getAlarm,
getDelays = getDelays,
getNextDelay = getNextDelay,
getUserIntf = getUserIntf,
invokeActions = invokeActions,
removeDelay = removeDelay,
rmExclude = rmExclude,

View File

@ -250,27 +250,49 @@ user.settings =
end
--
-- A look up table for user sync interfaces
--
local userSyncIntfs = { }
setmetatable( userSyncIntfs, { __mode = 'k' } )
--
-- Provides a way for user scripts to browse (and alter) active sync list.
--
user.syncs =
( function( )
local mt =
{
__ipairs =
function
( )
return ipairs( SyncMaster )
-- iterator for user syncs
function iter
(
self,
pos
)
pos = pos + 1
if pos >= #SyncMaster then return nil end
local sync = SyncMaster.get( pos )
return pos, sync:getUserIntf( )
end
local mt = { }
mt.__ipairs =
function( self )
return iter, self, -1
end
}
-- public interface
local intf = {
add = sync
local intf =
{
add = sync, -- syncs.add is a synonym to sync{ }
}
setmetatable( intf, mt )
return intf
end ) ( )
end )( )