From 15cb6c441a924850e4f13beb1e6fcd267bdf1835 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sat, 15 Aug 2015 15:24:23 +0200 Subject: [PATCH] structure of C++ engine methods --- src/gen_cpp_Engine.ysl2 | 39 +++++++++++++++++++++++++++++++++++++++ src/gen_java_Engine.ysl2 | 4 +++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/gen_cpp_Engine.ysl2 b/src/gen_cpp_Engine.ysl2 index c757f14..df3d14f 100644 --- a/src/gen_cpp_Engine.ysl2 +++ b/src/gen_cpp_Engine.ysl2 @@ -3,5 +3,44 @@ include yslt.yml2 tstylesheet { include ./types_c.ysl2 + template "/namespace[@name='pEp']" apply "interface", 0; + + template "interface" document("org_pEp_jniadapter_{@name}.cc", "text") + || + #include "org_pEp_jniadapter_«@name».h" + + `` apply "method", 0 + || + + template "method" { + const "mangled" call "mangle"; + + || + JNIEXPORT jobject JNICALL «$mangled»(JNIEnv *env, jobject obj`apply "parm[in]", mode=sig`) + { + jobject result; + + + return result; + } + + || + } + + function "mangle" { + const "convert", "count(parm/stringlist|parm/string|parm/identity) > 0"; + + choose { + when "$convert" + > «concat('Java_org_pEp_jniadapter_', ../@name, '__1', str:replace(@name, '_', '_1'))» + otherwise + > «concat('Java_org_pEp_jniadapter_', ../@name, '_', str:replace(@name, '_', '_1'))» + } + } + + template "parm", mode=sig { + const "name", "name(*[3])"; + > , jobject «$name» + } } diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index 0ea577c..02d1eff 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -45,7 +45,7 @@ tstylesheet { } template "method", mode=plain { - const "convert", "count(parm/stringlist|parm/stringpairlist|parm/string|parm/identity|parm/identitylist|parm/bloblist) > 0"; + const "convert", "count(parm/stringlist|parm/string|parm/identity) > 0"; const "singlereturn", "count(parm/creates|parm/returns) = 1"; const "multireturn", "count(parm/creates|parm/returns) > 1"; @@ -142,6 +142,7 @@ tstylesheet { if "$dir = 'in'" { if "$type = 'string' or $type = 'stringlist'" | ¡$type _«$name» = AbstractEngine.toUTF8(«$name»); + if "$type = 'identity'" | _Identity _«$name» = new _Identity(«$name»); } } @@ -152,6 +153,7 @@ tstylesheet { if "$dir != 'in'" choose { when "$type = 'string' or $type = 'stringlist'" | result.«$name» = AbstractEngine.toUTF16(_result.«$name»); + if "$type = 'identity'" | result.«$name» = Identity(«$name»); otherwise | result.«$name» = _result.«$name»; } }