This commit is contained in:
2008-06-10 03:29:00 +00:00
parent 0c8fe75ed1
commit 9be49650e6
9 changed files with 101 additions and 51 deletions

View File

@ -1,745 +0,0 @@
/*
* $Id: AseAwk.java,v 1.16 2007/10/24 03:46:51 bacon Exp $
*/
import java.awt.*;
import java.awt.event.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.Reader;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.Iterator;
import java.net.URL;
import ase.awk.StdAwk;
import ase.awk.Console;
import ase.awk.Context;
import ase.awk.Argument;
import ase.awk.Return;
public class AseAwk extends StdAwk
{
private static void run_in_awt ()
{
final Frame frame = new Frame ();
frame.setLayout (new BorderLayout());
frame.setTitle (AseAwk.class.getName());
frame.setSize (640, 480);
frame.addWindowListener (new WindowListener ()
{
public void windowActivated (WindowEvent e) {}
public void windowClosed (WindowEvent e) {}
public void windowClosing (WindowEvent e) { frame.dispose (); }
public void windowDeactivated (WindowEvent e) {}
public void windowDeiconified (WindowEvent e) {}
public void windowIconified (WindowEvent e) {}
public void windowOpened (WindowEvent e) {}
});
frame.add (new AseAwkPanel(), BorderLayout.CENTER);
frame.setVisible (true);
}
private static void print_usage ()
{
System.out.print ("Usage: ");
System.out.print (AseAwk.class.getName());
System.out.println (" [-m main] [-si file]? [-so file]? [-ci file]* [-co file]* [-a arg]* [-w o:n]*");
System.out.println (" -m main Specify the main function name");
System.out.println (" -si file Specify the input source file");
System.out.println (" The source code is read from stdin when it is not specified");
System.out.println (" -so file Specify the output source file");
System.out.println (" The deparsed code is not output when is it not specified");
System.out.println (" -ci file Specify the input console file");
System.out.println (" -co file Specify the output console file");
System.out.println (" -a str Specify an argument");
System.out.println (" -w o:n Specify an old and new word pair");
System.out.println (" o - an original word");
System.out.println (" n - the new word to replace the original word");
}
private static void print_error (String msg)
{
System.out.print ("Error: ");
System.out.println (msg);
}
private static String get_dll_name ()
{
URL url = AseAwk.class.getResource (
AseAwk.class.getName() + ".class");
if (url == null)
{
// probably it is compiled with gcj
// TODO: ....
String osname = System.getProperty ("os.name").toLowerCase();
String aseBase = "..";
String path;
if (osname.startsWith ("windows"))
{
path = aseBase + "\\lib\\aseawk_jni.dll";
}
else if (osname.startsWith ("mac"))
{
path = aseBase + "/lib/.libs/libaseawk_jni.dylib";
}
else
{
path = aseBase + "/lib/.libs/libaseawk_jni.so";
}
return path;
}
else
{
java.io.File file = new java.io.File (url.getFile());
String osname = System.getProperty ("os.name").toLowerCase();
String aseBase = file.getParentFile().getParentFile().getParent();
String path;
if (osname.startsWith ("windows"))
{
path = aseBase + "\\lib\\aseawk_jni.dll";
return path.substring(6);
}
else if (osname.startsWith ("mac"))
{
path = aseBase + "/lib/.libs/libaseawk_jni.dylib";
return path.substring(5);
}
else
{
path = aseBase + "/lib/.libs/libaseawk_jni.so";
return path.substring(5);
}
}
}
private static void run_in_console (String[] args)
{
AseAwk awk = null;
String dll = get_dll_name();
try
{
System.load (dll);
}
catch (java.lang.UnsatisfiedLinkError e)
{
print_error ("cannot load the library - " + dll);
return;
}
try
{
awk = new AseAwk ();
awk.setMaxDepth (AseAwk.DEPTH_BLOCK_PARSE, 30);
awk.setDebug (true);
//awk.setDebug (false);
}
catch (ase.awk.Exception e)
{
print_error ("ase.awk.Exception - " + e.getMessage());
}
int mode = 0;
String mainfn = null;
String srcin = null;
String srcout = null;
int nsrcins = 0;
int nsrcouts = 0;
//ArrayList<String> params = new ArrayList<String> ();
ArrayList params = new ArrayList ();
//for (String arg: args)
for (int i = 0; i < args.length; i++)
{
String arg = args[i];
if (mode == 0)
{
if (arg.equals("-si")) mode = 1;
else if (arg.equals("-so")) mode = 2;
else if (arg.equals("-ci")) mode = 3;
else if (arg.equals("-co")) mode = 4;
else if (arg.equals("-a")) mode = 5;
else if (arg.equals("-m")) mode = 6;
else if (arg.equals("-w")) mode = 7;
else
{
print_usage ();
return;
}
}
else
{
if (arg.length() >= 1 && arg.charAt(0) == '-')
{
print_usage ();
return;
}
if (mode == 1) // source input
{
if (nsrcins != 0)
{
print_usage ();
return;
}
srcin = arg;
nsrcins++;
mode = 0;
}
else if (mode == 2) // source output
{
if (nsrcouts != 0)
{
print_usage ();
return;
}
srcout = arg;
nsrcouts++;
mode = 0;
}
else if (mode == 3) // console input
{
awk.addConsoleInput (arg);
mode = 0;
}
else if (mode == 4) // console output
{
awk.addConsoleOutput (arg);
mode = 0;
}
else if (mode == 5) // argument mode
{
params.add (arg);
mode = 0;
}
else if (mode == 6)
{
if (mainfn != null)
{
print_usage ();
return;
}
mainfn = arg;
mode = 0;
}
else if (mode == 7)
{
int idx = arg.indexOf(':');
if (idx == -1)
{
print_usage ();
return;
}
String ow = arg.substring (0, idx);
String nw = arg.substring (idx+1);
try { awk.setWord (ow, nw); }
catch (Exception e) {/* don't care */}
mode = 0;
}
}
}
if (mode != 0)
{
print_usage ();
return;
}
try
{
awk.parse (srcin, srcout);
//awk.run (mainfn, params.toArray(new String[0]));
awk.run (mainfn, (String[])params.toArray(new String[0]));
}
catch (ase.awk.Exception e)
{
if (e.getLine() == 0)
{
print_error ("ase.awk.Exception - " + e.getMessage());
}
else
{
print_error (
"ase.awk.Exception at line " +
e.getLine() + " - " + e.getMessage());
}
}
finally
{
if (awk != null)
{
awk.close ();
awk = null;
}
}
}
public static void main (String[] args)
{
if (args.length == 0)
{
run_in_awt ();
}
else
{
run_in_console (args);
}
}
private Reader srcReader;
private Writer srcWriter;
private String srcInName;
private String srcOutName;
private LinkedList conInNames;
private LinkedList conOutNames;
private Iterator conInIter;
private Iterator conOutIter;
public AseAwk () throws ase.awk.Exception
{
super ();
srcReader = null;
srcWriter = null;
srcInName = null;
srcOutName = null;
conInNames = new LinkedList ();
conOutNames = new LinkedList ();
addFunction ("sleep", 1, 1);
}
public void sleep (Context ctx, String name, Return ret, Argument[] args) throws ase.awk.Exception
{
try { Thread.sleep (args[0].getIntValue() * 1000); }
catch (InterruptedException e) {}
ret.setIntValue (0);
}
public void parse () throws ase.awk.Exception
{
srcInName = null;
srcOutName = null;
super.parse ();
}
public void parse (String inName) throws ase.awk.Exception
{
srcInName = inName;
srcOutName = null;
super.parse ();
}
public void parse (String inName, String outName) throws ase.awk.Exception
{
srcInName = inName;
srcOutName = outName;
super.parse ();
}
public void run (String main, String[] args) throws ase.awk.Exception
{
conInIter = conInNames.iterator();
conOutIter = conOutNames.iterator();
super.run (main, args);
}
public void addConsoleInput (String name)
{
conInNames.addLast (name);
}
public void addConsoleOutput (String name)
{
conOutNames.addLast (name);
}
protected int openSource (int mode)
{
if (mode == SOURCE_READ)
{
Reader isr;
if (srcInName == null || srcInName.length() == 0)
{
isr = stdin;
}
else
{
FileInputStream fis;
try { fis = new FileInputStream (srcInName); }
catch (IOException e) { return -1; }
isr = new BufferedReader(new InputStreamReader (fis));
}
if (isr == null) return -1;
srcReader = isr;
return 1;
}
else if (mode == SOURCE_WRITE)
{
Writer osw;
if (srcOutName == null)
{
return 0;
}
else if (srcOutName.length() == 0)
{
osw = stdout;
}
else
{
FileOutputStream fos;
try { fos = new FileOutputStream (srcOutName); }
catch (IOException e) { return -1; }
osw = new BufferedWriter(new OutputStreamWriter (fos));
}
srcWriter = osw;
return 1;
}
return -1;
}
protected int closeSource (int mode)
{
if (mode == SOURCE_READ)
{
if (srcReader != null)
{
if (srcReader == stdin)
{
srcReader = null;
}
else
{
try
{
srcReader.close ();
srcReader = null;
}
catch (IOException e) { return -1; }
}
}
return 0;
}
else if (mode == SOURCE_WRITE)
{
if (srcWriter != null)
{
if (srcWriter == stdout)
{
try
{
srcWriter.flush ();
srcWriter = null;
}
catch (IOException e) { return -1; }
}
else
{
try
{
srcWriter.close ();
srcWriter = null;
}
catch (IOException e) { return -1; }
}
}
return 0;
}
return -1;
}
protected int readSource (char[] buf, int len)
{
try
{
int n = srcReader.read (buf, 0, len);
if (n == -1) n = 0;
return n;
}
catch (IOException e)
{
return -1;
}
}
protected int writeSource (char[] buf, int len)
{
if (srcWriter == null) return len;
try { srcWriter.write (buf, 0, len); }
catch (IOException e) { return -1; }
return len;
}
protected int openConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
Reader rd;
if (!conInIter.hasNext()) rd = stdin;
else
{
FileInputStream fis;
String fn = (String)conInIter.next();
try
{
fis = new FileInputStream (fn);
rd = new BufferedReader(
new InputStreamReader (fis));
}
catch (IOException e) { return -1; }
try { con.setFileName (fn); }
catch (ase.awk.Exception e)
{
try { rd.close(); }
catch (IOException e2) {}
return -1;
}
}
con.setHandle (rd);
return 1;
}
else if (mode == Console.MODE_WRITE)
{
Writer wr;
if (!conOutIter.hasNext()) wr = stdout;
else
{
FileOutputStream fos;
String fn = (String)conOutIter.next();
try
{
fos = new FileOutputStream (fn);
wr = new BufferedWriter(
new OutputStreamWriter (fos));
}
catch (IOException e) { return -1; }
try { con.setFileName (fn); }
catch (ase.awk.Exception e)
{
try { wr.close(); }
catch (IOException e2) {}
return -1;
}
}
con.setHandle (wr);
return 1;
}
return -1;
}
protected int closeConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
Reader rd = (Reader)con.getHandle();
if (rd != null && rd != stdin)
{
try { rd.close (); }
catch (IOException e) { return -1; }
}
return 0;
}
else if (mode == Console.MODE_WRITE)
{
Writer wr = (Writer)con.getHandle();
if (wr != null)
{
try
{
wr.flush ();
if (wr != stdout) wr.close ();
}
catch (IOException e) { return -1; }
}
return 0;
}
return -1;
}
protected int readConsole (Console con, char[] buf, int len)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
Reader rd = (Reader)con.getHandle();
try
{
int n = rd.read (buf, 0, len);
if (n == -1) n = 0;
return n;
}
catch (IOException e) { return -1; }
}
return -1;
}
protected int writeConsole (Console con, char[] buf, int len)
{
int mode = con.getMode ();
if (mode == Console.MODE_WRITE)
{
Writer wr = (Writer)con.getHandle();
try
{
wr.write (buf, 0, len);
wr.flush ();
}
catch (IOException e) { return -1; }
return len;
}
return -1;
}
protected int flushConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_WRITE)
{
Writer wr = (Writer)con.getHandle();
try { wr.flush (); }
catch (IOException e) { return -1; }
return 0;
}
return -1;
}
protected int nextConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
if (!conInIter.hasNext()) return 0;
String fn = (String)conInIter.next();
Reader rd;
FileInputStream fis;
try
{
fis = new FileInputStream (fn);
rd = new BufferedReader(
new InputStreamReader (fis));
}
catch (IOException e) { return -1; }
try { con.setFileName (fn); }
catch (ase.awk.Exception e)
{
try { rd.close(); }
catch (IOException e2) {}
return -1;
}
Reader tmp = (Reader)con.getHandle();
if (tmp != stdin)
{
try { tmp.close (); }
catch (IOException e)
{
try { rd.close (); }
catch (IOException e2) {}
return -1;
}
}
con.setHandle (rd);
return 1;
}
else if (mode == Console.MODE_WRITE)
{
if (!conOutIter.hasNext()) return 0;
String fn = (String)conOutIter.next();
Writer wr;
FileOutputStream fos;
try
{
fos = new FileOutputStream (fn);
wr = new BufferedWriter(
new OutputStreamWriter (fos));
}
catch (IOException e) { return -1; }
try { con.setFileName (fn); }
catch (ase.awk.Exception e)
{
try { wr.close(); }
catch (IOException e2) {}
return -1;
}
Writer tmp = (Writer)con.getHandle();
if (tmp != stdout)
{
try { tmp.close (); }
catch (IOException e)
{
try { wr.close (); }
catch (IOException e2) {}
return -1;
}
}
con.setHandle (wr);
return 1;
}
return -1;
}
}

