mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
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.
This commit is contained in:
parent
7b390601f7
commit
9327762d95
@ -102,6 +102,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
|
|||||||
case arg: Array[_] => convertList(arg, arg.zipWithIndex.iterator, memo)
|
case arg: Array[_] => convertList(arg, arg.zipWithIndex.iterator, memo)
|
||||||
case arg: Product => convertList(arg, arg.productIterator.zipWithIndex, memo)
|
case arg: Product => convertList(arg, arg.productIterator.zipWithIndex, memo)
|
||||||
case arg: Seq[_] => convertList(arg, arg.zipWithIndex.iterator, 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: Map[_, _] => convertMap(arg, arg, memo)
|
||||||
case arg: mutable.Map[_, _] => convertMap(arg, arg.toMap, 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
|
memo += arg -> null
|
||||||
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 {
|
else {
|
||||||
// This is a little nasty but necessary because we need to keep the
|
// 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
|
// 'converted' value up-to-date for any reference created to it in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user