From d477a74b7f9119ffec9b153f47a169a9e3a8f0f2 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 24 Oct 2006 06:06:16 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/Awk.java | 10 +-- ase/awk/makefile.cl | 2 +- ase/test/awk/Awk.java | 147 +++++++++++++++++++++++++++++++++++++++ ase/test/awk/makefile.cl | 5 ++ 4 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 ase/test/awk/Awk.java diff --git a/ase/awk/Awk.java b/ase/awk/Awk.java index b0c630b9..dce8927a 100644 --- a/ase/awk/Awk.java +++ b/ase/awk/Awk.java @@ -1,5 +1,5 @@ /* - * $Id: Awk.java,v 1.2 2006-10-24 06:03:14 bacon Exp $ + * $Id: Awk.java,v 1.3 2006-10-24 06:05:01 bacon Exp $ */ package ase.awk; @@ -19,15 +19,15 @@ public abstract class Awk private long __awk; - public Awk () throws ase.awk.Exception + public Awk () throws Exception { open (); } public native void close (); - public native void parse () throws ase.awk.Exception; - public native void run () throws ase.awk.Exception; - private native void open () throws ase.awk.Exception; + public native void parse () throws Exception; + public native void run () throws Exception; + private native void open () throws Exception; /* protected native void set_extio (long extio, Object obj); diff --git a/ase/awk/makefile.cl b/ase/awk/makefile.cl index acab21cd..19f84a0e 100644 --- a/ase/awk/makefile.cl +++ b/ase/awk/makefile.cl @@ -33,7 +33,7 @@ java: javac -classpath ../.. Awk.java Extio.java Exception.java clean: - del $(OBJS) $(OUT) *.obj + del $(OBJS) $(OUT) *.obj *.class .SUFFIXES: .c .obj .c.obj: diff --git a/ase/test/awk/Awk.java b/ase/test/awk/Awk.java new file mode 100644 index 00000000..a7e18005 --- /dev/null +++ b/ase/test/awk/Awk.java @@ -0,0 +1,147 @@ +/* + * $Id: Awk.java,v 1.1 2006-10-24 06:03:14 bacon Exp $ + */ + +package ase.test.awk; + +import java.io.*; + +public class Awk extends ase.awk.Awk +{ + private FileReader insrc; + private FileWriter outsrc; + + public Awk () throws ase.awk.Exception + { + super (); + } + + protected int open_source (int mode) + { + if (mode == SOURCE_READ) + { + try { insrc = new FileReader ("test.awk"); } + catch (IOException e) { return -1; } + return 1; + } + else if (mode == SOURCE_WRITE) + { + try { outsrc = new FileWriter ("test.out"); } + catch (IOException e) { return -1; } + return 1; + } + + return -1; + } + + protected int close_source (int mode) + { + if (mode == SOURCE_READ) + { + try { insrc.close (); } + catch (IOException e) { return -1; } + return 0; + } + else if (mode == SOURCE_WRITE) + { + try { outsrc.close (); } + catch (IOException e) { return -1; } + return 0; + } + + return -1; + } + + protected int read_source (char[] buf, int len) + { + try { return insrc.read (buf, 0, len); } + catch (IOException e) { return -1; } + } + + protected int write_source (char[] buf, int len) + { + try { outsrc.write (buf, 0, len); } + catch (IOException e) { return -1; } + return len; + } + + protected int open_console () + { + System.err.println ("[open_console called....]"); + return 1; + } + + protected int close_console () + { + System.err.println ("[close_console called....]"); + return 1; + } + + protected int read_console (char[] buf, int len) + { + return 0; + } + + protected int write_console (char[] buf, int len) + { + System.out.print (new String (buf, 0, len)); + return len; + } + + protected int next_console (char[] buf, int len) + { + return 0; + } + + public int open_file (ase.awk.Extio extio) + { + System.out.print ("opening file ["); + //System.out.print (extio.name()); + System.out.println ("]"); + + /* + FileInputStream f = new FileInputStream (extio.name()); + extio.setHandle (f); + */ + return 1; + } + + /* + public int open_file (String name) + { + System.out.print ("opening file ["); + System.out.print (name); + System.out.println ("]"); + return 1; + } + */ + + public int close_file (String name) + { + System.out.print ("closing file ["); + System.out.print (name); + System.out.println ("]"); + return 0; + } + + public static void main (String[] args) + { + Awk awk = null; + + try + { + awk = new Awk (); + awk.parse (); + awk.run (); + } + catch (ase.awk.Exception e) + { + System.out.println ("ase.awk.Exception - " + e.getMessage()); + } + finally + { + if (awk != null) awk.close (); + } + } + +} diff --git a/ase/test/awk/makefile.cl b/ase/test/awk/makefile.cl index dec7cb8c..2ca3204e 100644 --- a/ase/test/awk/makefile.cl +++ b/ase/test/awk/makefile.cl @@ -17,6 +17,11 @@ rex2: rex2.obj rex3: rex3.obj link /nologo /out:rex3.exe $(LDFLAGS) $(LIBS) rex3.obj +java: + javac -classpath ../../.. Awk.java + +jrun: + java -classpath ../../.. ase.test.awk.Awk clean: del $(OBJS) *.obj awk.exe rex.exe