View File

@ -1,91 +0,0 @@
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=UTF-8">
<title>Online AWK Interpreter</title>
<style>
body { font-family: georgia, tahoma, arial, sans-serif; }
p { font-size: 13px; }
h2 { font-size: 24px; font-style: italic; }
</style>
<script language='javascript'>
function resize()
{
var width, height;
if (navigator.appName.indexOf("Microsoft") == -1)
{
width = window.innerWidth;
height = window.innerHeight;
}
else
{
width = document.body.clientWidth;
height = document.body.clientHeight;
}
document.AseAwkApplet.width = width - 250;
document.AseAwkApplet.height = height - 80;
window.scroll (0, 0);
}
function load_sample1()
{
document.AseAwkApplet.clear ();
document.AseAwkApplet.setSourceInput (
'# wordfreq.awk --- print list of word frequencies\n' +
'{\n' +
' $0 = tolower($0); # remove case distinctions\n' +
'\n' +
' # remove punctuation\n' +
' gsub(/[^[:alnum:]_[:blank:]]/, " ");\n' +
'\n' +
' for (i = 1; i <= NF; i++) freq[$i]++;\n' +
'}\n' +
'\n' +
'END {\n' +
' for (word in freq)\n' +
' print word, freq[word];\n' +
'}\n');
document.AseAwkApplet.setConsoleInput (
'ASE aims to produce a script engine framework to ease the burden of creating a proprietary scripting language.\n' +
'It allows a hosting application to access various aspects of the embedded script engine and vice versa.');
}
</script>
</head>
<body onLoad="resize()" onResize="resize()">
<h2>Online AWK Interpreter</h2>
<table cellspacing=3>
<tr>
<td valign=top>
<script src='AseAwkApplet.js'></script>
</td>
<td valign=top>
<p>
Applet ini untuk menguji binding JNI yang Interpreternya <a href='http://kldp.net/projects/ase/'>ASE</a> AWK. Bahasa AWK ini agak berbeda dengan yang standar, yang setiap perintah diakhri dengan tanda semikolon. You can enter a valid AWK program into the source input window and click on the <b>Run Awk</b> button while entering arbitrary text into the console input window if needed. You may click <a href='#' onClick='load_sample1(); return true;'>here</a> to load a sample program instead.
</p>
<p>
<b>Note</b>: This java applet has been signed with a self-signed certificate. If you allow the applet to run, it will download a JNI file into your home directory. Currently, it supports Linux(i386) and Microsoft Windows(x86). If you decide to clean your system later, don't forget to delete the local JNI file downloaded.
</p>
<p>
Copyright (c) 2006-2007, Hyung-Hwan Chung. All rights reserved.
</p>
</td>
</tr>
</table>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3036869-1";
urchinTracker();
</script>
</body>
</html>

