From: Alexis Laferrière Date: Sun, 4 Jan 2015 07:16:09 +0000 (-0500) Subject: Java FFI: support array in extern types X-Git-Tag: v0.7.1~47^2~8 X-Git-Url: http://nitlanguage.org Java FFI: support array in extern types Signed-off-by: Alexis Laferrière --- diff --git a/src/ffi/java.nit b/src/ffi/java.nit index 9191141..1fa56e9 100644 --- a/src/ffi/java.nit +++ b/src/ffi/java.nit @@ -518,6 +518,35 @@ redef class MClassType else break end + # Change `float[]` to `[float` + if jni_type.has('[') then + var depth = jni_type.chars.count('[') + var java_type = jni_type.replace("[]", "") + var short + + if java_type == "boolean" then + short = "Z" + else if java_type == "byte" then + short = "B" + else if java_type == "char" then + short = "C" + else if java_type == "short" then + short = "S" + else if java_type == "int" then + short = "I" + else if java_type == "long" then + short = "J" + else if java_type == "float" then + short = "F" + else if java_type == "double" then + short = "D" + else + short = "L{java_type};" + end + + return "["*depth + short + end + return "L{jni_type};" end if mclass.name == "Bool" then return "Z" @@ -530,6 +559,7 @@ redef class MClassType redef fun jni_signature_alt do var ftype = mclass.ftype + if ftype isa ForeignJavaType then return "Object" if mclass.name == "Bool" then return "Boolean" if mclass.name == "Char" then return "Char"