mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 18:30:27 -04:00
Being a bit more open to underlying types other architectures may provide as arguments. Should fix #797.
This commit is contained in:
parent
38c5f41069
commit
c768f931ae
@ -47,7 +47,7 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends Arguments {
|
|||||||
def checkDouble(index: Int) = {
|
def checkDouble(index: Int) = {
|
||||||
checkIndex(index, "number")
|
checkIndex(index, "number")
|
||||||
args(index) match {
|
args(index) match {
|
||||||
case value: java.lang.Double => value
|
case value: java.lang.Number => value.doubleValue
|
||||||
case value => throw typeError(index, value, "number")
|
case value => throw typeError(index, value, "number")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends Arguments {
|
|||||||
def checkInteger(index: Int) = {
|
def checkInteger(index: Int) = {
|
||||||
checkIndex(index, "number")
|
checkIndex(index, "number")
|
||||||
args(index) match {
|
args(index) match {
|
||||||
case value: java.lang.Double => value.intValue
|
case value: java.lang.Number => value.intValue
|
||||||
case value => throw typeError(index, value, "number")
|
case value => throw typeError(index, value, "number")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends Arguments {
|
|||||||
map.get("name") match {
|
map.get("name") match {
|
||||||
case name: String =>
|
case name: String =>
|
||||||
val damage = map.get("damage") match {
|
val damage = map.get("damage") match {
|
||||||
case number: Number => number.intValue()
|
case number: java.lang.Number => number.intValue
|
||||||
case _ => 0
|
case _ => 0
|
||||||
}
|
}
|
||||||
val tag = map.get("tag") match {
|
val tag = map.get("tag") match {
|
||||||
@ -144,13 +144,17 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends Arguments {
|
|||||||
|
|
||||||
def isDouble(index: Int) =
|
def isDouble(index: Int) =
|
||||||
index >= 0 && index < count && (args(index) match {
|
index >= 0 && index < count && (args(index) match {
|
||||||
|
case value: java.lang.Float => true
|
||||||
case value: java.lang.Double => true
|
case value: java.lang.Double => true
|
||||||
case _ => false
|
case _ => false
|
||||||
})
|
})
|
||||||
|
|
||||||
def isInteger(index: Int) =
|
def isInteger(index: Int) =
|
||||||
index >= 0 && index < count && (args(index) match {
|
index >= 0 && index < count && (args(index) match {
|
||||||
|
case value: java.lang.Byte => true
|
||||||
|
case value: java.lang.Short => true
|
||||||
case value: java.lang.Integer => true
|
case value: java.lang.Integer => true
|
||||||
|
case value: java.lang.Long => true
|
||||||
case value: java.lang.Double => true
|
case value: java.lang.Double => true
|
||||||
case _ => false
|
case _ => false
|
||||||
})
|
})
|
||||||
@ -206,7 +210,7 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends Arguments {
|
|||||||
private def typeName(value: AnyRef): String = value match {
|
private def typeName(value: AnyRef): String = value match {
|
||||||
case null | Unit | None => "nil"
|
case null | Unit | None => "nil"
|
||||||
case _: java.lang.Boolean => "boolean"
|
case _: java.lang.Boolean => "boolean"
|
||||||
case _: java.lang.Double => "double"
|
case _: java.lang.Number => "double"
|
||||||
case _: java.lang.String => "string"
|
case _: java.lang.String => "string"
|
||||||
case _: Array[Byte] => "string"
|
case _: Array[Byte] => "string"
|
||||||
case value: java.util.Map[_, _] => "table"
|
case value: java.util.Map[_, _] => "table"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user