Browse Source

Generate marker files for make

Move exceptions into own subpkg foundation.pEp.jniadapter.exceptions
JNI-106
heck 5 years ago
parent
commit
e5f3aa6b8a
  1. 4
      .hgignore
  2. 3
      src/foundation/pEp/jniadapter/AbstractEngine.java
  3. 4
      src/foundation/pEp/jniadapter/Sync.java
  4. 2
      src/foundation/pEp/jniadapter/_Blob.java
  5. 5
      src/gen_cpp_Engine.ysl2
  6. 5
      src/gen_cpp_Message.ysl2
  7. 8
      src/gen_java_Engine.ysl2
  8. 35
      src/gen_java_Message.ysl2
  9. 35
      src/gen_java_exceptions.ysl2
  10. 59
      src/gen_throw_pEp_exception.ysl2
  11. 2
      test/java/foundation/pEp/jniadapter/test/jni88/TestMain.java
  12. 1
      test/java/foundation/pEp/jniadapter/test/jni91/TestMain.java
  13. 1
      test/java/foundation/pEp/jniadapter/test/jni92/TestMain.java

4
.hgignore

@ -24,8 +24,8 @@ foundation_pEp_jniadapter_Engine.*
foundation_pEp_jniadapter_Identity.h foundation_pEp_jniadapter_Identity.h
foundation_pEp_jniadapter_Message.cc foundation_pEp_jniadapter_Message.cc
foundation_pEp_jniadapter_Message.h foundation_pEp_jniadapter_Message.h
throw_pEp_exception.cc #throw_pEp_exception.cc
throw_pEp_exception.hh #throw_pEp_exception.hh
CipherSuite.java CipherSuite.java
Color.java Color.java

3
src/foundation/pEp/jniadapter/AbstractEngine.java

