From 9327762d95b95e5a9c02e30e92b95c2cabb82d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 15 Aug 2014 01:00:35 +0200 Subject: [PATCH 1/2] Autoconverting Iterables, e.g. for cases like `return new Object[]{hashMap.values()}` (hope this doesn't break anything). Added special key for converters, `oc:flatten`. If there is only key in the converted table and it has that name, the value of that key will be used directly. --- src/main/scala/li/cil/oc/server/driver/Registry.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/scala/li/cil/oc/server/driver/Registry.scala b/src/main/scala/li/cil/oc/server/driver/Registry.scala index 31bfaefe9..53fa7f89a 100644 --- a/src/main/scala/li/cil/oc/server/driver/Registry.scala +++ b/src/main/scala/li/cil/oc/server/driver/Registry.scala @@ -102,6 +102,7 @@ private[oc] object Registry extends api.detail.DriverAPI { case arg: Array[_] => convertList(arg, arg.zipWithIndex.iterator, memo) case arg: Product => convertList(arg, arg.productIterator.zipWithIndex, memo) case arg: Seq[_] => convertList(arg, arg.zipWithIndex.iterator, memo) + case arg: java.lang.Iterable[_] => convertList(arg, arg.zipWithIndex.iterator, memo) case arg: Map[_, _] => convertMap(arg, arg, memo) case arg: mutable.Map[_, _] => convertMap(arg, arg.toMap, memo) @@ -117,6 +118,11 @@ private[oc] object Registry extends api.detail.DriverAPI { memo += arg -> null null } + else if (converted.size == 1 && converted.containsKey("oc:flatten")) { + val value = converted.get("oc:flatten") + memo += arg -> value // Update memoization map. + value + } else { // This is a little nasty but necessary because we need to keep the // 'converted' value up-to-date for any reference created to it in From 3a9f6b03110c4bf0d33e61ad47706fa8a398e4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 15 Aug 2014 01:04:38 +0200 Subject: [PATCH 2/2] Made filesystem.isLink return the destination of the link as a second value, if it is one. --- .../assets/opencomputers/loot/OpenOS/lib/filesystem.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/lib/filesystem.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/lib/filesystem.lua index 83d528124..0ab4e4e63 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/lib/filesystem.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/lib/filesystem.lua @@ -157,7 +157,10 @@ end function filesystem.isLink(path) local node, rest, vnode, vrest = findNode(filesystem.path(path)) - return not vrest and vnode.links[filesystem.name(path)] ~= nil + if not vrest and vnode.links[filesystem.name(path)] ~= nil then + return true, vnode.links[filesystem.name(path)] + end + return false end function filesystem.link(target, linkpath)