JIMS code

Calixte.Denizet at ac-rennes.fr Calixte.Denizet at ac-rennes.fr
Sat Mar 20 19:35:26 CET 2010


> Hello,

Hello

> 
> I am adding Calixte as as C/C. He is the developer of JIMS and he will
> be better than me to answer to you.
> 
> Cheers,
> Sylvestre
> 
> Le samedi 20 mars 2010 à 18:40 +0800, sploving a écrit :
> > Hello,
> >    I am learning the code of JIMS in order to know how to import Python
> > in Scilab. I found Scilab use the mlist to wrap the Java class/ object.
> > I want to use the mlist to wrap the Python object,will that be OK?
> Yes
> 
> >  The implement of the JIMS is as the following: Scilab use the Scilab/C
> > API to call C/C++, which could use the JNI to call java. When I read 
> the
> > file "wrapInMlist.sci", I could not understand it very well. Could you
> > explain how the Java object/methods/fields are wrapped in mlist ? 

For the moment (actual version on git master) :
java class {
 field F
 method M
}

is converted into the mlist : obj = mlist(['_JObj' '_id' 'M' 'F'])
 * _id is the pos of the object in an array on the java side, for example _id=314
 * for the method, I create a scilab function in using deff : deff('y=tmpmacro(varargin)','y=wrapInMList(invoke(314,''M'',varargin))')
    invoke returns the id of the object returned by the invocation of the method M of the object 314. The function tmpmacro is     affected to the field 'M' of the mlist
 * for the field, I create a function using deff too, the syntax in Scilab is obj.F(32) affects 32 to F on the java side and obj.F() gets the value of F.

I'm currently working to simplify the wrapping... (I don't push my work for the moment). I use the overloading of extraction to improve wrapping. The idea is :
function y=%_JObj_e(name,M) 
  if name is the name of a method of object M._id then
     deff('y=tmpmacro(varargin)','y=invoke(314,name,varargin)')
     y=tmpmacro
     return
  end
  if name is the name of a field then
    y=get field value...
  end
endfunction

Obj.foo(1,2,3) call the previous function with args foo and Obj, and it returns a function which takes 1,2,3 as arguments... I wrote %_JObj_e in C to have the best performances... I'll try to keep this last solution because the speed of execution is better and the consumption of memory is lower...

 For a
> > java class example:
> > 
> > public class test {
> >   double salary;
> >   String name;
> >   double getSalary() {
> >     return salary;
> > 
> >   }
> > }
> > After call the wrapInMlist.sci, what is content of the mlist 
> returned ? 
> > 
> 

If you want to see just use in Scilab the function getfield.

> 
> > ps: the following code I cound not understand well (in the file
> > "wrapInMlist"):
> >  
> > wobj = mlist([infos 'new' meths fields], id);
> >       deff('y=tmpmacro(varargin)', 'y=wrapInMlist(newInstance_l(' + 
> sid
> > + ',varargin))');
> >       setfield(3, tmpmacro, wobj);
> > 
> > s = size(meths, 2);
> >   for i=1:s
> >       deff('y=tmpmacro(varargin)', 'y=wrapInMlist(invoke_l(' + sid +
> > ',''' + meths(i) + ''',varargin))');
> >       setfield(i + dec, tmpmacro, wobj);
> >       clear('tmpmacro');
> >   end
> > 
> > When I ask questions,  do I ask you directly in this mail or use the
> > mail list gsoc at lists.scilab.org ? 
> > Thanks in advance
> > 

Have fun and don't hesitate to contact me ...

> > Baozeng
> > 

Calixte

> >  
> >   
> > 
> 
> -- 
> -------------------------
> Sylvestre Ledru
> -------------------------
> The Scilab Consortium
> Digiteo
> Domaine de Voluceau
> Rocquencourt - B.P. 105
> 78153 Le Chesnay Cedex
> France
> 
> 
> 



More information about the dev mailing list