From ff5e01680cb5fcec0d8ad958d8b812dcfd5738cb Mon Sep 17 00:00:00 2001 From: Hussein Kasem Date: Wed, 15 Jul 2020 21:07:52 +0200 Subject: [PATCH] JNI-114 Make generated methods cached --- src/gen_cpp_Engine.ysl2 | 13 ++++++++++-- src/pEp.yml2 | 46 +++++++++++++++++++++-------------------- src/types_c.ysl2 | 2 ++ src/types_java.ysl2 | 1 + 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/gen_cpp_Engine.ysl2 b/src/gen_cpp_Engine.ysl2 index 7dd15d9..5d9411d 100644 --- a/src/gen_cpp_Engine.ysl2 +++ b/src/gen_cpp_Engine.ysl2 @@ -270,6 +270,7 @@ tstylesheet { const "dir", "name(*[1])"; const "type", "name(*[2])"; const "name", "name(*[3])"; + const "const", "name(*[4])"; choose { when "$type = 'message'" @@ -280,10 +281,18 @@ tstylesheet { | bool _«$name» = (bool) «$name»; when "$type='int'" | int _«$name» = (int) «$name»; + when "$type='uint'" + | auto _«$name» = (uint) «$name»; when "$type='string'" | const char *_«$name» = to_string(env, «$name»); - otherwise - | √$type *_«$name» = to_«$type»(env, «$name»); + otherwise { + choose { + when "$const" + | const √$type *_«$name» = to_«$type»(env, «$name»); + otherwise + | √$type *_«$name» = to_«$type»(env, «$name»); + } + } } } diff --git a/src/pEp.yml2 b/src/pEp.yml2 index 8810026..c3022fa 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -119,14 +119,14 @@ namespace pEp { inout int flags ); - method re_evaluate_message_rating( + method cached=true re_evaluate_message_rating( in message src, - Cconst stringlist x_keylist "NULL", + Cconst stringlist x_keylist "static_cast(nullptr)", Cconst Rating x_enc_status "PEP_rating_undefined", returns Rating rating ); - method outgoing_message_rating( + method cached=true outgoing_message_rating( in message msg, returns Rating rating ); @@ -136,18 +136,18 @@ namespace pEp { returns Rating rating ); - method get_identity( + method cached=true get_identity( in string address, in string userid, returns identity ident ); - method identity_rating( + method cached=true identity_rating( in identity ident, returns Rating rating ); - method blacklist_retrieve( + method cached=true blacklist_retrieve( returns stringlist blacklist ); @@ -157,34 +157,36 @@ namespace pEp { returns identity ident ); - method OpenPGP_list_keyinfo( + method cached=true OpenPGP_list_keyinfo( in string pattern, returns stringpairlist keyinfoList ); - method set_identity_flags( + //TODO Move to use IdentityFlag instead of ints + method cached=true set_identity_flags( in identity ident, - in int flags + in uint flags ); - method unset_identity_flags( + method cached=true unset_identity_flags( in identity ident, - in int flags + in uint flags ); - method own_identities_retrieve( + method cached=true own_identities_retrieve( returns identitylist identities ); - method get_trustwords( - in identity id1, - in identity id2, + + method cached=true get_trustwords( + in identity id1 const, + in identity id2 const, in string lang, returns sstring words, in bool full ); - method get_trustwords_for_fprs( + method cached=true get_trustwords_for_fprs( in string fpr1, in string fpr2, in string lang, @@ -201,13 +203,13 @@ namespace pEp { in bool full ); - method get_languagelist( + method cached=true get_languagelist( returns string languagelist ); // this function is not related to key reset - method key_reset_trust( + method cached=true key_reset_trust( in identity ident ); @@ -223,14 +225,14 @@ namespace pEp { method cached=true key_reset_all_own_keys(); - method deliverHandshakeResult( + method cached=true deliverHandshakeResult( in SyncHandshakeResult shr, - in identitylist identities + in identitylist identities const ); - method leave_device_group(); + method cached=true leave_device_group(); - method enable_identity_for_sync( + method cached=true enable_identity_for_sync( in identity ident ); diff --git a/src/types_c.ysl2 b/src/types_c.ysl2 index 1ec81ea..0d2497f 100644 --- a/src/types_c.ysl2 +++ b/src/types_c.ysl2 @@ -17,6 +17,7 @@ function "toC" { when "$type='Rating'" > PEP_rating when "$type='SyncHandshakeResult'" > sync_handshake_result when "$type='CipherSuite'" > PEP_CIPHER_SUITE + when "$type='uint'" > uint otherwise value "$type"; } @@ -31,6 +32,7 @@ function "jni_type" { when "$type = 'string' or $type = 'sstring'" > jbyteArray when "$type='bool'" > jboolean when "$type='int'" > jint + when "$type='uint'" > jint otherwise > jobject } } diff --git a/src/types_java.ysl2 b/src/types_java.ysl2 index a6806e5..6e67660 100644 --- a/src/types_java.ysl2 +++ b/src/types_java.ysl2 @@ -4,6 +4,7 @@ function "toJava" { choose { when "$type='bool'" > Boolean when "$type='int'" > int + when "$type='uint'" > int when "$type='string' or $type='sstring'" > String when "$type='timestamp'" > Date when "$type='void'" > void