View File

@ -1,84 +0,0 @@
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=UTF-8">
<title>온라인 AWK 인터프리터</title>
<style>
body { font-family: georgia, tahoma, arial, sans-serif; }
p { font-size: 13px; }
h2 { font-size: 24px; font-style: italic; }
</style>
<script language='javascript'>
function resize()
{
var width, height;
if (navigator.appName.indexOf("Microsoft") == -1)
{
width = window.innerWidth;
height = window.innerHeight;
}
else
{
width = document.body.clientWidth;
height = document.body.clientHeight;
}
document.AseAwkApplet.width = width - 250;
document.AseAwkApplet.height = height - 80;
window.scroll (0, 0);
}
function load_sample1()
{
document.AseAwkApplet.clear ();
document.AseAwkApplet.setSourceInput (
'# wordfreq.awk --- print list of word frequencies\n' +
'{\n' +
' $0 = tolower($0); # remove case distinctions\n' +
'\n' +
' # remove punctuation\n' +
' gsub(/[^[:alnum:]_[:blank:]]/, " ");\n' +
'\n' +
' for (i = 1; i <= NF; i++) freq[$i]++;\n' +
'}\n' +
'\n' +
'END {\n' +
' for (word in freq)\n' +
' print word, freq[word];\n' +
'}\n');
document.AseAwkApplet.setConsoleInput (
'ASE는 응용프로그램에 스크립팅언어을 쉽게 내장할 수 있도록 하는 스크립팅엔진 프레임웍크 제작을 목표로 한다.\n' +
'호스팅 프로그램에서 엔진을 제어할 수 있을 뿐만 아니라, 반대로 엔진에서도 호스팅 프로그램을 접근 할 수 있다.\n');
}
</script>
</head>
<body onLoad="resize()" onResize="resize()">
<h2>온라인 AWK 인터프리터</h2>
<table cellspacing=3>
<tr>
<td valign=top>
<script src='AseAwkApplet.js'></script>
</td>
<td valign=top>
<p>
이 애플릿은 <a href='http://kldp.net/projects/ase/'>ASE</a> AWK 인터프리터의 JNI바인딩을 시험하는 프로그램이다. 지원되는 AWK언어는 표준과 약간의 차이가 있는데, 대표적으로 모든 문장은 세미콜론으로 끝을 내야 한다. 소스창에 AWK 프로그램을 입력하고 <b>Run Awk</b>버튼을 누르면 된다. 예제프로그램을 올리고 싶으면 <a href='#' onClick='load_sample1()'>여기</a>를 눌러라.
</p>
<p>
<b>주의</b>: 이 애플릿은 자기서명인증서로 서명이 되었다. 애플릿 실행을 허가하면 사용자의 홈 디렉토리로 JNI파일을 다운로드 한다. 현재는 Linux(i386)와 Microsoft Windows(x86)만 지원을 한다. 불필요한 파일들을 청소하고 싶다면, 다운로드된 JNI파일도 삭제하기 바란다.
</p>
<p>
Copyright (c) 2006-2007, Hyung-Hwan Chung. All rights reserved.
</p>
</td>
</tr>
</table>
</body>
</html>

