Mercurial Hosting > luan
diff src/luan/modules/Io.luan @ 1578:c922446f53aa
immutable threading
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 08 Feb 2021 14:16:19 -0700 |
parents | a23b02693d3b |
children | b82767112d8e |
line wrap: on
line diff
--- a/src/luan/modules/Io.luan Sun Jan 31 16:04:39 2021 -0700 +++ b/src/luan/modules/Io.luan Mon Feb 08 14:16:19 2021 -0700 @@ -3,9 +3,31 @@ local System = require "java:java.lang.System" local Boot = require "luan:Boot.luan" local LuanException = require "java:luan.LuanException" +local Luan = require "luan:Luan.luan" +local error = Luan.error +local get_local_cloned = Luan.get_local_cloned +local set_local_cloned = Luan.set_local_cloned +local raw_set = Luan.raw_set +local set_metatable = Luan.set_metatable local Io = {} +local mt = {} +function mt.__index(tbl,key) + if key=="stdin" or key=="stdout" or key=="stderr" then + return get_local_cloned(tbl,key) + else + return nil + end +end +function mt.__new_index(tbl,key,value) + if key=="stdin" or key=="stdout" or key=="stderr" then + set_local_cloned(tbl,key,value) + else + raw_set(tbl,key,value) + end +end +set_metatable(Io,mt) Io.dns_lookup = IoLuan.dns_lookup Io.ip = IoLuan.ip @@ -20,8 +42,6 @@ -- used by http and rpc Io.password = "password" -local Luan = require "luan:Luan.luan" -local error = Luan.error local to_string = Luan.to_string or error() local type = Luan.type or error() local ipairs = Luan.ipairs or error()