Re: [Ikvm-developers] fill extern c# method using attribute
Brought to you by:
jfrijters
From: Fabio G. <fab...@gm...> - 2012-11-27 15:59:40
|
I set class and method abstract as you say, now the code is the following, now i get this error on row marked with *** Unable to cast object of type 'java.lang.Class' to type 'java.lang.reflect.TypeVariable'. using System;using alice.tuprologx.pj.engine;using alice.tuprologx.pj.model;using java.lang.reflect;using java.util;using alice.tuprologx.pj.annotations;using List = alice.tuprologx.pj.model.List;using Type = java.lang.reflect.Type; namespace javaprolog { public class Program { static void Main(string[] args) { java.lang.Class c = java.lang.Class.forName("javaprolog.Perm, javaprolog"); Perm pu = (Perm)PJ.newInstance(c); Int val1 = new Int(new java.lang.Integer(1)); Int val2 = new Int(new java.lang.Integer(2)); Int val3 = new Int(new java.lang.Integer(3)); ArrayList l = new ArrayList(); l.add(val1); l.add(val2); l.add(val3); alice.tuprologx.pj.model.List list = new List(l); *** alice.tuprologx.pj.model.List p = pu.permutation(list); Console.WriteLine(p.toJava()); } } public abstract class Perm : java.lang.Object { [PrologMethodAttribute(clauses = new string[] { "permutation([],[]).", "permutation(U,[X|V]):-remove(U,X,Z),permutation(Z,V).", "remove([X|T],X,T).", "remove([X|U],E,[X|V]):-remove(U,E,V)." })] public abstract alice.tuprologx.pj.model.List permutation(alice.tuprologx.pj.model.List list); } } *Fabio Gravina* On Mon, Nov 12, 2012 at 5:06 PM, Jeroen Frijters <je...@su...> wrote: > Hi, > > You should not mark the method as "extern", this means it is a native > method. > > I'm not familiar with tuprolog, but I guess you should mark the method as > "abstract" (and the class too). > > Regards, > Jeroen > > > -----Original Message----- > > From: Fabio Gravina [mailto:fab...@gm...] > > Sent: Monday, November 12, 2012 11:12 > > To: ikv...@li... > > Subject: [Ikvm-developers] fill extern c# method using attribute > > > > Hi, > > I'm trying to fill my c# method using an attribute defined in java like > > in following code. > > Conpiling go fine, but at runtime i get the following error : > > "Could not load type 'javaprolog.Perm' from assembly 'javaprolog, > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the > > method 'permutation' has no implementation (no RVA)." > > > > > > Can you help me?? > > > > using System; > > using alice.tuprologx.pj.engine; > > using alice.tuprologx.pj.model; > > using java.util; > > using alice.tuprologx.pj.annotations; > > > > namespace javaprolog > > { > > public class Program > > { > > static void Main(string[] args) > > { > > java.lang.Class c = > > java.lang.Class.forName("javaprolog.Perm, javaprolog"); > > Perm pu = (Perm)PJ.newInstance(c); > > ... > > } > > } > > > > public class Perm : java.lang.Object > > { > > [PrologMethodAttribute(clauses = new string[] > > { > > "permutation([],[]).", > > "permutation(U,[X|V]):- > > remove(U,X,Z),permutation(Z,V).", > > "remove([X|T],X,T).", > > > > "remove([X|U],E,[X|V]):-remove(U,E,V)." > > })] > > public extern alice.tuprologx.pj.model.List > > permutation(alice.tuprologx.pj.model.List mylist); > > } > > } > > > > > > Fabio Gravina > > > > |