Browse Source

eliminate public native methods (wrap all in native methods in "normal" java method) // CodeGen - convert needs to go

JNI-106
heck 5 years ago
parent
commit
f3ed199b69
  1. 2
      src/gen_cpp_Engine.ysl2
  2. 91
      src/gen_java_Engine.ysl2

2
src/gen_cpp_Engine.ysl2

@ -298,7 +298,7 @@ tstylesheet {
} }
function "mangle" { function "mangle" {
const "convert", "count(parm/stringlist|parm/string|parm/identity|parm/identitylist) > 0"; const "convert", "1";
choose { choose {
when "$convert" when "$convert"

91
src/gen_java_Engine.ysl2

@ -23,6 +23,7 @@ tstylesheet {
} }
|| ||
/*
document("foundation/pEp/jniadapter/{$cname}Interface.java", "text") document("foundation/pEp/jniadapter/{$cname}Interface.java", "text")
|| ||
package foundation.pEp.jniadapter; package foundation.pEp.jniadapter;
@ -34,72 +35,54 @@ tstylesheet {
`` apply "method", mode=java_interface `` apply "method", mode=java_interface
`` apply "basic", mode=java_interface `` apply "basic", mode=java_interface
} }
|| ||
*/
} }
template "basic" { template "basic" {
const "itype" call "toIntermediate" with "type", "@type"; const "itype" call "toIntermediate" with "type", "@type";
const "jtype" call "toJava" with "type", "@type"; const "jtype" call "toJava" with "type", "@type";
choose { ||
when "name(parm/*[1])='bytearray|identitylist'" private native «$itype» _«@name»(`apply "parm/*", mode=basic_iparm`);
||
public native «$itype» «@name»(`apply "parm/*", mode=basic_iparm`);
||
otherwise {
||
private native «$itype» _«@name»(`apply "parm/*", mode=basic_iparm`);
public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`) { public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`) {
||
apply "parm/*", mode=basic_parm_set;
choose {
when "@type = 'void'"
|> _«@name»(`apply "parm/*", mode=basic_parm_name`);
when "@type = 'identity'"
|> return new Identity(_«@name»(`apply "parm/*", mode=basic_parm_name`));
when "@type = 'bool'"
|> return new Boolean(_«@name»(`apply "parm/*", mode=basic_parm_name`));
when "@type = 'identitylist'" {
|| ||
apply "parm/*", mode=basic_parm_set; Vector<_Identity> glist = _«@name»(`apply "parm/*", mode=basic_parm_name`);
choose { Vector<Identity> ret = new Vector<Identity>();
when "@type = 'void'" if(glist != null) {
|> _«@name»(`apply "parm/*", mode=basic_parm_name`); for (_Identity i : glist) {
when "@type = 'identity'" ret.add(new Identity(i));
|> return new Identity(_«@name»(`apply "parm/*", mode=basic_parm_name`));
when "@type = 'bool'"
|> return new Boolean(_«@name»(`apply "parm/*", mode=basic_parm_name`));
when "@type = 'identitylist'" {
||
Vector<_Identity> glist = _«@name»(`apply "parm/*", mode=basic_parm_name`);
Vector<Identity> ret = new Vector<Identity>();
if(glist != null) {
for (_Identity i : glist) {
ret.add(new Identity(i));
}
} }
return ret; }
|| return ret;
} otherwise
|> return Utils.toUTF16(_«@name»(`apply "parm/*", mode=basic_parm_name`));
}
||
}
|| ||
} } otherwise
|> return Utils.toUTF16(_«@name»(`apply "parm/*", mode=basic_parm_name`));
}
||
} }
||
} }
template "basic" mode=java_interface { template "basic" mode=java_interface {
const "itype" call "toIntermediate" with "type", "@type"; const "itype" call "toIntermediate" with "type", "@type";
const "jtype" call "toJava" with "type", "@type"; const "jtype" call "toJava" with "type", "@type";
choose { ||
when "name(parm/*[1])='bytearray'" public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`);
|| ||
public native «$itype» «@name»(`apply "parm/*", mode=basic_iparm`);
||
otherwise {
||
public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`);
||
}
}
} }
template "*", mode=basic_parm_name choose { template "*", mode=basic_parm_name choose {
@ -193,7 +176,7 @@ 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", "1";
const "singlereturn", "count(parm/creates|parm/returns|parm/inout[../int]) = 1"; const "singlereturn", "count(parm/creates|parm/returns|parm/inout[../int]) = 1";
const "multireturn", "count(parm/creates|parm/returns|parm/inout[../int]) > 1"; const "multireturn", "count(parm/creates|parm/returns|parm/inout[../int]) > 1";
@ -236,8 +219,9 @@ tstylesheet {
ArrayList<Pair<byte[], byte[]>> glist = _«@name»(`apply "parm[in]", mode=call;`); ArrayList<Pair<byte[], byte[]>> glist = _«@name»(`apply "parm[in]", mode=call;`);
if(glist != null){ if(glist != null){
ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>(); ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
for (Pair<byte[],byte[]> i : glist) for (Pair<byte[],byte[]> i : glist) {
list.add(new Pair<String, String>(Utils.toUTF16(i.first), Utils.toUTF16(i.second))); list.add(new Pair<String, String>(Utils.toUTF16(i.first), Utils.toUTF16(i.second)));
}
return list; return list;
} }
return null; return null;
@ -250,8 +234,9 @@ tstylesheet {
Vector<_Identity> glist = _«@name»(`apply "parm[in]", mode=call;`); Vector<_Identity> glist = _«@name»(`apply "parm[in]", mode=call;`);
if(glist != null){ if(glist != null){
Vector<Identity> list = new Vector<Identity>(); Vector<Identity> list = new Vector<Identity>();
for (_Identity i : glist) for (_Identity i : glist) {
list.add(new Identity(i)); list.add(new Identity(i));
}
return list; return list;
} }
return null; return null;
@ -271,7 +256,6 @@ tstylesheet {
if "not($singlereturn) and not($multireturn)" if "not($singlereturn) and not($multireturn)"
|| ||
_«@name»(`apply "parm[in]", mode=call;`); _«@name»(`apply "parm[in]", mode=call;`);
return;
|| ||
|| ||
@ -350,8 +334,9 @@ tstylesheet {
when "$type = 'identitylist'" when "$type = 'identitylist'"
|| ||
Vector<_Identity> _«$name» = new Vector<_Identity>(); Vector<_Identity> _«$name» = new Vector<_Identity>();
for (Identity i : «$name») for (Identity i : «$name») {
_«$name».add(new _Identity(i)); _«$name».add(new _Identity(i));
}
|| ||
} }
} }

Loading…
Cancel
Save