Browse Source

adding inout for Integer

Volker Birk 7 years ago
parent
commit
be51e38280
  1. 9
      src/gen_cpp_Engine.ysl2
  2. 6
      src/gen_java_Engine.ysl2
  3. 20
      src/jniutils.cc
  4. 3
      src/jniutils.hh
  5. 3
      src/pEp.yml2
  6. 4
      src/types_c.ysl2
  7. 5
      src/types_java.ysl2

9
src/gen_cpp_Engine.ysl2

@ -192,6 +192,7 @@ tstylesheet {
}
template "parm", mode=in {
const "dir", "name(*[1])";
const "type", "name(*[2])";
const "name", "name(*[3])";
@ -202,8 +203,10 @@ tstylesheet {
| √$type _«$name» = to_«$type»(env, «$name»);
when "$type='bool'"
| bool _«$name» = (bool) «$name»;
when "$type='int'"
when "$type='int' and $dir='in'"
| int _«$name» = (int) «$name»;
when "$type='int' and $dir='inout'"
| √$type _«$name» = to_Integer(env, «$name»);
otherwise
| √$type *_«$name» = to_«$type»(env, «$name»);
}
@ -239,6 +242,8 @@ tstylesheet {
> &_«$name», &_«$name»_size
when "$dir = 'creates' or $dir = 'returns'"
> &_«$name»
when "$dir = 'inout' and $type='int'"
> (unsigned int *) &_«$name»
otherwise
> _«$name»
}
@ -257,7 +262,7 @@ tstylesheet {
template "parm", mode=sig {
const "name", "name(*[3])";
> ,\n `call "jni_type" with "type", "name(*[2])"` «$name»
> ,\n `call "jni_type" with "type", "name(*[2])", with "dir", "name(*[1])"` «$name»
}
}

6
src/gen_java_Engine.ysl2

@ -242,7 +242,8 @@ tstylesheet {
indent(0);
if "$public" > public
> †$type «translate($name,'-','_')»
call "toJava" with "type", "$type";
> «translate($name,'-','_')»
choose {
when "$public" > ;
otherwise if "position()!=last()" > ,
@ -259,7 +260,8 @@ tstylesheet {
indent(0);
if "$public" > public
> ¡$type «translate($name,'-','_')»
call "toIntermediate" with "type", "$type", with "dir", "$dir";
> «translate($name,'-','_')»
choose {
when "$public" > ;
otherwise if "position()!=last()" > ,

20
src/jniutils.cc

@ -186,6 +186,26 @@ namespace pEp {
return env->ThrowNew(ex, ex_name);
}
jobject from_Integer(JNIEnv *env, int val)
{
assert(env);
jclass clazz = findClass(env, "java/lang/Integer");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(I)V");
assert(constructor);
jobject obj = env->NewObject(clazz, constructor, val);
assert(obj);
env->DeleteLocalRef(clazz);
return obj;
}
int to_Integer(JNIEnv *env, jobject obj)
{
assert(env && obj);
int _val = callIntMethod(env, obj, "intValue");
return _val;
}
jbyteArray from_string(JNIEnv *env, const char *str)
{
if (str && str[0]) {

3
src/jniutils.hh

@ -151,6 +151,9 @@ namespace pEp {
jint outOfMemory(JNIEnv *env);
jobject from_Integer(JNIEnv *env, int val);
int to_Integer(JNIEnv *env, jobject obj);
jbyteArray from_string(JNIEnv *env, const char *str);
char *to_string(JNIEnv *env, jbyteArray str);

3
src/pEp.yml2

@ -174,8 +174,7 @@ namespace pEp {
creates message dst,
creates stringlist keylist,
returns Rating rating,
/* TODO replace with int, this is a OR of multipla DecryptFlags */
returns DecryptFlags flags
inout int flags
);
method re_evaluate_message_rating(

4
src/types_c.ysl2

@ -22,12 +22,14 @@ function "toC" {
function "jni_type" {
param "type";
param "dir";
choose {
when "../enum[@name=$type]" > jint
when "$type = 'string' or $type = 'sstring'" > jbyteArray
when "$type='bool'" > jboolean
when "$type='int'" > jint
when "$type='int' and $dir!='inout'" > jint
when "$type='int' and $dir='inout'" > jobject
otherwise > jobject
}
}

5
src/types_java.ysl2

@ -35,6 +35,7 @@ function "toSig" {
> L
choose {
when "$type='timestamp'" > java/util/Date
when "$type='int'" > java/lang/Integer
when "$type='identity'" > org/pEp/jniadapter/_Identity
when "$type='message'" > org/pEp/jniadapter/Message
@ -58,10 +59,12 @@ function "toSig" {
function "toIntermediate" {
param "type";
param "dir";
choose {
when "$type='bool'" > boolean
when "$type='int'" > int
when "$type='int' and $dir!='inout'" > int
when "$type='int' and $dir='inout'" > Integer
when "$type='string' or $type='sstring'" > byte[]
when "$type='bloblist'" > Vector<_Blob>

Loading…
Cancel
Save