From f177ebe37d4dca450d619bd74eb48d698b0ec2cd Mon Sep 17 00:00:00 2001 From: heck Date: Fri, 14 Feb 2020 17:34:06 +0100 Subject: [PATCH] Move Message.enums from code-gen (AbstractMessage) to Message. when using "superclass for generated code, subclass to enhance/override behaviour" - concept, then generated, nested "final" types are _evil_! The types should not be in the abstract base class, but on the acutal class the API user will use. but this class is not being generated (only inhertis the generated class) but types are not being inherited, nor can you subclass them into the subclass because they are final. --- src/gen_cpp_Message.ysl2 | 12 ++++++++---- src/gen_java_Message.ysl2 | 2 +- src/pEp.yml2 | 19 ------------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/gen_cpp_Message.ysl2 b/src/gen_cpp_Message.ysl2 index 57ea985..bd47a3d 100644 --- a/src/gen_cpp_Message.ysl2 +++ b/src/gen_cpp_Message.ysl2 @@ -123,6 +123,10 @@ tstylesheet { const "jname" call "CamelCase" with "text", "name(*[1])"; const "cname" call "lcase" with "text", "name(*[1])"; const "type", "name(.)"; + const "jnitype" choose { + when "$type = 'direction' or $type = 'EncFormat'" > jint + otherwise > `call "jni_type" with "type", "name(.)"` + } const "getname" call "mangle" { with "type", "$type"; with "classname", "$class"; @@ -134,12 +138,12 @@ tstylesheet { with "name", "concat('set', $jname)"; } || - JNIEXPORT `call "jni_type" with "type", "name(.)"` JNICALL + JNIEXPORT «$jnitype» JNICALL «$getname»(JNIEnv *env, jobject obj) { «$name» *_obj = «$name»_ptr(env, obj); || choose { - when "../enum[@name=$type]" + when "$jnitype = 'jint' " |> return (jint) _obj->«$cname»; otherwise |> return from_«$type»(env, _obj->«$cname»); @@ -148,11 +152,11 @@ tstylesheet { } JNIEXPORT void JNICALL - «$setname»(JNIEnv *env, jobject obj, `call "jni_type" with "type", "name(.)"` value) { + «$setname»(JNIEnv *env, jobject obj, «$jnitype» value) { «$name» *_obj = «$name»_ptr(env, obj); || choose { - when "../enum[@name=$type]" + when "$jnitype = 'jint'" |> _obj->«$cname» = («$ctype») (int) value; otherwise { choose { diff --git a/src/gen_java_Message.ysl2 b/src/gen_java_Message.ysl2 index 16334ca..eeeafc7 100644 --- a/src/gen_java_Message.ysl2 +++ b/src/gen_java_Message.ysl2 @@ -219,7 +219,7 @@ tstylesheet { || - when "../enum[@name=$ctype]" + when "$ctype = 'direction' or $ctype = 'EncFormat'" || private native int _get«$name»(); public «$itype» get«$name»() { diff --git a/src/pEp.yml2 b/src/pEp.yml2 index c335d7c..f946cec 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -267,25 +267,6 @@ namespace pEp { }; struct message { - enum TextFormat { - plain > 0 - html > 1 - other > 255 - } - - enum direction { - incoming > 0 - outgoing > 1 - } - - enum EncFormat { - none > 0 - inline > 1 - SMIME > 2 - PGPMIME > 3 - PEP > 4 - } - direction dir; string id; string shortmsg;