Mercurial Hosting > luan
changeset 1192:e15a41a8b4b2
remove Io.repr
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Feb 2018 14:51:44 -0700 |
parents | dada70cb57c1 |
children | 9f522cfe0c30 |
files | conv.txt src/luan/modules/Io.luan src/luan/modules/Parsers.luan |
diffstat | 3 files changed, 4 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
diff -r dada70cb57c1 -r e15a41a8b4b2 conv.txt --- a/conv.txt Sun Feb 25 17:17:08 2018 -0700 +++ b/conv.txt Mon Feb 26 14:51:44 2018 -0700 @@ -8,3 +8,5 @@ "request.cookie" "set_cookie" "assert" + +"Io.repr"
diff -r dada70cb57c1 -r e15a41a8b4b2 src/luan/modules/Io.luan --- a/src/luan/modules/Io.luan Sun Feb 25 17:17:08 2018 -0700 +++ b/src/luan/modules/Io.luan Mon Feb 26 14:51:44 2018 -0700 @@ -81,61 +81,6 @@ end --- repr - -local function do_repr(out,obj,strict,done) - local tp = type(obj) - if tp == "table" then - if done[obj] == true then - strict and error "circular reference" - out.write "<circular reference>" - return - end - done[obj] = true - out.write( "{" ) - local is_first = true - local in_list = {} - for key, value in ipairs(obj) do - if is_first then is_first = false else out.write ", " end - do_repr(out,value,strict,done) - in_list[key] = true - end - for key, value in pairs(obj) do - if in_list[key] ~= true then - if is_first then is_first = false else out.write ", " end - if type(key) == "string" and matches(key,"^[a-zA-Z_][a-zA-Z_0-9]*$") ~= nil then - out.write( key ) - elseif type(key) == "table" then - out.write( "[<", key, ">]" ) - else - out.write "[" - do_repr(out,key,strict,done) - out.write "]" - end - out.write "=" - do_repr(out,value,strict,done) - end - end - out.write "}" - elseif tp == "string" then - out.write( '"', encode(obj), '"' ) - elseif tp == "nil" or tp == "boolean" or tp == "number" then - out.write( obj ) - else - strict and error("can't repr type '"..tp.."' of "..obj) - out.write( "<", obj, ">" ) - end -end - -function Io.repr(obj,strict) - local string_uri = uri "string:" - local out = string_uri.text_writer() - do_repr(out,obj,strict or false,{}) - out.close() - return string_uri.read_text() -end - - -- debug function Io.debug(prompt)
diff -r dada70cb57c1 -r e15a41a8b4b2 src/luan/modules/Parsers.luan --- a/src/luan/modules/Parsers.luan Sun Feb 25 17:17:08 2018 -0700 +++ b/src/luan/modules/Parsers.luan Mon Feb 26 14:51:44 2018 -0700 @@ -16,8 +16,8 @@ local JsonToString = require "java:luan.lib.json.JsonToString" -- converts json string to luan object -function Parsers.json_parse(obj) - return JavaLuan.toLuan(JsonParser.parse(obj)) +function Parsers.json_parse(s) + return JavaLuan.toLuan(JsonParser.parse(s)) end -- converts luan object to json string