Skip to content

Instantly share code, notes, and snippets.

@warmist
Created January 9, 2014 21:01
Show Gist options
  • Save warmist/8341961 to your computer and use it in GitHub Desktop.
Save warmist/8341961 to your computer and use it in GitHub Desktop.
Print all enum values
--prints enum values
local args={...}
function isEnum(t)
return t._kind=='enum-type'
end
function printEnum(t)
if not isEnum(t) then
qerror("type is not an enum")
end
for i=t._first_item, t._last_item do
print(i,t[i])
end
end
local f,err=load("return "..table.concat (args," "))
if f==nil then
qerror(err)
end
printEnum(f())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment