Skip to content

Commit

Permalink
Fix computer type casting, issue #449.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lochie committed Nov 26, 2016
1 parent cf8e60e commit dfad15f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/lc/common/impl/drivers/IComputerTypeCaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public static class ComputerCraftTypeCaster implements IComputerTypeCaster {

@Override
public Object performCastToType(Object xx, Class<?> yy) throws Exception {
if (xx == null)
return null;
LCLog.debug("ComputerCraft driver: perform cast: %s to %s", xx.getClass().getName(), yy.getName());
if (yy == Character.class || yy == char.class) {
if (!(xx instanceof String))
Expand All @@ -29,6 +31,8 @@ public Object performCastToType(Object xx, Class<?> yy) throws Exception {

@Override
public Object castToComputerSafe(Object aresult) throws Exception {
if (aresult == null)
return null;
LCLog.debug("ComputerCraft driver: perform 2luacast: %s", aresult.getClass().getName());
if (aresult instanceof Enum<?>) {
return ((Enum<?>) aresult).name();
Expand All @@ -42,6 +46,8 @@ public static class OpenComputersTypeCaster implements IComputerTypeCaster {

@Override
public Object performCastToType(Object xx, Class<?> yy) throws Exception {
if (xx == null)
return null;
LCLog.debug("OpenComputers driver: perform cast: %s to %s", xx.getClass().getName(), yy.getName());
if (yy == Character.class || yy == char.class) {
if (!(xx instanceof byte[]))
Expand All @@ -65,6 +71,8 @@ public Object performCastToType(Object xx, Class<?> yy) throws Exception {

@Override
public Object castToComputerSafe(Object aresult) throws Exception {
if (aresult == null)
return null;
LCLog.debug("OpenComputers driver: perform 2luacast: %s", aresult.getClass().getName());
if (aresult instanceof Enum<?>) {
return ((Enum<?>) aresult).name();
Expand Down

0 comments on commit dfad15f

Please sign in to comment.