diff --git a/trunk/src/com/jpexs/asdec/abc/ABC.java b/trunk/src/com/jpexs/asdec/abc/ABC.java index 6220fb6cd..bb1f2a949 100644 --- a/trunk/src/com/jpexs/asdec/abc/ABC.java +++ b/trunk/src/com/jpexs/asdec/abc/ABC.java @@ -50,10 +50,12 @@ public class ABC { public long stringOffsets[]; public static String IDENT_STRING = " "; + public static final int MINORwithDECIMAL = 17; + public ABC(InputStream is) throws IOException { ABCInputStream ais = new ABCInputStream(is); - major_version = ais.readU16(); minor_version = ais.readU16(); + major_version = ais.readU16(); constants = new ConstantPool(); //constant integers int constant_int_pool_count = ais.readU30(); @@ -76,6 +78,19 @@ public class ABC { constants.constant_double[i] = ais.readDouble(); } + + //constant decimal + if(minor_version >= MINORwithDECIMAL) + { + int constant_decimal_pool_count = ais.readU30(); + constants.constant_decimal = new Decimal[constant_decimal_pool_count]; + for (int i = 1; i < constant_decimal_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_decimal[i] = ais.readDecimal(); + } + }else{ + constants.constant_decimal=new Decimal[0]; + } + //constant string int constant_string_pool_count = ais.readU30(); constants.constant_string = new String[constant_string_pool_count]; @@ -202,8 +217,8 @@ public class ABC { public void saveToStream(OutputStream os) throws IOException { ABCOutputStream aos = new ABCOutputStream(os); - aos.writeU16(major_version); aos.writeU16(minor_version); + aos.writeU16(major_version); aos.writeU30(constants.constant_int.length); for (int i = 1; i < constants.constant_int.length; i++) { @@ -219,6 +234,13 @@ public class ABC { aos.writeDouble(constants.constant_double[i]); } + if(minor_version>=MINORwithDECIMAL){ + aos.writeU30(constants.constant_decimal.length); + for (int i = 1; i < constants.constant_decimal.length; i++) { + aos.writeDecimal(constants.constant_decimal[i]); + } + } + aos.writeU30(constants.constant_string.length); for (int i = 1; i < constants.constant_string.length; i++) { aos.writeString(constants.constant_string[i]); diff --git a/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java b/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java index 739ae38fb..b3dfd899f 100644 --- a/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java +++ b/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java @@ -313,6 +313,20 @@ public class ABCInputStream extends InputStream { return traits; } + public byte[] readBytes(int count) throws IOException{ + byte ret[]=new byte[count]; + for(int i=0;iJTable uses this method to determine how many rows it + * should display. This method should be quick, as it + * is called frequently during rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_decimal.length; + } + + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } + + /** + * Returns the name of the column at columnIndex. This is used + * to initialize the table's column header name. Note: this name does + * not need to be unique; two columns in a table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } + + /** + * Returns the most specific superclass for all the cell values + * in the column. This is used by the JTable to set up a + * default renderer and editor for the column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } + + /** + * Returns true if the cell at rowIndex and + * columnIndex + * is editable. Otherwise, setValueAt on the cell will not + * change the value of that cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + /** + * Returns the value for the cell at columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) return rowIndex; + else { + return abc.constants.constant_decimal[rowIndex]; + } + } + + /** + * Sets the value in the cell at columnIndex and + * rowIndex to aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + + } + + /** + * Adds a listener to the list that is notified each time a change + * to the data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + + } + + /** + * Removes a listener from the list that is notified each time a + * change to the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/types/Decimal.java b/trunk/src/com/jpexs/asdec/abc/types/Decimal.java new file mode 100644 index 000000000..993db1711 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/types/Decimal.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program 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 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.types; + +/** + * + * @author JPEXS + */ +public class Decimal { + public byte data[]; + public Decimal(byte data[]) + { + this.data=data; + } + + @Override + public String toString() { + return new String(data); + } + + +} diff --git a/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java b/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java index 3b3644d99..37637ed9c 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java +++ b/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java @@ -23,6 +23,7 @@ import com.jpexs.asdec.abc.avm2.ConstantPool; public class ValueKind { + public static final int CONSTANT_Decimal = 0x02; //decimal public static final int CONSTANT_Int = 0x03;// integer public static final int CONSTANT_UInt = 0x04;// uinteger public static final int CONSTANT_Double = 0x06;// double @@ -38,8 +39,8 @@ public class ValueKind { public static final int CONSTANT_ExplicitNamespace = 0x19;// Namespace public static final int CONSTANT_StaticProtectedNs = 0x1A;// Namespace public static final int CONSTANT_PrivateNs = 0x05;// namespace - private static final int optionalKinds[] = new int[]{0x03, 0x04, 0x06, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05}; - private static final String optionalKindNames[] = new String[]{"Int", "UInt", "Double", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNs"}; + private static final int optionalKinds[] = new int[]{0x03, 0x04, 0x06,0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05}; + private static final String optionalKindNames[] = new String[]{"Int", "UInt", "Double","Decimal", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNs"}; public int value_index; public int value_kind; @@ -78,6 +79,9 @@ public class ValueKind { case CONSTANT_Double: ret = "" + constants.constant_double[value_index]; break; + case CONSTANT_Decimal: + ret = "" + constants.constant_decimal[value_index]; + break; case CONSTANT_Utf8: ret = "\"" + constants.constant_string[value_index] + "\""; break;