Commit e91fd99a authored by Jacob Potter's avatar Jacob Potter

Small cleanups to Java / JNI generators

parent 268b0201
...@@ -131,7 +131,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -131,7 +131,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"const auto& data = ::djinni::JniClass<$jniHelper>::get();") w.wl(s"const auto& data = ::djinni::JniClass<$jniHelper>::get();")
val call = "auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(" val call = "auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject("
w.w(call + "data.clazz.get(), data.jconstructor") w.w(call + "data.clazz.get(), data.jconstructor")
if(!r.fields.isEmpty) { if(r.fields.nonEmpty) {
w.wl(",") w.wl(",")
writeAlignedCall(w, " " * call.length(), r.fields, ")}", f => { writeAlignedCall(w, " " * call.length(), r.fields, ")}", f => {
val name = idCpp.field(f.ident) val name = idCpp.field(f.ident)
...@@ -167,11 +167,11 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -167,11 +167,11 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) {
val refs = new JNIRefs(ident.name) val refs = new JNIRefs(ident.name)
i.methods.map(m => { i.methods.foreach(m => {
m.params.map(p => refs.find(p.ty)) m.params.foreach(p => refs.find(p.ty))
m.ret.foreach(refs.find) m.ret.foreach(refs.find)
}) })
i.consts.map(c => { i.consts.foreach(c => {
refs.find(c.ty) refs.find(c.ty)
}) })
...@@ -258,7 +258,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -258,7 +258,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
w.w(call) w.w(call)
val javaMethodName = idJava.method(m.ident) val javaMethodName = idJava.method(m.ident)
w.w(s"getGlobalRef(), data.method_$javaMethodName") w.w(s"getGlobalRef(), data.method_$javaMethodName")
if(!m.params.isEmpty){ if(m.params.nonEmpty){
w.wl(",") w.wl(",")
writeAlignedCall(w, " " * call.length(), m.params, ")", p => { writeAlignedCall(w, " " * call.length(), m.params, ")", p => {
val param = jniMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident)) val param = jniMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment