Browse Source

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.
JNI-87
heck 5 years ago
parent
commit
f177ebe37d
  1. 12
      src/gen_cpp_Message.ysl2
  2. 2
      src/gen_java_Message.ysl2
  3. 19
      src/pEp.yml2

12
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 {

2
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»() {

19
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;

Loading…
Cancel
Save