View File

@ -1,85 +0,0 @@
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=UTF-8">
<title>Online AWK Interpreter</title>
<style>
body { font-family: tahoma, arial, sans-serif; }
p { font-size: 13px; }
h2 { font-size: 24px; font-style: italic; }
</style>
<script language='javascript'>
function resize()
{
var width, height;
if (navigator.appName.indexOf("Microsoft") == -1)
{
width = window.innerWidth;
height = window.innerHeight;
}
else
{
width = document.body.clientWidth;
height = document.body.clientHeight;
}
document.AseAwkApplet.width = width - 250;
document.AseAwkApplet.height = height - 80;
window.scroll (0, 0);
}
function load_sample1()
{
document.AseAwkApplet.clear ();
document.AseAwkApplet.setSourceInput (
'# wordfreq.awk --- print list of word frequencies\n' +
'{\n' +
' $0 = tolower($0); # remove case distinctions\n' +
'\n' +
' # remove punctuation\n' +
' gsub(/[^[:alnum:]_[:blank:]]/, " ");\n' +
'\n' +
' for (i = 1; i <= NF; i++) freq[$i]++;\n' +
'}\n' +
'\n' +
'END {\n' +
' for (word in freq)\n' +
' print word, freq[word];\n' +
'}\n');
document.AseAwkApplet.setConsoleInput (
'ASE aims to produce a script engine framework to ease the burden of creating a proprietary scripting language.\n' +
'It allows a hosting application to access various aspects of the embedded script engine and vice versa.');
}
</script>
</head>
<body onLoad="resize()" onResize="resize()">
<h2>Online AWK Interpreter</h2>
<table cellspacing=3>
<tr>
<td valign=top>
<script src='AseAwkApplet.js'></script>
</td>
<td valign=top>
<p>
This applet is a test program for JNI binding to the <a href='http://kldp.net/projects/ase/'>ASE</a> AWK interpreter. The AWK language supported is slightly different from the standard in that all statements must end with a semicolon. You may enter a valid AWK program into the source input window and click on the <b>Run Awk</b> button. You can enter arbitrary text into the console input window if the AWK program entered contains an action-pattern block. You may click <a href='#' onClick='load_sample1(); return true;'>here</a> to load a sample program instead.
</p>
<p>
<b>Note</b>: This java applet has been signed with a self-signed certificate. If you allow the applet to run, it will download a JNI file into your home directory. Currently, it supports Linux(i386) and Microsoft Windows(x86). If you decide to clean your system later, don't forget to delete the local JNI file downloaded.
</p>
<p>
Copyright (c) 2006-2007, Hyung-Hwan Chung. All rights reserved.
</p>
</td>
</tr>
</table>
</body>
</html>

View File

