Browse Source

inout for Integers

Volker Birk 7 years ago
parent
commit
c5a8cc8283
  1. 39
      src/gen_cpp_Engine.ysl2
  2. 8
      src/gen_java_Engine.ysl2
  3. 3
      src/types_c.ysl2
  4. 5
      src/types_java.ysl2

39
src/gen_cpp_Engine.ysl2

@ -78,7 +78,7 @@ tstylesheet {
result_ = env->NewObject(clazz_result_, constructor_result_, obj); result_ = env->NewObject(clazz_result_, constructor_result_, obj);
|| ||
apply "parm[returns|creates]", mode=setresult apply "parm[returns|creates|inout[../int]]", mode=setresult
with "jtype" > org/pEp/jniadapter/Engine$_«@name»_Return with "jtype" > org/pEp/jniadapter/Engine$_«@name»_Return
|| ||
@ -89,7 +89,7 @@ tstylesheet {
when "$returning = 1" { when "$returning = 1" {
|| ||
return «name(parm[returns|creates]/*[3])»_; return «name(parm[returns|creates|inout[../int]]/*[3])»_;
|| ||
} }
} }
@ -102,25 +102,39 @@ tstylesheet {
template "parm", mode=setresult { template "parm", mode=setresult {
param "jtype"; param "jtype";
const "sig" call "toSig" with "type", "name(*[2])"; const "dir", "name(*[1])";
const "type", "name(*[2])";
const "name", "name(*[3])"; const "name", "name(*[3])";
const "sig" call "toSig" with "type", "$type";
|| ||
jfieldID «$name»_field = getFieldID(env, "«$jtype»", jfieldID «$name»_field = getFieldID(env, "«$jtype»",
"«$name»", "«$sig»"); "«$name»", "«$sig»");
if («$name»_)
env->SetObjectField(result_, «$name»_field, «$name»_);
||
if "$name = 'dst'"
||
else
env->SetObjectField(result_, «$name»_field, src);
|| ||
choose {
when "$type='int'"
| env->SetIntField(result_, «$name»_field, _«$name»);
otherwise {
||
if («$name»_)
env->SetObjectField(result_, «$name»_field, «$name»_);
||
if "$name = 'dst'"
||
else
env->SetObjectField(result_, «$name»_field, src);
||
}
}
|| ||
|| ||
} }
template "parm", mode=return { template "parm", mode=return {
param "dir", "name(*[1])";
param "type", "name(*[2])"; param "type", "name(*[2])";
param "jtype" call "toJava" with "type", "$type"; param "jtype" call "toJava" with "type", "$type";
param "name", "name(*[3])"; param "name", "name(*[3])";
@ -174,7 +188,6 @@ tstylesheet {
|| ||
} }
otherwise { otherwise {
|| ||
jobject «$name»_ = NULL; jobject «$name»_ = NULL;
@ -203,10 +216,8 @@ tstylesheet {
| √$type _«$name» = to_«$type»(env, «$name»); | √$type _«$name» = to_«$type»(env, «$name»);
when "$type='bool'" when "$type='bool'"
| bool _«$name» = (bool) «$name»; | bool _«$name» = (bool) «$name»;
when "$type='int' and $dir='in'" when "$type='int'"
| int _«$name» = (int) «$name»; | int _«$name» = (int) «$name»;
when "$type='int' and $dir='inout'"
| √$type _«$name» = to_Integer(env, «$name»);
otherwise otherwise
| √$type *_«$name» = to_«$type»(env, «$name»); | √$type *_«$name» = to_«$type»(env, «$name»);
} }

8
src/gen_java_Engine.ysl2

@ -137,21 +137,21 @@ tstylesheet {
template "method", mode=plain { template "method", mode=plain {
const "convert", "count(parm/stringlist|parm/stringpairlist|parm/string|parm/identity|parm/identitylist) > 0"; const "convert", "count(parm/stringlist|parm/stringpairlist|parm/string|parm/identity|parm/identitylist) > 0";
const "singlereturn", "count(parm/creates|parm/returns) = 1"; const "singlereturn", "count(parm/creates|parm/returns|parm/inout[../int]) = 1";
const "multireturn", "count(parm/creates|parm/returns) > 1"; const "multireturn", "count(parm/creates|parm/returns|parm/inout[../int]) > 1";
if "$multireturn" { if "$multireturn" {
if "$convert" if "$convert"
|| ||
private class _«@name»_Return { private class _«@name»_Return {
`` apply "parm[creates|returns]", 1, mode=intermediate with "public", 1; `` apply "parm[creates|returns|inout[../int]]", 1, mode=intermediate with "public", 1;
} }
|| ||
|| ||
public class «@name»_Return { public class «@name»_Return {
`` apply "parm[creates|returns]", 1, mode=java with "public", 1; `` apply "parm[creates|returns|inout[../int]]", 1, mode=java with "public", 1;
} }
|| ||

3
src/types_c.ysl2

@ -28,8 +28,7 @@ function "jni_type" {
when "../enum[@name=$type]" > jint when "../enum[@name=$type]" > jint
when "$type = 'string' or $type = 'sstring'" > jbyteArray when "$type = 'string' or $type = 'sstring'" > jbyteArray
when "$type='bool'" > jboolean when "$type='bool'" > jboolean
when "$type='int' and $dir!='inout'" > jint when "$type='int'" > jint
when "$type='int' and $dir='inout'" > jobject
otherwise > jobject otherwise > jobject
} }
} }

5
src/types_java.ysl2

@ -3,7 +3,7 @@ function "toJava" {
choose { choose {
when "$type='bool'" > Boolean when "$type='bool'" > Boolean
when "$type='int'" > Integer when "$type='int'" > int
when "$type='string' or $type='sstring'" > String when "$type='string' or $type='sstring'" > String
when "$type='timestamp'" > Date when "$type='timestamp'" > Date
when "$type='void'" > void when "$type='void'" > void
@ -63,8 +63,7 @@ function "toIntermediate" {
choose { choose {
when "$type='bool'" > boolean when "$type='bool'" > boolean
when "$type='int' and $dir!='inout'" > int when "$type='int'" > int
when "$type='int' and $dir='inout'" > Integer
when "$type='string' or $type='sstring'" > byte[] when "$type='string' or $type='sstring'" > byte[]
when "$type='bloblist'" > Vector<_Blob> when "$type='bloblist'" > Vector<_Blob>

Loading…
Cancel
Save