Index: ChangeLog =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/ChangeLog,v retrieving revision 1.26 diff -u -3 -p -u -r1.26 ChangeLog --- ChangeLog 4 May 2005 11:05:52 -0000 1.26 +++ ChangeLog 4 May 2005 14:27:53 -0000 @@ -1,5 +1,20 @@ 2005-05-04 Andrew John Hughes + * lib/Makefile.am: + Added build of services.jar and conditional mkdir. + * src/nongnu/cashews/services/TypeChecker.java: + (callService): Commented out. + (TEST_ENDPOINT): New constant. + +2005-05-04 Atheesh Sanka + + * src/nongnu/cashews/services/TypeChecker.java: + New class. + (main(String[])): Call the service using command-line input. + + +2005-05-04 Andrew John Hughes + * src/nongnu/cashews/language/expression/HaskellFunction.java: New class. (function): New field. Index: lib/.cvsignore =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/lib/.cvsignore,v retrieving revision 1.4 diff -u -3 -p -u -r1.4 .cvsignore --- lib/.cvsignore 4 May 2005 07:31:55 -0000 1.4 +++ lib/.cvsignore 4 May 2005 14:27:53 -0000 @@ -8,6 +8,7 @@ cashews.jar rdf.jar commons.jar xml.jar +services.jar deps.sh gen-classlist.sh mkdep.pl Index: lib/Makefile.am =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/lib/Makefile.am,v retrieving revision 1.6 diff -u -3 -p -u -r1.6 Makefile.am --- lib/Makefile.am 4 May 2005 07:31:55 -0000 1.6 +++ lib/Makefile.am 4 May 2005 14:27:53 -0000 @@ -52,13 +52,13 @@ JAVAH = $(USER_JAVAH) -jni -classpath .: if INSTALL_GLIBJ_ZIP if FOUND_ECLIPSE -pkgdata_DATA = commons.jar xml.jar rdf.jar owls.jar cashews.jar eclipse.jar +pkgdata_DATA = commons.jar xml.jar rdf.jar owls.jar cashews.jar services.jar eclipse.jar install-data-local: genclasses compile-classes eclipse.jar - mkdir $(INSTALLDIR) + if [ ! -e $(INSTALLDIR) ]; then mkdir $(INSTALLDIR); fi cp eclipse.jar $(INSTALLDIR) cp $(top_srcdir)/resource/plugin.xml $(INSTALLDIR) else -pkgdata_DATA = commons.jar xml.jar rdf.jar cashews.jar owls.jar +pkgdata_DATA = commons.jar xml.jar rdf.jar cashews.jar owls.jar services.jar endif endif # INSTALL_GLIBJ_ZIP @@ -109,6 +109,12 @@ if FOUND_GCJ $(GCJ) -shared -fjni -findirect-dispatch -o cashews.jar.so cashews.jar endif +services.jar: classes compile-classes # resources + if test "$(JAR)" != ""; then rm services.jar; $(JAR) cf services.jar `find nongnu -path '*services*' -name '*class'` > /dev/null; fi +if FOUND_GCJ +$(GCJ) -shared -fjni -findirect-dispatch -o services.jar.so services.jar +endif + if FOUND_ECLIPSE eclipse.jar: classes compile-classes # resources Index: src/nongnu/cashews/services/TypeChecker.java =================================================================== RCS file: src/nongnu/cashews/services/TypeChecker.java diff -N src/nongnu/cashews/services/TypeChecker.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/services/TypeChecker.java 4 May 2005 14:27:53 -0000 @@ -0,0 +1,120 @@ +/* TypeChecking.java -- A program to evaluate the type of haskell code. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.services; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; + +/* FIXME: COMMENTED OUT UNTIL IT WORKS WITHIN THE PROJECT +import org.apache.axis.client.Call; +import org.apache.axis.client.Service; +*/ + +/** + * A client implementation to call the type checking web service. + * + * @author Atheesh Sanka (address@hidden) + * @author Andrew John Hughes (address@hidden) + */ +public class TypeChecker +{ + + /** + * A test endpoint for the service within the DCS. + */ + private static final String TEST_ENDPOINT = + "http://esk.dcs.shef.ac.uk:8080/typeCheckingService"; + + /** + * A simple test harness to call the type checker. + * + * @param args the command-line arguments. + * @throws IOException if an I/O error occurs. + */ + public static void main(String[] args) + throws IOException + { + BufferedReader br = + new BufferedReader(new InputStreamReader(System.in)); + String expression; + + System.out.print("Please enter the expression: "); + + expression = br.readLine(); + + /* FIXME: COMMENTED OUT UNTIL IT WORKS WITHIN THE PROJECT + boolean flag = new TypeChecker().callService(expression); + + if( flag == false ) + System.out.println( "Invalid expression" ); + */ + } + + + /** + * Calls the type checking web service with the supplied + * expression. The supplied expression should contain valid Haskell + * code. + * + * @param expression the expression to supply to the service. + * @return true if the code typed correctly, false otherwise. + */ + /* FIXME: COMMENTED OUT UNTIL IT WORKS WITHIN THE PROJECT + public boolean callService( String expression ) + { + try + { + Service service = new Service(); + + Call call = (Call) service.createCall(); + + call.setTargetEndpointAddress( new java.net.URL(TEST_ENDPOINT) ); + + call.setOperationName("typeCheckRequest"); + + call.addParameter("expr", org.apache.axis.Constants.XSD_STRING, + javax.xml.rpc.ParameterMode.IN); + + call.setReturnType( org.apache.axis.Constants.XSD_STRING ); + + String result = (String) call.invoke( new Object[] { expression } ); + + if( result.indexOf( "error" ) == -1 ) + { + System.out.println( "The type of '" + expression + "' is '" + + result + "'" ); + return true; + } + else + return false; + + } + catch (Exception e) + { + System.err.println(e.toString()); + e.printStackTrace(); + return false; + } + } + */ +}