From 8cc7a08171dee399cc065a9e69ca7b5e79b7b0ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Wed, 29 Jul 2015 08:52:40 -0400 Subject: [PATCH 1/1] contrib/jwrapper: use declared upper bounds to set extern parameters types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/jwrapper/src/javap_visitor.nit | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/contrib/jwrapper/src/javap_visitor.nit b/contrib/jwrapper/src/javap_visitor.nit index 899930d..fe81c88 100644 --- a/contrib/jwrapper/src/javap_visitor.nit +++ b/contrib/jwrapper/src/javap_visitor.nit @@ -175,7 +175,6 @@ redef class Nbase_type private fun to_java_type: JavaType do # By default, everything is bound by object - # TODO use a more precise bound var jtype = new JavaType jtype.identifier.add_all(["java", "lang", "object"]) return jtype @@ -215,6 +214,20 @@ redef class Nbase_type_extends redef fun to_java_type do return n_generic_identifier.to_java_type end +redef class Nbase_type_super + redef fun to_java_type + do + var bounds = n_type_bound.to_a + + # Java use more than one lower bound, + # it can't be translated statically to Nit, + # so we use the only the first one. + # This may cause problems on complex generic types, + # but these cases can be handled manually. + return bounds.first + end +end + redef class Ngeneric_identifier private fun to_java_type: JavaType is abstract end @@ -311,3 +324,21 @@ redef class Nodes return false end end + +redef class Ntype_bound + # Get the types composing this bound + private fun to_a: Array[JavaType] is abstract +end + +redef class Ntype_bound_head + redef fun to_a do return [n_full_class_name.to_java_type] +end + +redef class Ntype_bound_tail + redef fun to_a + do + var a = n_type_bound.to_a + a.add n_full_class_name.to_java_type + return a + end +end -- 1.7.9.5