Browse Source

generate Engine.java

JNI-44
Volker Birk 10 years ago
parent
commit
11a725a55c
  1. 6
      src/Makefile
  2. 32
      src/gen_java_Engine.ysl2
  3. 7
      src/org/pEp/jniadapter/Engine.java
  4. 17
      src/pEp.yml2
  5. 19
      src/textutils.ysl2
  6. 12
      src/types_java.ysl2

6
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

32
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()" > ,`
}
}

7
src/org/pEp/jniadapter/Engine.java

@ -1,7 +0,0 @@
package org.pEp.jniadapter;
public class Engine extends AbstractEngine {
public Engine() throws pEpException {
}
}

17
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
);
};
};

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

12
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";
}
}
Loading…
Cancel
Save