Mercurial Hosting > luan
diff src/luan/modules/Luan.luan @ 1261:198d6af7330a
rename Luan.to_table to Table.java_to_table_shallow and Luan.to_luan to Table.java_to_table_deep
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 24 Sep 2018 13:09:16 -0600 |
parents | 4b5b84853f6f |
children | 781ec0a92bb5 |
line wrap: on
line diff
--- a/src/luan/modules/Luan.luan Sun Sep 23 22:32:34 2018 -0600 +++ b/src/luan/modules/Luan.luan Mon Sep 24 13:09:16 2018 -0600 @@ -1,6 +1,5 @@ java() local BasicLuan = require "java:luan.modules.BasicLuan" -local LuanJava = require "java:luan.Luan" local Luan = {} @@ -38,30 +37,4 @@ return Luan.load( "return "..s, source_name or "eval" )() end - -local error = Luan.error -local type = Luan.type or error() -local pairs = Luan.pairs or error() - -Luan.to_table = LuanJava.toTable - -local function to_luan(obj,to_table) - if type(obj) ~= "java" then - return obj - end - obj = to_table(obj) or error("can't convert type "..obj.getClass().getName().." to luan") - local tbl = {} - for key, value in pairs(obj) do - key = to_luan(key,to_table) - value = to_luan(value,to_table) - tbl[key] = value - end - return tbl -end - -function Luan.to_luan(obj,to_table) - to_table = to_table or Luan.to_table - return to_luan(obj,to_table) -end - return Luan