From bcbb6f49cbaa52b9bd723addeaf70759bbc64bea Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Fri, 21 Aug 2015 14:45:52 +0200 Subject: [PATCH] updateIdentity and myself --- src/gen_java_Engine.ysl2 | 35 ++++++++++++++++++---- src/org/pEp/jniadapter/AbstractEngine.java | 34 --------------------- src/pEp.yml2 | 6 ++++ src/types_java.ysl2 | 1 + 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 index 0e2c86b..a93e3e4 100644 --- a/src/gen_java_Engine.ysl2 +++ b/src/gen_java_Engine.ysl2 @@ -18,17 +18,40 @@ tstylesheet { public «$cname»() throws pEpException { } `` apply "method", mode=plain - private native byte[] trustwords(_Identity ident); - - public String trustwords(Identity ident) { - _Identity _ident = new _Identity(ident); - return AbstractEngine.toUTF16(trustwords(_ident)); - } + `` apply "basic" } || } + template "basic" { + const "itype" call "toIntermediate" with "type", "@type"; + const "jtype" call "toJava" with "type", "@type"; + const "ptype", "name(parm/*[1])"; + const "pitype" call "toIntermediate" with "type", "$ptype"; + const "pjtype" call "toJava" with "type", "$ptype"; + const "pname", "name(parm/*[2])"; + + || + private native «$itype» «@name»(«$pitype» «$pname»); + + public «$jtype» «@name»(«$pjtype» «$pname») { + «$pitype» _«$pname» = new «$pitype»(«$pname»); + || + choose { + when "@type = 'void'" + |> «@name»(_«$pname»); + when "@type = 'identity'" + |> return new Identity(«@name»(_«$pname»)); + otherwise + |> return AbstractEngine.toUTF16(«@name»(_«$pname»)); + } + || + } + + || + } + function "returnJava" { const "returning", "count(parm/creates|parm/returns)"; const "returntype" call "toJava" with "type", "name(parm[creates|returns]/*[2])"; diff --git a/src/org/pEp/jniadapter/AbstractEngine.java b/src/org/pEp/jniadapter/AbstractEngine.java index 36905f7..48d1e91 100644 --- a/src/org/pEp/jniadapter/AbstractEngine.java +++ b/src/org/pEp/jniadapter/AbstractEngine.java @@ -101,39 +101,5 @@ abstract class AbstractEngine implements AutoCloseable { return result; } - - public class _Identity { - public byte[] address; - public byte[] fpr; - public byte[] user_id; - public byte[] username; - CommType comm_type; - public byte[] lang; - public boolean me; - - public _Identity(Identity value) { - address = toUTF8(value.address); - fpr = toUTF8(value.fpr); - user_id = toUTF8(value.user_id); - username = toUTF8(value.username); - comm_type = value.comm_type; - lang = toUTF8(value.lang); - me = value.me; - } - - public Identity getIdentity() { - Identity ident = new Identity(me); - - ident.address = toUTF16(address); - ident.fpr = toUTF16(fpr); - ident.user_id = toUTF16(user_id); - ident.username = toUTF16(username); - ident.comm_type = comm_type; - ident.lang = toUTF16(lang); - ident.me = me; - - return ident; - } - } } diff --git a/src/pEp.yml2 b/src/pEp.yml2 index c485127..383f3a6 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -4,6 +4,7 @@ decl interface @name; decl exception @name; decl method @name; decl struct @name; +decl basic @type @name; namespace pEp { exception pEp_status { @@ -86,6 +87,11 @@ namespace pEp { in message msg, returns Color color ); + + basic string trustwords(identity ident); + basic identity myself(identity ident); + basic identity updateIdentity(identity ident); + basic void keyCompromized(identity ident); }; struct message { diff --git a/src/types_java.ysl2 b/src/types_java.ysl2 index 5536dc3..e384728 100644 --- a/src/types_java.ysl2 +++ b/src/types_java.ysl2 @@ -12,6 +12,7 @@ function "toJava" { when "$type='bloblist'" > Vector when "$type='stringpairlist'" > ArrayList> when "$type='message'" > Message + when "$type='void'" > void otherwise call "CamelCase" with "text", "$type"; }