From ecd3fc28694bb17801a0bc522bbf50e33897b143 Mon Sep 17 00:00:00 2001 From: Edouard Tisserant Date: Wed, 23 Nov 2016 17:35:40 +0100 Subject: [PATCH] JNI-19 added set_identity_flags and unset_identity_flags --- src/gen_cpp_Engine.ysl2 | 27 ++++++++++++++++++--------- src/gen_java_Engine.ysl2 | 6 ++++++ src/pEp.yml2 | 13 ++++++++++++- src/types_c.ysl2 | 1 + src/types_java.ysl2 | 2 ++ 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/gen_cpp_Engine.ysl2 b/src/gen_cpp_Engine.ysl2 index c5b37ae..8ad7fe7 100644 --- a/src/gen_cpp_Engine.ysl2 +++ b/src/gen_cpp_Engine.ysl2 @@ -28,12 +28,18 @@ tstylesheet { template "method" { const "mangled" call "mangle"; - const "rettype", "name(parm[creates|returns]/*[2])"; - const "retname", "name(parm[creates|returns]/*[3])"; - const "jtype" call "toJavaDeclare" with "type", "$rettype"; + const "returning", "count(parm/creates|parm/returns)"; + const "CretType" choose { + when "$returning = 0" > void + when "$returning > 0" > jobject + } + const "CretDefault" choose { + when "$returning = 0" > + when "$returning > 0" > NULL + } || - JNIEXPORT jobject JNICALL «$mangled»( + JNIEXPORT «$CretType» JNICALL «$mangled»( JNIEnv *env, jobject obj`apply "parm[in]", mode=sig` ) @@ -51,13 +57,13 @@ tstylesheet { status < PEP_STATUS_OK |`> |` status >= PEP_TRUSTWORD_NOT_FOUND) { throw_pEp_Exception(env, status); - return NULL; + return «$CretDefault»; } || choose { - when "count(parm[returns|creates]) > 1" { + when "$returning > 1" { apply "parm[returns|creates]", mode=return; apply "parm[1]", mode=return { @@ -75,16 +81,17 @@ tstylesheet { || } - when "count(parm[returns|creates]) = 1" { + when "$returning = 1" { + const "rettype", "name(parm[creates|returns]/*[2])"; choose { when "ancestor::namespace/child::enum[@name=$rettype]" apply "parm[returns|creates]", mode=return { - with "jtype", "$jtype"; + with "jtype", call "toJavaDeclare" with "type", "$rettype"; with "jnitype", "'jint'"; with "sig", "'(I)V'"; } when "$rettype = 'message' or $rettype = 'identity'" apply "parm[returns|creates]", mode=return { - with "jtype", "$jtype"; + with "jtype", call "toJavaDeclare" with "type", "$rettype"; with "jnitype", "'jlong'"; with "sig", "'(J)V'"; } @@ -239,6 +246,8 @@ tstylesheet { | message *_«$name» = (message *) callLongMethod(env, «$name», "getHandle"); when "$type='bool'" | bool _«$name» = (bool) «$name»; + when "$type='int'" + | int _«$name» = (int) «$name»; otherwise | √$type *_«$name» = to_«$type»(env, «$name»); } diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index 7ae7546..499f625 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -155,6 +155,12 @@ tstylesheet { return result; || + if "not($singlereturn) and not($multireturn)" + || + _«@name»(`apply "parm[in]", mode=call;`); + return; + || + || } || diff --git a/src/pEp.yml2 b/src/pEp.yml2 index d94b819..4ee54ab 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -109,7 +109,7 @@ namespace pEp { enum DecryptFlags { pEp_decrypt_flag_own_private_key > 1 PEP_decrypt_flag_consumed > 2 - PEP_decrypt_flag_discarded > 4 + PEP_decrypt_flag_ignored > 4 }; enum IdentityFlags { @@ -145,6 +145,7 @@ namespace pEp { creates message dst, creates stringlist keylist, returns Rating rating, + /* TODO replace with int, this is a OR of multipla DecryptFlags */ returns DecryptFlags flags ); @@ -178,6 +179,16 @@ namespace pEp { returns stringpairlist keyinfoList ); + method set_identity_flags( + in identity ident, + in int flags + ); + + method unset_identity_flags( + in identity ident, + in int flags + ); + basic string trustwords(identity ident); basic identity myself(identity ident); basic identity updateIdentity(identity ident); diff --git a/src/types_c.ysl2 b/src/types_c.ysl2 index abab0a7..5f5ff29 100644 --- a/src/types_c.ysl2 +++ b/src/types_c.ysl2 @@ -27,6 +27,7 @@ function "jni_type" { when "../enum[@name=$type]" > jint when "$type = 'string'" > jbyteArray when "$type='bool'" > jboolean + when "$type='int'" > jint otherwise > jobject } } diff --git a/src/types_java.ysl2 b/src/types_java.ysl2 index 9d6b847..ff249b0 100644 --- a/src/types_java.ysl2 +++ b/src/types_java.ysl2 @@ -14,6 +14,7 @@ function "toJava" { when "$type='message'" > Message when "$type='void'" > void when "$type='bool'" > Boolean + when "$type='int'" > Integer otherwise call "CamelCase" with "text", "$type"; } @@ -82,6 +83,7 @@ function "toIntermediate" { when "$type='bool'" > boolean when "$type='DecryptFlags'" > DecryptFlags when "$type='SyncHandshakeResult'" > int + when "$type='int'" > int otherwise call "toJava" with "type", "$type"; }