webmcp
diff framework/env/execute/multi_wrapped.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/execute/multi_wrapped.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,26 @@ 1.4 +--[[-- 1.5 +execute.multi_wrapped( 1.6 + wrapper_funcs, -- multiple wrapper functions (i.e. filters) 1.7 + inner_func -- inner function (i.e. an action or view) 1.8 +) 1.9 + 1.10 +This function does the same as execute.wrapped(...), but with multiple wrapper functions, instead of just one wrapper function. It is used by execute.filtered_view{...} and execute.filtered_action{...} to wrap multiple filters around the view or action. 1.11 + 1.12 +--]]-- 1.13 + 1.14 +function execute.multi_wrapped(wrapper_funcs, inner_func) 1.15 + local function wrapped_execution(pos) 1.16 + local wrapper_func = wrapper_funcs[pos] 1.17 + if wrapper_func then 1.18 + return execute.wrapped( 1.19 + wrapper_func, 1.20 + function() 1.21 + wrapped_execution(pos+1) 1.22 + end 1.23 + ) 1.24 + else 1.25 + return inner_func() 1.26 + end 1.27 + end 1.28 + return wrapped_execution(1) 1.29 +end