@ -1,38 +0,0 @@
/*
* $Id: AseAwkApplet.java,v 1.1 2007/04/30 08:32:41 bacon Exp $
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AseAwkApplet extends Applet
{
AseAwkPanel awkPanel;
public void init ()
{
awkPanel = new AseAwkPanel ();
setLayout (new BorderLayout ());
add (awkPanel, BorderLayout.CENTER);
}
public void stop () {}
public void paint (Graphics g) {}
public void setConsoleInput (String str)
{
awkPanel.setConsoleInput (str);
}
public void setSourceInput (String str)
{
awkPanel.setSourceInput (str);
}
public void clear ()
{
awkPanel.clear ();
}
}

View File

@ -1,5 +0,0 @@
<!--
document.write ('<applet name="AseAwkApplet" code="AseAwkApplet" archive="bin/aseawk.jar" codebase="." width="700" height="550">');
document.write ('</applet>');
-->

View File

@ -1,976 +0,0 @@
/*
* $Id: AseAwkPanel.java,v 1.32 2007/11/12 07:21:52 bacon Exp $
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.net.URL;
import java.net.URLConnection;
import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.security.MessageDigest;
import java.util.List;
import java.util.Iterator;
import ase.awk.StdAwk;
import ase.awk.Console;
import ase.awk.Context;
import ase.awk.Argument;
import ase.awk.Return;
public class AseAwkPanel extends Panel implements DropTargetListener
{
/* MsgBox taken from http://www.rgagnon.com/javadetails/java-0242.html */
class MsgBox extends Dialog implements ActionListener
{
boolean id = false;
Button ok,can;
MsgBox (Frame frame, String msg, boolean okcan)
{
super (frame, "Message", true);
setLayout(new BorderLayout());
add("Center",new Label(msg));
addOKCancelPanel(okcan);
createFrame();
pack();
setVisible(true);
}
void addOKCancelPanel( boolean okcan )
{
Panel p = new Panel();
p.setLayout(new FlowLayout());
createOKButton( p );
if (okcan == true) createCancelButton( p );
add("South",p);
}
void createOKButton(Panel p)
{
p.add(ok = new Button("OK"));
ok.addActionListener(this);
}
void createCancelButton(Panel p)
{
p.add(can = new Button("Cancel"));
can.addActionListener(this);
}
void createFrame()
{
Dimension d = getToolkit().getScreenSize();
setLocation(d.width/3,d.height/3);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == ok)
{
id = true;
setVisible(false);
}
else if(ae.getSource() == can)
{
setVisible(false);
}
}
}
public class Awk extends StdAwk
{
private AseAwkPanel awkPanel;
private StringReader srcIn;
private StringWriter srcOut;
public Awk (AseAwkPanel awkPanel) throws Exception
{
super ();
this.awkPanel = awkPanel;
addFunction ("sleep", 1, 1);
/*
setWord ("sin", "cain");
setWord ("length", "len");
setWord ("OFMT", "ofmt");
setWord ("END", "end");
setWord ("sleep", "cleep");
setWord ("end", "END");
*/
}
public void sleep (Context ctx, String name, Return ret, Argument[] args) throws ase.awk.Exception
{
Argument t = args[0];
//if (args[0].isIndexed()) t = args[0].getIndexed(0);
try { Thread.sleep (t.getIntValue() * 1000); }
catch (InterruptedException e) {}
ret.setIntValue (0);
/*
ret.setIndexedRealValue (1, 111.23);
ret.setIndexedStringValue (2, "1111111");
ret.setIndexedStringValue (3, "22222222");
ret.setIndexedIntValue (4, 444);
ret.setIndexedIntValue (5, 55555);
Return r = new Return (ctx);
r.setStringValue ("[[%.6f]]");
Return r2 = new Return (ctx);
r2.setStringValue ("[[%.6f]]");
//ctx.setGlobal (Context.GLOBAL_CONVFMT, ret);
Argument g = ctx.getGlobal (Context.GLOBAL_CONVFMT);
ctx.setGlobal (Context.GLOBAL_CONVFMT, r2);
System.out.println (g.getStringValue());
g = ctx.getGlobal (Context.GLOBAL_CONVFMT);
System.out.println (g.getStringValue());
*/
}
protected int openSource (int mode)
{
if (mode == SOURCE_READ)
{
srcIn = new StringReader (awkPanel.getSourceInput());
return 1;
}
else if (mode == SOURCE_WRITE)
{
srcOut = new StringWriter ();
return 1;
}
return -1;
}
protected int closeSource (int mode)
{
if (mode == SOURCE_READ)
{
srcIn.close ();
return 0;
}
else if (mode == SOURCE_WRITE)
{
awkPanel.setSourceOutput (srcOut.toString());
try { srcOut.close (); }
catch (IOException e) { return -1; }
return 0;
}
return -1;
}
protected int readSource (char[] buf, int len)
{
try
{
int n = srcIn.read (buf, 0, len);
if (n == -1) n = 0;
return n;
}
catch (IOException e) { return -1; }
}
protected int writeSource (char[] buf, int len)
{
srcOut.write (buf, 0, len);
return len;
}
protected int openConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
con.setHandle (new StringReader (awkPanel.getConsoleInput()));
return 1;
}
else if (mode == Console.MODE_WRITE)
{
con.setHandle (new StringWriter ());
return 1;
}
return -1;
}
protected int closeConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
Reader rd = (Reader)con.getHandle();
try { rd.close (); }
catch (IOException e) { return -1; }
return 0;
}
else if (mode == Console.MODE_WRITE)
{
Writer wr = (Writer)con.getHandle();
awkPanel.setConsoleOutput (wr.toString());
try { wr.close (); }
catch (IOException e) { return -1; }
return 0;
}
return -1;
}
protected int readConsole (Console con, char[] buf, int len)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
Reader rd = (Reader)con.getHandle();
try
{
int n = rd.read (buf, 0, len);
if (n == -1) n = 0;
return n;
}
catch (IOException e) { return -1; }
}
return -1;
}
protected int writeConsole (Console con, char[] buf, int len)
{
int mode = con.getMode ();
if (mode == Console.MODE_WRITE)
{
Writer wr = (Writer)con.getHandle();
try { wr.write (buf, 0, len); }
catch (IOException e) { return -1; }
return len;
}
return -1;
}
protected int flushConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_WRITE)
{
return 0;
}
return -1;
}
protected int nextConsole (Console con)
{
int mode = con.getMode ();
if (mode == Console.MODE_READ)
{
return 0;
}
else if (mode == Console.MODE_WRITE)
{
return 0;
}
return -1;
}
}
private TextArea srcIn;
private TextArea srcOut;
private TextArea conIn;
private TextArea conOut;
private TextField entryPoint;
private TextField jniLib;
private Label statusLabel;
private DropTarget srcInDropTarget;
private DropTarget conInDropTarget;
private boolean jniLibLoaded = false;
private class Option
{
private String name;
private int value;
private boolean state;
public Option (String name, int value, boolean state)
{
this.name = name;
this.value = value;
this.state = state;
}
public String getName()
{
return this.name;
}
public int getValue()
{
return this.value;
}
public boolean getState()
{
return this.state;
}
public void setState (boolean state)
{
this.state = state;
}
}
protected Option[] options = new Option[]
{
new Option("IMPLICIT", StdAwk.OPTION_IMPLICIT, true),
new Option("EXPLICIT", StdAwk.OPTION_EXPLICIT, false),
new Option("SHIFT", StdAwk.OPTION_SHIFT, false),
new Option("IDIV", StdAwk.OPTION_IDIV, false),
new Option("STRCONCAT", StdAwk.OPTION_STRCONCAT, false),
new Option("EXTIO", StdAwk.OPTION_EXTIO, true),
new Option("BLOCKLESS", StdAwk.OPTION_BLOCKLESS, true),
new Option("BASEONE", StdAwk.OPTION_BASEONE, true),
new Option("STRIPSPACES", StdAwk.OPTION_STRIPSPACES, false),
new Option("NEXTOFILE", StdAwk.OPTION_NEXTOFILE, false),
//new Option("CRLF", StdAwk.OPTION_CRLF, false),
new Option("ARGSTOMAIN", StdAwk.OPTION_ARGSTOMAIN, false),
new Option("RESET", StdAwk.OPTION_RESET, false),
new Option("MAPTOVAR", StdAwk.OPTION_MAPTOVAR, false),
new Option("PABLOCK", StdAwk.OPTION_PABLOCK, true)
};
public AseAwkPanel ()
{
prepareUserInterface ();
prepareNativeInterface ();
}
private void prepareUserInterface ()
{
jniLib = new TextField ();
String osname = System.getProperty ("os.name").toLowerCase();
int fontSize = (osname.startsWith("windows"))? 14: 12;
Font font = new Font ("Monospaced", Font.PLAIN, fontSize);
srcIn = new TextArea ();
srcOut = new TextArea ();
conIn = new TextArea ();
conOut = new TextArea ();
srcIn.setFont (font);
srcOut.setFont (font);
conIn.setFont (font);
conOut.setFont (font);
Panel srcInPanel = new Panel();
srcInPanel.setLayout (new BorderLayout());
srcInPanel.add (new Label("Source Input"), BorderLayout.NORTH);
srcInPanel.add (srcIn, BorderLayout.CENTER);
Panel srcOutPanel = new Panel();
srcOutPanel.setLayout (new BorderLayout());
srcOutPanel.add (new Label("Source Output"), BorderLayout.NORTH);
srcOutPanel.add (srcOut, BorderLayout.CENTER);
Panel conInPanel = new Panel();
conInPanel.setLayout (new BorderLayout());
conInPanel.add (new Label("Console Input"), BorderLayout.NORTH);
conInPanel.add (conIn, BorderLayout.CENTER);
Panel conOutPanel = new Panel();
conOutPanel.setLayout (new BorderLayout());
conOutPanel.add (new Label("Console Output"), BorderLayout.NORTH);
conOutPanel.add (conOut, BorderLayout.CENTER);
Button runBtn = new Button ("Run Awk");
runBtn.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
runAwk ();
}
});
entryPoint = new TextField();
Panel entryPanel = new Panel();
entryPanel.setLayout (new BorderLayout());
entryPanel.add (new Label("Main:"), BorderLayout.WEST);
entryPanel.add (entryPoint, BorderLayout.CENTER);
Panel leftPanel = new Panel();
leftPanel.setLayout (new BorderLayout());
leftPanel.add (runBtn, BorderLayout.SOUTH);
Panel optPanel = new Panel();
optPanel.setBackground (Color.YELLOW);
optPanel.setLayout (new GridLayout(options.length, 1));
for (int i = 0; i < options.length; i++)
{
Checkbox cb = new Checkbox(options[i].getName(), options[i].getState());
cb.addItemListener (new ItemListener ()
{
public void itemStateChanged (ItemEvent e)
{
Object x = e.getItem();
String name;
if (x instanceof Checkbox)
{
// gcj
name = ((Checkbox)x).getLabel();
}
else if (x instanceof String)
{
// standard jdk
name = (String)x;
}
else name = x.toString();
for (int i = 0; i < options.length; i++)
{
if (options[i].getName().equals(name))
{
options[i].setState (e.getStateChange() == ItemEvent.SELECTED);
}
}
}
});
optPanel.add (cb);
}
leftPanel.add (entryPanel, BorderLayout.NORTH);
leftPanel.add (optPanel, BorderLayout.CENTER);
Panel topPanel = new Panel ();
BorderLayout topPanelLayout = new BorderLayout ();
topPanel.setLayout (topPanelLayout);
topPanelLayout.setHgap (2);
topPanelLayout.setVgap (2);
topPanel.add (new Label ("JNI Library: "), BorderLayout.WEST);
topPanel.add (jniLib, BorderLayout.CENTER);
Panel centerPanel = new Panel ();
GridLayout centerPanelLayout = new GridLayout (2, 2);
centerPanel.setLayout (centerPanelLayout);
centerPanelLayout.setHgap (2);
centerPanelLayout.setVgap (2);
centerPanel.add (srcInPanel);
centerPanel.add (srcOutPanel);
centerPanel.add (conInPanel);
centerPanel.add (conOutPanel);
BorderLayout mainLayout = new BorderLayout ();
mainLayout.setHgap (2);
mainLayout.setVgap (2);
setLayout (mainLayout);
statusLabel = new Label ("Ready - " + System.getProperty("user.dir"));
statusLabel.setBackground (Color.GREEN);
add (topPanel, BorderLayout.NORTH);
add (centerPanel, BorderLayout.CENTER);
add (leftPanel, BorderLayout.WEST);
add (statusLabel, BorderLayout.SOUTH);
srcInDropTarget = new DropTarget (srcIn, this);
conInDropTarget = new DropTarget (conIn, this);
}
public void prepareNativeInterface ()
{
String libBase = "aseawk_jni";
String osname = System.getProperty ("os.name").toLowerCase();
String osarch = System.getProperty("os.arch").toLowerCase();
String userHome = System.getProperty("user.home");
if (osname.startsWith("windows")) osname = "win";
else if (osname.startsWith("linux")) osname = "linux";
else if (osname.startsWith("mac")) osname = "mac";
URL url = this.getClass().getResource (
this.getClass().getName() + ".class");
if (url == null)
{
if (osname.equals("win"))
{
jniLib.setText(System.getProperty("user.dir") +
"\\.\\lib\\" + System.mapLibraryName(libBase));
}
else
{
jniLib.setText(System.getProperty("user.dir") +
"/../lib/.libs/" + System.mapLibraryName(libBase));
}
return;
}
String protocol = url.getProtocol ();
boolean isHttp = url.getPath().startsWith ("http://");
File file = new File (isHttp? url.getPath():url.getFile());
String base = protocol.equals("jar")?
file.getParentFile().getParentFile().getParent():
file.getParentFile().getParent();
/*if (isHttp)*/ base = java.net.URLDecoder.decode (base);
if (isHttp) libBase = libBase + "-" + osname + "-" + osarch;
String libName = System.mapLibraryName(libBase);
if (osname.equals("win"))
{
String jniLocal;
if (isHttp)
{
base = "http://" + base.substring(6).replace('\\', '/');
String jniUrl = base + "/lib/" + libName;
String md5Url = jniUrl + ".md5";
jniLocal = userHome + "\\" + libName;
try
{
downloadNative (md5Url, jniUrl, jniLocal);
}
catch (Exception e)
{
showMessage ("Cannot download native library - " + e.getMessage());
jniLocal = "ERROR - Not Available";
}
}
else
{
jniLocal = base + "\\lib\\" + libName;
if (protocol.equals("jar")) jniLocal = jniLocal.substring(6);
}
jniLib.setText (jniLocal);
}
else
{
String jniLocal;
if (isHttp)
{
base = "http://" + base.substring(6);
String jniUrl = base + "/lib/" + libName;
String md5Url = jniUrl + ".md5";
jniLocal = userHome + "/" + libName;
try
{
downloadNative (md5Url, jniUrl, jniLocal);
}
catch (Exception e)
{
showMessage ("Cannot download native library - " + e.getMessage());
jniLocal = "ERROR - Not Available";
}
}
else
{
jniLocal = base + "/lib/.libs/" + libName;
if (protocol.equals("jar")) jniLocal = jniLocal.substring(5);
}
jniLib.setText (jniLocal);
}
}
public String getSourceInput ()
{
return srcIn.getText ();
}
public void setSourceOutput (String output)
{
srcOut.setText (output);
}
public String getConsoleInput ()
{
return conIn.getText ();
}
public void setConsoleOutput (String output)
{
conOut.setText (output);
}
private void runAwk ()
{
Awk awk = null;
if (!jniLibLoaded)
{
try
{
System.load (jniLib.getText());
jniLib.setEnabled (false);
jniLibLoaded = true;
}
catch (UnsatisfiedLinkError e)
{
showMessage ("Cannot load library - " + e.getMessage());
return;
}
catch (Exception e)
{
showMessage ("Cannot load library - " + e.getMessage());
return;
}
}
srcOut.setText ("");
conOut.setText ("");
try
{
try
{
awk = new Awk (this);
}
catch (Exception e)
{
showMessage ("Cannot instantiate awk - " + e.getMessage());
return;
}
for (int i = 0; i < options.length; i++)
{
if (options[i].getState())
{
awk.setOption (awk.getOption() | options[i].getValue());
}
else
{
awk.setOption (awk.getOption() & ~options[i].getValue());
}
}
statusLabel.setText ("Parsing...");
awk.parse ();
String main = entryPoint.getText().trim();
statusLabel.setText ("Running...");
if (main.length() > 0) awk.run (main);
else awk.run ();
statusLabel.setText ("Done...");
}
catch (ase.awk.Exception e)
{
String msg;
int line = e.getLine();
int code = e.getCode();
if (line <= 0)
msg = "An exception occurred - [" + code + "] " + e.getMessage();
else
msg = "An exception occurred - [" + code + "] " + e.getMessage() + " at line " + line;
showMessage (msg);
statusLabel.setText (msg);
return;
}
finally
{
if (awk != null) awk.close ();
}
}
private void showMessage (String msg)
{
Frame tmp = new Frame ("");
MsgBox message = new MsgBox (tmp, msg, false);
requestFocus ();
message.dispose ();
tmp.dispose ();
}
private String getFileMD5 (String file) throws Exception
{
MessageDigest md = MessageDigest.getInstance("MD5");
FileInputStream fis = null;
try
{
fis = new FileInputStream (file);
int n;
byte[] b = new byte[1024];
while ((n = fis.read(b)) != -1)
{
md.update (b, 0, n);
}
}
catch (FileNotFoundException e) { return ""; }
catch (IOException e) { throw e; }
finally
{
if (fis != null)
{
try { fis.close (); }
catch (IOException e) {}
fis = null;
}
}
StringBuffer buf = new StringBuffer ();
byte[] d = md.digest ();
for (int i = 0; i < d.length; i++)
{
String x = Integer.toHexString((d[i] & 0x00FF));
if (x.length() == 1) buf.append ('0');
buf.append (x);
}
return buf.toString();
}
private void downloadNative (String md5URL, String sourceURL, String destFile) throws Exception
{
InputStream is = null;
FileOutputStream fos = null;
String sumRemote = null;
/* download the checksum file */
try
{
URL url = new URL (md5URL);
URLConnection conn = url.openConnection ();
is = url.openStream ();
int n, total = 0;
byte[] b = new byte[32];
while ((n = is.read(b, total, 32-total)) != -1)
{
total += n;
if (total >= 32)
{
sumRemote = new String (b);
break;
}
}
}
catch (IOException e) { throw e; }
finally
{
if (is != null)
{
try { is.close (); }
catch (IOException e) {}
is = null;
}
}
if (sumRemote != null)
{
/* if the checksum matches the checksum of the local file,
* the native library file doesn't have to be downloaded */
String sumLocal = getFileMD5 (destFile);
if (sumRemote.equalsIgnoreCase(sumLocal)) return;
}
/* download the actual file */
try
{
URL url = new URL(sourceURL);
URLConnection conn = url.openConnection();
is = url.openStream();
fos = new FileOutputStream(destFile);
int n;
byte[] b = new byte[1024];
while ((n = is.read(b)) != -1)
{
fos.write(b, 0, n);
}
}
catch (IOException e) { throw e; }
finally
{
if (is != null)
{
try { is.close (); }
catch (IOException e) {}
is = null;
}
if (fos != null)
{
try { fos.close (); }
catch (IOException e) {}
fos = null;
}
}
}
public void dragEnter(DropTargetDragEvent dtde) { }
public void dragExit(DropTargetEvent dte) { }
public void dragOver(DropTargetDragEvent dtde) { }
public void dropActionChanged(DropTargetDragEvent dtde) { }
public void drop (DropTargetDropEvent dtde)
{
DropTarget dropTarget = dtde.getDropTargetContext().getDropTarget();
if (dropTarget != srcInDropTarget &&
dropTarget != conInDropTarget)
{
dtde.rejectDrop ();
return;
}
Transferable tr = dtde.getTransferable ();
DataFlavor[] flavors = tr.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++)
{
//System.out.println("Possible flavor: " + flavors[i].getMimeType());
if (flavors[i].isFlavorJavaFileListType())
{
TextArea t = (TextArea)dropTarget.getComponent();
t.setText ("");
try
{
dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
List files = (List)tr.getTransferData(flavors[i]);
Iterator x = files.iterator ();
while (x.hasNext())
{
File file = (File)x.next ();
loadFileTo (file, t);
}
dtde.dropComplete (true);
return;
}
catch (UnsupportedFlavorException e)
{
dtde.rejectDrop ();
return;
}
catch (IOException e)
{
dtde.rejectDrop ();
return;
}
}
else if (flavors[i].isFlavorSerializedObjectType())
{
TextArea t = (TextArea)dropTarget.getComponent();
try
{
dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
Object o = tr.getTransferData(flavors[i]);
t.replaceText (o.toString(), t.getSelectionStart(), t.getSelectionEnd());
dtde.dropComplete(true);
return;
}
catch (UnsupportedFlavorException e)
{
dtde.rejectDrop ();
return;
}
catch (IOException e)
{
dtde.rejectDrop ();
return;
}
}
}
dtde.rejectDrop ();
}
private void loadFileTo (File file, TextArea textArea) throws IOException
{
FileReader fr = null;
StringBuffer fb = new StringBuffer(textArea.getText());
try
{
fr = new FileReader (file);
int n;
char[] b = new char[1024];
while ((n = fr.read (b)) != -1) fb.append (b, 0, n);
}
catch (IOException e) { throw e; }
finally
{
if (fr != null)
{
try { fr.close (); }
catch (IOException e) {}
fr = null;
}
}
textArea.setText (fb.toString());
}
void clear ()
{
conIn.setText ("");
srcIn.setText ("");
conOut.setText ("");
srcOut.setText ("");
}
void setConsoleInput (String str)
{
conIn.setText (str);
}
void setSourceInput (String str)
{
srcIn.setText (str);
}
}

