Skip to content

Commit

Permalink
Merge pull request #276 from luvit/process-title
Browse files Browse the repository at this point in the history
lib: Add magic process.title getter/setter property
  • Loading branch information
creationix committed Jul 10, 2012
2 parents 57bf6dd + dedcde8 commit 0a3b668
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lib/luvit/luvit.lua
Expand Up @@ -34,7 +34,35 @@ local constants = require('constants')
local uv = require('uv')
local utils = require('utils')
setmetatable(process, Emitter.meta)
setmetatable(process, {
__index = function (table, key)
if key == "title" then
return native.getProcessTitle()
else
return Emitter[key]
end
end,
__newindex = function (table, key, value)
if key == "title" then
return native.setProcessTitle(value)
else
return rawset(table, key, value)
end
end,
__pairs = function (table)
local key = "title"
return function (...)
if key == "title" then
key = next(table)
return "title", table.title
end
if not key then return nil end
local lastkey = key
key = next(table, key)
return lastkey, table[lastkey]
end
end
})
-- Replace lua's stdio with luvit's
-- leave stderr using lua's blocking implementation
Expand Down

0 comments on commit 0a3b668

Please sign in to comment.