284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
...
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
ct.ext.job = declare {
ident = 'ext-job';
init = {
states = {};
};
construct = function(me,name,doc,pred,...)
print('constructing job',name,'for',doc)
-- prepare contexts for relevant extensions
me.name = name
me.doc = doc -- for reqs + limiting
for _, ext in pairs(ct.ext.loaded) do
if pred == nil or pred(ext) then
me.states[ext] = {}
end
................................................................................
end;
hook = function(me, hook, ...)
-- used when extensions may need to persist state across
-- multiple functions or invocations
local ret = {}
local hook_id = me.name ..'_'.. hook
for hookfn, ext, state in me:each('hook', hook_id) do
print(' - running hook for ext',ext.id)
table.insert(ret, (hookfn(me:delegate(ext),...)))
end
return ret
end;
};
}
|
|
284
285
286
287
288
289
290
291
292
293
294
295
296
297
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
ct.ext.job = declare {
ident = 'ext-job';
init = {
states = {};
};
construct = function(me,name,doc,pred,...)
-- prepare contexts for relevant extensions
me.name = name
me.doc = doc -- for reqs + limiting
for _, ext in pairs(ct.ext.loaded) do
if pred == nil or pred(ext) then
me.states[ext] = {}
end
................................................................................
end;
hook = function(me, hook, ...)
-- used when extensions may need to persist state across
-- multiple functions or invocations
local ret = {}
local hook_id = me.name ..'_'.. hook
for hookfn, ext, state in me:each('hook', hook_id) do
table.insert(ret, (hookfn(me:delegate(ext),...)))
end
return ret
end;
};
}
|