@ -4,9 +4,8 @@ import java.util.ArrayList;
import java.util.Vector; import java.util.Vector;
import foundation.pEp.jniadapter.Sync.DefaultCallback; import foundation.pEp.jniadapter.Sync.DefaultCallback;
import foundation.pEp.jniadapter.exceptions.*;
import java.io.UnsupportedEncodingException;
import java.text.Normalizer;
abstract class AbstractEngine extends UniquelyIdentifiable implements AbstractEngineInterface, AutoCloseable { abstract class AbstractEngine extends UniquelyIdentifiable implements AbstractEngineInterface, AutoCloseable {
static { static {

4
src/foundation/pEp/jniadapter/Sync.java

@ -1,9 +1,5 @@
package foundation.pEp.jniadapter; package foundation.pEp.jniadapter;
import foundation.pEp.jniadapter.Identity;
import foundation.pEp.jniadapter.Message;
import foundation.pEp.jniadapter.pEpException;
public interface Sync { public interface Sync {

2
src/foundation/pEp/jniadapter/_Blob.java

@ -1,5 +1,7 @@
package foundation.pEp.jniadapter; package foundation.pEp.jniadapter;
import foundation.pEp.jniadapter.exceptions.*;
public class _Blob { public class _Blob {
public byte[] data; public byte[] data;
public byte[] mime_type; public byte[] mime_type;

5
src/gen_cpp_Engine.ysl2

@ -5,7 +5,10 @@ tstylesheet {
include ./types_c.ysl2 include ./types_c.ysl2
include ./types_java.ysl2 include ./types_java.ysl2
template "/namespace[@name='pEp']" apply "interface", 0; template "/namespace[@name='pEp']" {
apply "interface", 0;
document("gen_cpp_Engine.marker", "text") > ""
}
template "interface" document("foundation_pEp_jniadapter_{@name}.cc", "text") template "interface" document("foundation_pEp_jniadapter_{@name}.cc", "text")
|| ||

5
src/gen_cpp_Message.ysl2

@ -5,7 +5,10 @@ tstylesheet {
include ./textutils.ysl2 include ./textutils.ysl2
include ./types_c.ysl2 include ./types_c.ysl2
template "/namespace[@name='pEp']" apply "struct", 0; template "/namespace[@name='pEp']" {
apply "struct", 0;
document("gen_cpp_Message.marker", "text") > ""
}
template "struct" { template "struct" {
const "jname" call "CamelCase" with "text", "@name"; const "jname" call "CamelCase" with "text", "@name";

8
src/gen_java_Engine.ysl2

@ -4,7 +4,10 @@ tstylesheet {
include ./textutils.ysl2 include ./textutils.ysl2
include ./types_java.ysl2 include ./types_java.ysl2
template "/namespace[@name='pEp']" apply "interface", 0; template "/namespace[@name='pEp']" {
apply "interface", 0;
document("gen_java_Engine.marker", "text") > ""
}
template "interface" { template "interface" {
const "cname" call "toJava" with "type", "@name"; const "cname" call "toJava" with "type", "@name";
@ -12,6 +15,7 @@ tstylesheet {
|| ||
package foundation.pEp.jniadapter; package foundation.pEp.jniadapter;
import foundation.pEp.jniadapter.exceptions.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Vector; import java.util.Vector;
@ -265,7 +269,7 @@ tstylesheet {
|| ||
public `call "returnJava"` «@name»( public `call "returnJava"` «@name»(
`` apply "parm[in|inout]", 2, mode=java `` apply "parm[in|inout]", 2, mode=java
) throws pEpException; );
|| ||
} }

35
src/gen_java_Message.ysl2

@ -4,7 +4,10 @@ tstylesheet {
include ./textutils.ysl2 include ./textutils.ysl2
include ./types_java.ysl2 include ./types_java.ysl2
template "/namespace[@name='pEp']" apply "struct|enum|exception", 0; template "/namespace[@name='pEp']" {
apply "struct|enum|exception", 0;
document("gen_java_Message.marker", "text") > ""
}
template "struct" { template "struct" {
const "cname" call "toJava" with "type", "@name"; const "cname" call "toJava" with "type", "@name";
@ -12,6 +15,7 @@ tstylesheet {
|| ||
package foundation.pEp.jniadapter; package foundation.pEp.jniadapter;
import foundation.pEp.jniadapter.exceptions.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Vector; import java.util.Vector;
import java.util.Date; import java.util.Date;
@ -77,23 +81,24 @@ tstylesheet {
|| ||
} }
template "enum|exception" { template "enum" {
const "jname" call "toJava" with "type", "@name"; const "jname" call "toJava" with "type", "@name";
document("foundation/pEp/jniadapter/{$jname}.java", "text") document("foundation/pEp/jniadapter/{$jname}.java", "text")
|| ||
// CodeGen template enum|exception // CodeGen template enum
package foundation.pEp.jniadapter; package foundation.pEp.jniadapter;
import java.util.HashMap; import java.util.HashMap;
`` apply ".", 0, mode=inner `` apply ".", 0, mode=inner
|| ||
} }
template "enum|exception", mode=inner { template "enum", mode=inner {
const "jname" call "CamelCase" with "text", "@name"; const "jname" call "CamelCase" with "text", "@name";
|| ||
// CodeGen template enum|exception, mode=inner // CodeGen template enum, mode=inner
public enum «$jname» { public enum «$jname» {
`` apply "*", mode=value `` apply "*", mode=value
; ;
@ -123,6 +128,24 @@ tstylesheet {
|| ||
} }
function "exception" {
param "name";
document "foundation/pEp/jniadapter/exceptions/{$name}.java", "text" {
| package foundation.pEp.jniadapter.exceptions;
|
| public class «$name» extends pEpException {
| public «$name»(String message) {
| super(message);
| }
| }
}
}
template "exception" for "*[text()!=0]" call "exception"
with "name" call "CamelCase" with "text", "name(.)";
template "*", mode=entry { template "*", mode=entry {
const "ctype", "name(.)"; const "ctype", "name(.)";
const "type" call "toJava" with "type", "name(.)"; const "type" call "toJava" with "type", "name(.)";

35
src/gen_java_exceptions.ysl2

@ -1,35 +0,0 @@
include yslt.yml2
tstylesheet {
include ./textutils.ysl2
template "/" {
| package foundation.pEp.jniadapter;
|
| public class pEpException extends RuntimeException {
| public pEpException(String message) {
| super(message);
| }
| }
apply "namespace/exception[@name='Status']", 0;
}
function "exception" {
param "name";
document "foundation/pEp/jniadapter/{$name}.java", "text" {
| package foundation.pEp.jniadapter;
|
| public class «$name» extends pEpException {
| public «$name»(String message) {
| super(message);
| }
| }
}
}
template "exception" for "*[text()!=0]" call "exception"
with "name" call "CamelCase" with "text", "name(.)";
}

59
src/gen_throw_pEp_exception.ysl2

@ -18,42 +18,43 @@ tstylesheet {
}; };
|| ||
document("gen_throw_pEp_exception.marker", "text") > ""
} }
template "namespace" template "namespace"
|| document("throw_pEp_exception.cc", "text")
#include <assert.h> ||
#include <pEp/pEpEngine.h> #include <assert.h>
#include "throw_pEp_exception.hh" #include <pEp/pEpEngine.h>
#include "throw_pEp_exception.hh"
namespace pEp { namespace pEp {
namespace JNIAdapter { namespace JNIAdapter {
jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status) jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status)
{ {
jclass ex; jclass ex;
const char *ex_name; const char *ex_name;
switch (status) { switch (status) {
`` apply "exception/*[text()!=0]", 4, mode=case `` apply "exception/*[text()!=0]", 4, mode=case
default: default:
assert(0); assert(0);
ex_name = "Exception"; ex_name = "Exception";
} }
ex = env->FindClass(ex_name); ex = env->FindClass(ex_name);
assert(ex);
if (ex == NULL) {
ex = env->FindClass("java/lang/NoClassDefFoundError");
assert(ex); assert(ex);
if (ex == NULL) {
ex = env->FindClass("java/lang/NoClassDefFoundError");
assert(ex);
}
return env->ThrowNew(ex, ex_name);
} }
};
return env->ThrowNew(ex, ex_name);
}
}; };
}; ||
||
template "*", mode=case { template "*", mode=case {
| case `call "UCASE" with "text", "name(.)"`: | case `call "UCASE" with "text", "name(.)"`:

2
test/java/foundation/pEp/jniadapter/test/jni88/TestMain.java

@ -1,5 +1,7 @@
package foundation.pEp.jniadapter.test.jni88; package foundation.pEp.jniadapter.test.jni88;
import foundation.pEp.jniadapter.*; import foundation.pEp.jniadapter.*;
import foundation.pEp.jniadapter.exceptions.*;
import java.util.Vector; import java.util.Vector;
import java.lang.Thread; import java.lang.Thread;

1
test/java/foundation/pEp/jniadapter/test/jni91/TestMain.java

@ -1,5 +1,6 @@
package foundation.pEp.jniadapter.test.jni91; package foundation.pEp.jniadapter.test.jni91;
import foundation.pEp.jniadapter.*; import foundation.pEp.jniadapter.*;
import foundation.pEp.jniadapter.exceptions.*;
import java.lang.Thread; import java.lang.Thread;

1
test/java/foundation/pEp/jniadapter/test/jni92/TestMain.java

@ -1,4 +1,5 @@
package foundation.pEp.jniadapter.test.jni92; package foundation.pEp.jniadapter.test.jni92;
import foundation.pEp.jniadapter.exceptions.*;
import foundation.pEp.jniadapter.test.utils.*; import foundation.pEp.jniadapter.test.utils.*;
import foundation.pEp.pitytest.*; import foundation.pEp.pitytest.*;
import foundation.pEp.jniadapter.*; import foundation.pEp.jniadapter.*;

Loading…
Cancel
Save