Skip to content

Instantly share code, notes, and snippets.

@phi-gamma
Created April 16, 2013 11:59
Show Gist options
  • Save phi-gamma/5395383 to your computer and use it in GitHub Desktop.
Save phi-gamma/5395383 to your computer and use it in GitHub Desktop.
allow overriding of attributes allocation
--- /tmp/luatex-basics-nod.lua 2013-04-16 13:56:51.387870041 +0200
+++ luatex-basics-nod.lua 2013-04-16 13:57:39.235889616 +0200
@@ -28,21 +28,23 @@
end
-attributes = { }
+attributes = attributes or { }
attributes.unsetvalue = -0x7FFFFFFF
local numbers, last = { }, 127
-function attributes.private(name)
- local number = numbers[name]
- if not number then
- if last < 255 then
- last = last + 1
+if not attributes.private then
+ function attributes.private(name)
+ local number = numbers[name]
+ if not number then
+ if last < 255 then
+ last = last + 1
+ end
+ number = last
+ numbers[name] = number
end
- number = last
- numbers[name] = number
+ return number
end
- return number
end
-- Nodes:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment