This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

requiring a module from java


Dear all,
I finally found a recipe to load compiled modules from java in order to
provide a scripting environment; I post some skeleton code here.
This code can be made more flexible using reflection instead of static
instantiation.
I'm not a kawa internal expert so please excuse redundancies in the
source, and send smarter solutions if you knows any.

	Marco

PS when I first wrote this letter, our mail servers where down so I lost
it (I think), so I apologize for the eventual duplication. 

//this is the object that provides the application scriptability
import kawa.lang.*;
import kawa.standard.*;
import gnu.mapping.*;
import mymodule
...

Scheme scm;

...

  protected void setUp(){
	//set up a new interpreter
    scm=new Scheme();
    Scheme.registerEnvironment();
    Environment.setCurrent(scm.getEnvironment());

	//load a module generated with (module-name <mymodule>)
    mymodule mm1=new mymodule();
    mm1.run();
    gnu.kawa.reflect.ClassMemberConstraint.defineAll(mm1,
scm.getEnvironment());
    require.find(mymodule.class,scm.getEnvironment());
 }


  private Object eval(String value){
    try{
      return scm.eval(value);
    }catch(Exception e){
	...
      return null;
    }
  }

-- 
	(--cafe babe--) 
Marco Vezzoli	marco.vezzoli@st.com
CR&D Intranet Developement   STMicroelectronics
tel. +39 039 603 6852 fax. +39 039 603 5055

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]