From: yeom Date: Tue, 12 Jul 2011 21:54:22 +0000 (+0000) Subject: make mp3decoder compile X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=87a76afcbc0a1d5bb71f17e70fb814ef0b82c86d;p=IRC.git make mp3decoder compile --- diff --git a/Robust/src/ClassLibrary/SSJava/ByteArrayInputStream.java b/Robust/src/ClassLibrary/SSJava/ByteArrayInputStream.java index eb05a83a..1d26f361 100644 --- a/Robust/src/ClassLibrary/SSJava/ByteArrayInputStream.java +++ b/Robust/src/ClassLibrary/SSJava/ByteArrayInputStream.java @@ -245,7 +245,7 @@ public class ByteArrayInputStream extends InputStream // ints will always fit in an int. Since we have to return a long // anyway, numBytes might as well just be a long. long numBytes = Math.min((long) (count - pos), num < 0 ? 0L : num); - pos += numBytes; + pos +=(int)numBytes; return numBytes; } } \ No newline at end of file diff --git a/Robust/src/ClassLibrary/SSJava/Character.java b/Robust/src/ClassLibrary/SSJava/Character.java new file mode 100644 index 00000000..3e412818 --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/Character.java @@ -0,0 +1,73 @@ +public class Character { + + public static int digit(char ch, int radix) { + if (ch>='0'&&ch<='9') + return ch-'0'; + else if (ch>='a'&&ch<='z') { + int val=(ch-'a')+10; + if (val='A'&&ch<='Z') { + int val=(ch-'A')+10; + if (val='0'&&ch<='9') + return true; + else + return false; + } + + char value; + + public Character(char c) { + value = c; + } + + public Character(Character c) { + value = c.value; + } + + public String toString() { + return ""+value; + } + + public static boolean isWhitespace(char character) { + boolean returnValue; + if ( (character == '\t') || + (character == '\n') || + (character == ' ') || + (character == '\u000C') || + (character == '\u001C') || + (character == '\u001D') || + (character == '\u001E') || + (character == '\u001F')) { + returnValue = true; + } else { + returnValue = false; + } + return returnValue; + } + + public static final int MIN_RADIX = 2; + public static final int MAX_RADIX = 36; + + public static char forDigit(int digit, int radix) { + if ((digit >= radix) || (digit < 0)) { + return '\0'; + } + if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) { + return '\0'; + } + if (digit < 10) { + return (char)('0' + digit); + } + return (char)('a' - 10 + digit); + } +} diff --git a/Robust/src/ClassLibrary/SSJava/IOException.java b/Robust/src/ClassLibrary/SSJava/IOException.java new file mode 100644 index 00000000..aba14444 --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/IOException.java @@ -0,0 +1,74 @@ +/* IOException.java -- Generic input/output exception + Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +//package java.io; + +/** + * This exception is thrown to indicate an I/O problem of some sort + * occurred. Since this is a fairly generic exception, often a subclass + * of IOException will actually be thrown in order to provide a more + * detailed indication of what happened. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Tom Tromey (tromey@cygnus.com) + * @status updated to 1.4 + */ +public class IOException extends Exception +{ + /** + * Compatible with JDK 1.0+. + */ + private static final long serialVersionUID = 7818375828146090155L; + + /** + * Create an exception without a descriptive error message. + */ + public IOException() + { + } + + /** + * Create an exception with a descriptive error message. + * + * @param message the descriptive error message + */ + public IOException(String message) + { + super(message); + } +} // class IOException \ No newline at end of file diff --git a/Robust/src/ClassLibrary/SSJava/Long.java b/Robust/src/ClassLibrary/SSJava/Long.java index e0e06cf5..b53033bb 100644 --- a/Robust/src/ClassLibrary/SSJava/Long.java +++ b/Robust/src/ClassLibrary/SSJava/Long.java @@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ -package java.lang; +//package java.lang; /** * Instances of class Long represent primitive diff --git a/Robust/src/ClassLibrary/SSJava/String.java b/Robust/src/ClassLibrary/SSJava/String.java index d5f98219..131b7691 100644 --- a/Robust/src/ClassLibrary/SSJava/String.java +++ b/Robust/src/ClassLibrary/SSJava/String.java @@ -1,5 +1,7 @@ import Object; import String; +import StringBuffer; +import System; @LATTICE("V(str.length-offset)) + length=str.length-offset; + char charstr[]=new char[length]; + for(int i=0; i count) || (srcBegin > srcEnd)) { + // FIXME + System.printString("Index error: "+srcBegin+" "+srcEnd+" "+count+"\n"+this); + System.exit(-1); + } + int len = srcEnd - srcBegin; + int j = dstBegin; + for(int i=srcBegin; icount || (ooffset+len)>other.count) + return false; + for(int i=0; iJavaLayerHooks class allows developers to change diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java index 9a32c5b8..13f2ac0b 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java @@ -19,14 +19,14 @@ */ -import java.io.IOException; -import java.io.InputStream; -import java.io.InvalidClassException; -import java.io.InvalidObjectException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.lang.reflect.Array; +//import java.io.IOException; +//import java.io.InputStream; +//import java.io.InvalidClassException; +//import java.io.InvalidObjectException; +//import java.io.ObjectInputStream; +//import java.io.ObjectOutputStream; +//import java.io.OutputStream; +//import java.lang.reflect.Array; /** * The JavaLayerUtils class is not strictly part of the JavaLayer API. @@ -43,17 +43,19 @@ public class JavaLayerUtils * @param in The input stream to deserialize an object from. * @param cls The expected class of the deserialized object. */ - static public Object deserialize(InputStream in, Class cls) +// static public Object deserialize(InputStream in, Class cls) + static public Object deserialize(InputStream in) throws IOException { - if (cls==null) - throw new NullPointerException("cls"); +// if (cls==null) +// throw new NullPointerException("cls"); - Object obj = deserialize(in, cls); - if (!cls.isInstance(obj)) - { - throw new InvalidObjectException("type of deserialized instance not of required class."); - } +// Object obj = deserialize(in, cls); + Object obj = deserialize(in); +// if (!cls.isInstance(obj)) +// { +// throw new InvalidObjectException("type of deserialized instance not of required class."); +// } return obj; } @@ -79,6 +81,8 @@ public class JavaLayerUtils if (in==null) throw new NullPointerException("in"); + //TODO : need to enable after having objectinputstream + /* ObjectInputStream objIn = new ObjectInputStream(in); Object obj; @@ -93,6 +97,8 @@ public class JavaLayerUtils } return obj; + */ + return null; } /** @@ -106,46 +112,58 @@ public class JavaLayerUtils * @param length The expected length of the array, or -1 if * any length is expected. */ - static public Object deserializeArray(InputStream in, Class elemType, int length) - throws IOException - { - if (elemType==null) - throw new NullPointerException("elemType"); - - if (length<-1) - throw new IllegalArgumentException("length"); - - Object obj = deserialize(in); - - //SSJava will never throw exceptions as it is so this code is meaningless - /* - Class cls = obj.getClass(); - - if (!cls.isArray()) - throw new InvalidObjectException("object is not an array"); - - Class arrayElemType = cls.getComponentType(); - if (arrayElemType!=elemType) - throw new InvalidObjectException("unexpected array component type"); - - if (length != -1) - { - int arrayLength = Array.getLength(obj); - if (arrayLength!=length) - throw new InvalidObjectException("array length mismatch"); - } - */ - return obj; - } + static public Object deserializeArray(InputStream in, int length) + throws IOException + { + if (length<-1) + throw new IllegalArgumentException("length"); + + Object obj = deserialize(in); + + return obj; + } +// static public Object deserializeArray(InputStream in, Class elemType, int length) +// throws IOException +// { +// if (elemType==null) +// throw new NullPointerException("elemType"); +// +// if (length<-1) +// throw new IllegalArgumentException("length"); +// +// Object obj = deserialize(in); +// +// //SSJava will never throw exceptions as it is so this code is meaningless +// /* +// Class cls = obj.getClass(); +// +// if (!cls.isArray()) +// throw new InvalidObjectException("object is not an array"); +// +// Class arrayElemType = cls.getComponentType(); +// if (arrayElemType!=elemType) +// throw new InvalidObjectException("unexpected array component type"); +// +// if (length != -1) +// { +// int arrayLength = Array.getLength(obj); +// if (arrayLength!=length) +// throw new InvalidObjectException("array length mismatch"); +// } +// */ +// return obj; +// } - static public Object deserializeArrayResource(String name, Class elemType, int length) +// static public Object deserializeArrayResource(String name, Class elemType, int length) + static public Object deserializeArrayResource(String name, int length) throws IOException { InputStream str = getResourceAsStream(name); if (str==null) throw new IOException("unable to load resource '"+name+"'"); - Object obj = deserializeArray(str, elemType, length); +// Object obj = deserializeArray(str, elemType, length); + Object obj = deserializeArray(str, length); return obj; } @@ -153,14 +171,15 @@ public class JavaLayerUtils static public void serialize(OutputStream out, Object obj) throws IOException { - if (out==null) - throw new NullPointerException("out"); - - if (obj==null) - throw new NullPointerException("obj"); - - ObjectOutputStream objOut = new ObjectOutputStream(out); - objOut.writeObject(obj); + //TODO : need to enable after having objectinputstream +// if (out==null) +// throw new NullPointerException("out"); +// +// if (obj==null) +// throw new NullPointerException("obj"); +// +// ObjectOutputStream objOut = new ObjectOutputStream(out); +// objOut.writeObject(obj); } @@ -196,11 +215,12 @@ public class JavaLayerUtils { is = hook.getResourceAsStream(name); } - else - { - Class cls = JavaLayerUtils.class; - is = cls.getResourceAsStream(name); - } + //TODO java reflection +// else +// { +// Class cls = JavaLayerUtils.class; +// is = cls.getResourceAsStream(name); +// } return is; } diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java index 42ea4c7f..0ac6afa9 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java @@ -701,7 +701,8 @@ class LayerIIDecoder extends LayerIDecoder implements FrameDecoder @LOC("TMP") int tmp = 0; @LOC("TEMP") int temp = samplecode; - if(temp > source.length - 3) temp = source.length - 3; +// if(temp > source.length - 3) temp = source.length - 3; + if(temp > groupingtable[0].length - 3) temp = groupingtable[0].length - 3; samples[tmp] = groupingtable[0][temp]; temp++;tmp++; diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java index c271208f..a65f2efe 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java @@ -62,7 +62,7 @@ final class LayerIIIDecoder implements FrameDecoder { @LOC("VAR") private float[][] prevblck; @LOC("K") private float[][] k; @LOC("NZ") private int[] nonzero; - @LOC("F")private Bitstream stream; + @LOC("F") private Bitstream stream; @LOC("H") private Header header; @LOC("F") private SynthesisFilter filter1; @LOC("F") private SynthesisFilter filter2; @@ -90,7 +90,8 @@ final class LayerIIIDecoder implements FrameDecoder { // decodeFrame() method, where possible, so that one @LATTICE("THIS