Skip to content

Commit c9afed9

Browse files
committed
boolean conversion fix
1 parent a085b8d commit c9afed9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/main/java/ca/weblite/objc/RuntimeUtils.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -882,14 +882,16 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
882882
case 'b':
883883
case 'c':
884884
case 'C':
885-
if ( Number.class.isInstance(val) ){
886-
val = ((Number)val).byteValue();
887-
} else if ( String.class.isInstance(val)){
888-
val = new Byte(Byte.parseByte((String)val)).byteValue();
889-
} else {
890-
throw new RuntimeException("Attempt to pass ineligible value to byte: "+val);
891-
}
892-
return new ByteByReference((Byte)val);
885+
if (Boolean.class.isInstance(val)) {
886+
val = (byte) (Boolean.TRUE.equals(val) ? 1 : 0);
887+
} else if (Number.class.isInstance(val)) {
888+
val = ((Number) val).byteValue();
889+
} else if (String.class.isInstance(val)) {
890+
val = new Byte(Byte.parseByte((String) val)).byteValue();
891+
} else {
892+
throw new RuntimeException("Attempt to pass ineligible value to byte: " + val);
893+
}
894+
return new ByteByReference((Byte) val);
893895
case 'v':
894896
return null;
895897
case '^':

0 commit comments

Comments
 (0)