diff --git a/src/Makefile b/src/Makefile index 6cf9f17..aa2b3f3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,12 +24,16 @@ clean: rm -f org_pEp_jniadapter_*.h rm -f org/pEp/jniadapter/*.class rm -f org/pEp/jniadapter/pEp*.java + rm -f org/pEp/jniadapter/Engine.java rm -f throw_pEp_exception.* org/pEp/jniadapter/pEpException.java: pEp.yml2 gen_java_exceptions.ysl2 yml2proc -y gen_java_exceptions.ysl2 $< -o $@ -throw_pEp_exception.cc throw_pEp_exception.hh: pEp.yml2 gen_throw_pEp_exception.ysl2 +org/pEp/jniadapter/Engine.java : pEp.yml2 gen_java_Engine.ysl2 types_java.ysl2 + yml2proc -y gen_java_Engine.ysl2 $< -o $@ + +throw_pEp_exception.cc throw_pEp_exception.hh: pEp.yml2 gen_throw_pEp_exception.ysl2 textutils.ysl2 yml2proc -y gen_throw_pEp_exception.ysl2 $< -o throw_pEp_exception.cc throw_pEp_exception.o: throw_pEp_exception.cc throw_pEp_exception.hh diff --git a/src/gen_java_Engine.ysl2 b/src/gen_java_Engine.ysl2 new file mode 100644 index 0000000..def14e8 --- /dev/null +++ b/src/gen_java_Engine.ysl2 @@ -0,0 +1,32 @@ +include yslt.yml2 + +tstylesheet { + include ./types_java.ysl2 + + template "/" + || + package org.pEp.jniadapter; + + final public class Engine extends AbstractEngine { + public Engine() throws pEpException { } + + `` apply "namespace/interface/method"; + } + || + + template "method" + || + public native void «@name»( + `` apply "parm", 2 + ) throws pEpException;`if "position()!=last()" > \n` + || + + template "parm" { + const "dir", "name(*[1])"; + const "type", "name(*[2])"; + const "name", "name(*[3])"; + + | `call "toJava" with "type", "$type"` «translate($name,'-','_')»`if "position()!=last()" > ,` + } +} + diff --git a/src/org/pEp/jniadapter/Engine.java b/src/org/pEp/jniadapter/Engine.java deleted file mode 100644 index 45ed16a..0000000 --- a/src/org/pEp/jniadapter/Engine.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.pEp.jniadapter; - -public class Engine extends AbstractEngine { - public Engine() throws pEpException { - } -} - diff --git a/src/pEp.yml2 b/src/pEp.yml2 index b8069b7..cb9287b 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -1,5 +1,7 @@ decl namespace @name; decl enum @name; +decl interface @name; +decl method @name; namespace pEp { enum pEp_status { @@ -45,5 +47,20 @@ namespace pEp { pEp_out_of_memory > -2 pEp_unknown_error > -1 }; + + interface message_api { + method encrypt_message( + in message src, + in stringlist extra, + creates message dst, + in pEp_enc_format enc_format + ); + + method decrypt_message( + in message src, + in pEp_MIME_format mime, + creates message dst + ); + }; }; diff --git a/src/textutils.ysl2 b/src/textutils.ysl2 index 567f48e..ded3427 100644 --- a/src/textutils.ysl2 +++ b/src/textutils.ysl2 @@ -12,21 +12,16 @@ function "lcase" { function "CamelCase" { param "text"; + const "tokens", "str:tokenize($text, '-')"; - choose { - when "contains($text, '-')" { - const "tokens", "str:tokenize($text, '-')"; - for "$tokens" { - choose { - when ".='pEp'" > pEp - otherwise { - call "UCASE" with "text", "substring(., 1, 1)"; - call "lcase" with "text", "substring(., 2)"; - } - } + for "$tokens" { + choose { + when ".='pEp'" > pEp + otherwise { + call "UCASE" with "text", "substring(., 1, 1)"; + call "lcase" with "text", "substring(., 2)"; } } - otherwise | unsupported } } diff --git a/src/types_java.ysl2 b/src/types_java.ysl2 new file mode 100644 index 0000000..311a0db --- /dev/null +++ b/src/types_java.ysl2 @@ -0,0 +1,12 @@ +include ./textutils.ysl2 + +function "toJava" { + param "type"; + + choose { + when "string" > String + when "stringlist" > String[] + otherwise call "CamelCase" with "text", "$type"; + } +} +