if not modules then modules = { } end modules ['pack-obj'] = { version = 1.001, comment = "companion to pack-obj.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } --[[ldx--

We save object references in the main utility table. jobobjects are reusable components.

--ldx]]-- local texsprint, texcount = tex.sprint, tex.count local allocate, mark = utilities.storage.allocate, utilities.storage.mark local collected, tobesaved = allocate(), allocate() local jobobjects = { collected = collected, tobesaved = tobesaved, } job.objects = jobobjects local function initializer() collected = mark(jobobjects.collected) tobesaved = mark(jobobjects.tobesaved) end job.register('job.objects.collected', tobesaved, initializer, nil) function jobobjects.save(tag,number,page) local t = { number, page } tobesaved[tag], collected[tag] = t, t end function jobobjects.set(tag,number,page) collected[tag] = { number, page } end function jobobjects.get(tag) return collected[tag] or tobesaved[tag] end function jobobjects.number(tag,default) local o = collected[tag] or tobesaved[tag] texsprint((o and o[1]) or default) end function jobobjects.page(tag,default) local o = collected[tag] or tobesaved[tag] texsprint((o and o[2]) or default) end function jobobjects.doifelse(tag) commands.testcase(collected[tag] or tobesaved[tag]) end