View File

@ -3,6 +3,7 @@
#
TOP_DIR = @abs_top_builddir@
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@ -I$(TOP_DIR)/inc
@ -10,20 +11,10 @@ CXXFLAGS = @CXXFLAGS@ -I$(TOP_DIR)/inc
LDFLAGS = @LDFLAGS@ -L$(TOP_DIR)/out/@BUILDMODE@/lib
LIBS = @LIBS@ -laseawk -lasecmn -laseutl -lm
LIBS_CXX = -laseawk++ ${LIBS}
LIBS_CJ = -laseawkja
MODE = @BUILDMODE@
STRIP = @STRIP@
CJ = @CJ@
CJFLAGS = @CJFLAGS@ --classpath=$(TOP_DIR)/..:. -fjni
BUILD_CJ = @BUILD_CJ@
JAVAC = @JAVAC@
JAR = @JAR@
CFLAGS_JNI = @CFLAGS_JNI@
BUILD_JNI = @BUILD_JNI@
AR = ar
OUT_DIR= $(TOP_DIR)/out/$(MODE)
@ -33,16 +24,10 @@ TMP_DIR = $(MODE)
ASEAWK_LIB =
all: build$(BUILD_JNI)$(BUILD_CJ)
all: build
build: $(TMP_DIR) $(OUT_DIR_BIN) $(OUT_DIR_BIN)/aseawk $(OUT_DIR_BIN)/aseawk++
buildjnicj: buildjni buildcj
buildjni: build $(OUT_DIR_BIN)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html $(OUT_DIR)/AseAwkApplet.js
buildcj: build $(OUT_DIR_BIN)/aseawkja
$(OUT_DIR_BIN)/aseawk: awk.c
$(CC) $(CFLAGS) -o $@ awk.c $(LDFLAGS) $(LIBS)
$(STRIP) $@
@ -51,38 +36,6 @@ $(OUT_DIR_BIN)/aseawk++: Awk.cpp
$(CXX) $(CXXFLAGS) -o $@ Awk.cpp $(LDFLAGS) $(LIBS_CXX)
$(STRIP) $@
$(OUT_DIR_BIN)/aseawkja: $(TMP_DIR)/cj AseAwk.java AseAwkPanel.java AseAwkApplet.java
$(CJ) $(CJFLAGS) -o $(TMP_DIR)/cj/AseAwk.o -c AseAwk.java
$(CJ) $(CJFLAGS) -o $(TMP_DIR)/cj/AseAwkPanel.o -c AseAwkPanel.java
$(CJ) $(CJFLAGS) -o $(TMP_DIR)/cj/AseAwkApplet.o -c AseAwkApplet.java
mkdir -p $(TMP_DIR)/cj/lib
cd $(TMP_DIR)/cj/lib; $(AR) xv @abs_top_builddir@/@BUILDMODE@/lib/libaseawkja.a
$(CJ) --main=AseAwk -o $@ $(TMP_DIR)/cj/*.o $(TMP_DIR)/cj/lib/*.o
rm -rf $(TMP_DIR)/cj/lib
# Linking with the library seems to cause the resulting program
# to crash for some JNI operations. Correct me if I'm wrong.
#$(CJ) --main=AseAwk -o $@ $(TMP_DIR)/cj/*.o $(LDFLAGS) $(LIBS_CJ)
$(OUT_DIR_BIN)/aseawk.jar: $(TMP_DIR)/AseAwkPanel.class $(TMP_DIR)/AseAwk.class $(TMP_DIR)/AseAwkApplet.class
cd $(TMP_DIR); $(JAR) -xvf ../$(OUT_DIR_LIB)/aseawk.jar
cd $(TMP_DIR); $(JAR) -cvfm ../$@ ../manifest *.class ase
rm -rf $(TMP_DIR)/ase
$(TMP_DIR)/AseAwkPanel.class: AseAwkPanel.java
$(JAVAC) -classpath $(TMP_DIR):$(OUT_DIR_LIB)/aseawk.jar -d $(TMP_DIR) AseAwkPanel.java
$(TMP_DIR)/AseAwk.class: AseAwk.java
$(JAVAC) -classpath $(TMP_DIR):$(OUT_DIR_LIB)/aseawk.jar -d $(TMP_DIR) AseAwk.java
$(TMP_DIR)/AseAwkApplet.class: AseAwkApplet.java
$(JAVAC) -classpath $(TMP_DIR):$(OUT_DIR_LIB)/aseawk.jar -d $(TMP_DIR) AseAwkApplet.java
$(OUT_DIR)/AseAwkApplet.html: AseAwkApplet.html
cp -pf AseAwkApplet.html $(OUT_DIR)
$(OUT_DIR)/AseAwkApplet.js: AseAwkApplet.js
cp -pf AseAwkApplet.js $(OUT_DIR)
$(OUT_DIR_BIN):
mkdir -p $(OUT_DIR_BIN)
@ -93,6 +46,5 @@ $(TMP_DIR)/cj:
mkdir -p $(TMP_DIR)/cj
clean:
rm -rf $(OUT_DIR_BIN)/aseawk $(OUT_DIR_BIN)/aseawk++ $(OUT_DIR_BIN)/aseawkja
rm -rf $(OUT_DIR_BIN)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html $(OUT_DIR)/AseAwkApplet.js $(TMP_DIR)/*.class
rm -rf $(OUT_DIR_BIN)/aseawk $(OUT_DIR_BIN)/aseawk++