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. 33
      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"

33
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,21 +35,14 @@ 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'"
||
public native «$itype» «@name»(`apply "parm/*", mode=basic_iparm`);
||
otherwise {
|| ||
private native «$itype» _«@name»(`apply "parm/*", mode=basic_iparm`); private native «$itype» _«@name»(`apply "parm/*", mode=basic_iparm`);
@ -81,26 +75,15 @@ tstylesheet {
|| ||
} }
}
}
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 native «$itype» «@name»(`apply "parm/*", mode=basic_iparm`);
||
otherwise {
|| ||
public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`); public «$jtype» «@name»(`apply "parm/*", mode=basic_parm`);
|| ||
} }
}
}
template "*", mode=basic_parm_name choose { template "*", mode=basic_parm_name choose {
when "position() mod 2" { when "position() mod 2" {
@ -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