Browse Source

outer enum

JNI-44
Volker Birk 10 years ago
parent
commit
b91938f246
  1. 1
      src/Makefile
  2. 33
      src/gen_java_Message.ysl2
  3. 22
      src/pEp.yml2
  4. 2
      src/textutils.ysl2
  5. 2
      src/types_java.ysl2

1
src/Makefile

@ -47,5 +47,6 @@ clean:
rm -f org/pEp/jniadapter/pEp*.java rm -f org/pEp/jniadapter/pEp*.java
rm -f org/pEp/jniadapter/Engine.java rm -f org/pEp/jniadapter/Engine.java
rm -f org/pEp/jniadapter/MimeMessage.java rm -f org/pEp/jniadapter/MimeMessage.java
rm -f org/pEp/jniadapter/Color.java
rm -f throw_pEp_exception.* rm -f throw_pEp_exception.*

33
src/gen_java_Message.ysl2

@ -3,7 +3,7 @@ include yslt.yml2
tstylesheet { tstylesheet {
include ./types_java.ysl2 include ./types_java.ysl2
template "/namespace[@name='pEp']" apply "struct|interface", 0; template "/namespace[@name='pEp']" apply "struct|interface|enum", 0;
template "interface" { template "interface" {
const "cname" call "toJava" with "type", "@name"; const "cname" call "toJava" with "type", "@name";
@ -34,23 +34,36 @@ tstylesheet {
import java.util.HashMap; import java.util.HashMap;
public class «$cname» { public class «$cname» {
`` apply "enum" `` apply "enum", mode=inner
`` apply "*[name(.)!='enum']", mode=entry `` apply "*[name(.)!='enum']", mode=entry
} }
|| ||
} }
template "enum" template "enum" {
const "jname" call "toJava" with "type", "@name";
document("org/pEp/jniadapter/{$jname}.java", "text")
||
package org.pEp.jniadapter;
import java.util.HashMap;
`` apply ".", 0, mode=inner
||
}
template "enum", mode=inner {
const "jname" call "CamelCase" with "text", "@name";
|| ||
public enum «@name» { public enum «$jname» {
`` apply "*", mode=value `` apply "*", mode=value
; ;
public final int value; public final int value;
public static final HashMap<Integer, «@name»> tag = public static final HashMap<Integer, «$jname»> tag =
new HashMap<Integer, «@name»>(); new HashMap<Integer, «$jname»>();
«@name»(int value) { «$jname»(int value) {
this.value = value; this.value = value;
fill(value); fill(value);
} }
@ -61,6 +74,7 @@ tstylesheet {
} }
|| ||
}
template "method" template "method"
|| ||
@ -104,6 +118,9 @@ tstylesheet {
} }
} }
template "*", mode=value | «name(.)» («.»)`if "position()!=last()" > , ` template "*", mode=value {
const "name" call "toJava" with "type", "name(.)";
| «$name» («.»)`if "position()!=last()" > , `
}
} }

22
src/pEp.yml2

@ -50,12 +50,30 @@ namespace pEp {
pEp_unknown_error > -1 pEp_unknown_error > -1
}; };
enum color {
pEp_rating_undefined > 0
pEp_rating_cannot_decrypt > 1
pEp_rating_have_no_key > 2
pEp_rating_unencrypted > 3
pEp_rating_unreliable > 4
pEp_rating_reliable > 5
pEp_rating_yellow > 5
pEp_rating_trusted > 6
pEp_rating_green > 6
pEp_rating_trusted_and_anonymized > 7
pEp_rating_fully_anonymous > 8
pEp_rating_under_attack > -1
pEp_rating_red > -1
pEp_rating_b0rken > -2
};
interface Engine { interface Engine {
method encrypt_message( method encrypt_message(
in message src, in message src,
in stringlist extra, in stringlist extra,
creates message dst, creates message dst,
in encformat enc_format in EncFormat enc_format
); );
method decrypt_message( method decrypt_message(
@ -110,7 +128,7 @@ namespace pEp {
stringlist keywords; stringlist keywords;
string comments; string comments;
stringpairlist opt_fields; stringpairlist opt_fields;
encformat enc_format; EncFormat enc_format;
}; };
}; };

2
src/textutils.ysl2

@ -19,7 +19,7 @@ function "CamelCase" {
when ".='pEp'" > pEp when ".='pEp'" > pEp
otherwise { otherwise {
call "UCASE" with "text", "substring(., 1, 1)"; call "UCASE" with "text", "substring(., 1, 1)";
call "lcase" with "text", "substring(., 2)"; value "substring(., 2)";
} }
} }
} }

2
src/types_java.ysl2

@ -10,7 +10,7 @@ function "toJava" {
when "$type='identity'" > Identity when "$type='identity'" > Identity
when "$type='identitylist'" > ArrayList<Identity> when "$type='identitylist'" > ArrayList<Identity>
when "$type='timestamp'" > Date when "$type='timestamp'" > Date
when "$type='encformat'" > MimeMessage.EncFormat when "$type='EncFormat'" > MimeMessage.EncFormat
when "$type='bloblist'" > ArrayList<Blob> when "$type='bloblist'" > ArrayList<Blob>
when "$type='stringpairlist'" > Vector<Pair<String, String>> when "$type='stringpairlist'" > Vector<Pair<String, String>>
when "$type='message'" > MimeMessage when "$type='message'" > MimeMessage

Loading…
Cancel
Save