From 87ce80d9fcbfa4fd52fc0a99eb9bf21f4701914a Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sat, 15 Aug 2015 16:16:28 +0200 Subject: [PATCH] skeleton --- src/gen_cpp_Engine.ysl2 | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/gen_cpp_Engine.ysl2 b/src/gen_cpp_Engine.ysl2 index df3d14f..4ffe80b 100644 --- a/src/gen_cpp_Engine.ysl2 +++ b/src/gen_cpp_Engine.ysl2 @@ -7,19 +7,39 @@ tstylesheet { template "interface" document("org_pEp_jniadapter_{@name}.cc", "text") || + #include #include "org_pEp_jniadapter_«@name».h" + #include "jniutils.hh" + + using namespace pEp::JNIAdapter; `` apply "method", 0 || template "method" { const "mangled" call "mangle"; + const "jtype" call "CamelCase" with "text", "name(parm[creates|returns]/*[2])"; || - JNIEXPORT jobject JNICALL «$mangled»(JNIEnv *env, jobject obj`apply "parm[in]", mode=sig`) + JNIEXPORT jobject JNICALL «$mangled»( + JNIEnv *env, + jobject obj`apply "parm[in]", mode=sig` + ) { - jobject result; + || + + choose { + when "count(parm[returns|creates]) > 1" + |> jclass clazz = findClass(env, "org/pEp/jniadapter/_«@name»_Return"); + when "count(parm[returns|creates]) = 1" { + |> jclass clazz = findClass(env, "org/pEp/jniadapter/«$jtype»"); + } + } + || + jmethodID constructor = env->GetMethodID(clazz, "", "()V"); + assert(constructor); + jobject result = env->NewObject(clazz, constructor); return result; } @@ -40,7 +60,7 @@ tstylesheet { template "parm", mode=sig { const "name", "name(*[3])"; - > , jobject «$name» + > ,\n jobject «$name» } }