From c0453908d39926ffeaf208638892c86ebcf9d219 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Thu, 6 Nov 2014 11:36:49 -0500 Subject: [PATCH] ctf: Remove deprecated datatypes Change-Id: I65f2e72c21ecd44993f969b1192e9f5e973be89f Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/36092 Tested-by: Hudson CI Reviewed-by: Genevieve Bastien --- .../core/event/types/ArrayDeclaration.java | 149 ------------------ .../ctf/core/event/types/ArrayDefinition.java | 134 ---------------- .../core/event/types/ScopedDefinition.java | 33 ---- .../core/event/types/SequenceDeclaration.java | 145 ----------------- .../core/event/types/SequenceDefinition.java | 126 --------------- .../tracecompass/ctf/core/trace/Utils.java | 18 --- 6 files changed, 605 deletions(-) delete mode 100644 org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDeclaration.java delete mode 100644 org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDefinition.java delete mode 100644 org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDeclaration.java delete mode 100644 org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDefinition.java diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDeclaration.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDeclaration.java deleted file mode 100644 index 2194508aa0..0000000000 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDeclaration.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Matthew Khouzam - Initial API and implementation - * Contributors: Simon Marchi - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.tracecompass.ctf.core.event.types; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer; -import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope; -import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.common.collect.Multimap; - -/** - * A CTF array declaration - * - * Arrays are fixed-length. Their length is declared in the type declaration - * within the meta-data. They contain an array of "inner type" elements, which - * can refer to any type not containing the type of the array being declared (no - * circular dependency). The length is the number of elements in an array. - * - * @deprecated use - * {@link org.eclipse.tracecompass.internal.ctf.core.event.types.ArrayDeclaration} - * @version 1.0 - * @author Matthew Khouzam - * @author Simon Marchi - */ -@Deprecated -public class ArrayDeclaration extends CompoundDeclaration { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final int fLength; - private final IDeclaration fElemType; - - /** - *
-     * Cache where we can pre-generate the children names
-     * Key: parent name
-     * Value: children names
-     * ex: field → {field[0], field[1], … field[n]}
-     * 
- * - * TODO: investigate performance - */ - private final Multimap fChildrenNames = ArrayListMultimap. create(); - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Constructor - * - * @param length - * how many elements in the array - * @param elemType - * what type of element is in the array - */ - public ArrayDeclaration(int length, IDeclaration elemType) { - fLength = length; - fElemType = elemType; - } - - // ------------------------------------------------------------------------ - // Getters/Setters/Predicates - // ------------------------------------------------------------------------ - - @Override - public IDeclaration getElementType() { - return fElemType; - } - - /** - * - * @return how many elements in the array - */ - public int getLength() { - return fLength; - } - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - - /** - * @since 3.0 - */ - @Deprecated - @Override - public ArrayDefinition createDefinition(IDefinitionScope definitionScope, - @NonNull String fieldName, BitBuffer input) throws CTFReaderException { - alignRead(input); - List definitions = read(input, definitionScope, fieldName); - return new ArrayDefinition(this, definitionScope, fieldName, definitions); - } - - @Override - public String toString() { - /* Only used for debugging */ - return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$ - } - - @NonNull - private List read(@NonNull BitBuffer input, IDefinitionScope definitionScope, String fieldName) throws CTFReaderException { - Builder definitions = new ImmutableList.Builder<>(); - if (!fChildrenNames.containsKey(fieldName)) { - for (int i = 0; i < fLength; i++) { - fChildrenNames.put(fieldName, fieldName + '[' + i + ']'); - } - } - List elemNames = (List) fChildrenNames.get(fieldName); - for (int i = 0; i < fLength; i++) { - String name = elemNames.get(i); - if (name == null) { - throw new IllegalStateException(); - } - definitions.add(fElemType.createDefinition(definitionScope, name, input)); - } - @SuppressWarnings("null") - @NonNull ImmutableList ret = definitions.build(); - return ret; - } - - /** - * @since 3.0 - */ - @Override - public int getMaximumSize() { - long val = (long) fLength * fElemType.getMaximumSize(); - return (int) Math.min(Integer.MAX_VALUE, val); - } - -} diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDefinition.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDefinition.java deleted file mode 100644 index 5e2127555c..0000000000 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ArrayDefinition.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Matthew Khouzam - Initial API and implementation - * Contributors: Simon Marchi - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.tracecompass.ctf.core.event.types; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; - -/** - * A CTF array definition - * - * Arrays are fixed-length. Their length is declared in the type declaration - * within the meta-data. They contain an array of "inner type" elements, which - * can refer to any type not containing the type of the array being declared (no - * circular dependency). The length is the number of elements in an array. - * - * @deprecated use {@link AbstractArrayDefinition} - * @version 1.0 - * @author Matthew Khouzam - * @author Simon Marchi - */ -@NonNullByDefault -@Deprecated -public final class ArrayDefinition extends AbstractArrayDefinition{ - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final ImmutableList fDefinitions; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Constructor - * - * @param declaration - * the parent declaration - * @param definitionScope - * the parent scope - * @param fieldName - * the field name - * @param definitions - * the content of the array - * @since 3.0 - */ - public ArrayDefinition(ArrayDeclaration declaration, - @Nullable IDefinitionScope definitionScope, - String fieldName, - List definitions) { - super(declaration, definitionScope, fieldName); - @SuppressWarnings("null") - @NonNull ImmutableList list = ImmutableList.copyOf(definitions); - fDefinitions = list; - - } - - // ------------------------------------------------------------------------ - // Getters/Setters/Predicates - // ------------------------------------------------------------------------ - - @Override - public List getDefinitions() { - return fDefinitions; - } - - /** - * Get the element at i - * - * @param i the index (cannot be negative) - * @return The element at I, if I > length, null, if I < 0, the method throws an out of bounds exception - */ - @Nullable - public Definition getElem(int i) { - if (i > fDefinitions.size()) { - return null; - } - - return fDefinitions.get(i); - } - - @Override - public ArrayDeclaration getDeclaration() { - return (ArrayDeclaration) super.getDeclaration(); - } - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - - if (getDeclaration().isString()) { - for (Definition def : fDefinitions) { - IntegerDefinition character = (IntegerDefinition) def; - - if (character.getValue() == 0) { - break; - } - - b.append(character.toString()); - } - } else { - b.append('['); - Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$ - b.append(joiner.join(fDefinitions)); - b.append(']'); - } - - @SuppressWarnings("null") - @NonNull String ret = b.toString(); - return ret; - } -} diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ScopedDefinition.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ScopedDefinition.java index abe020d5af..c8de3b289c 100644 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ScopedDefinition.java +++ b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ScopedDefinition.java @@ -74,21 +74,6 @@ public abstract class ScopedDefinition extends Definition implements IDefinition return (AbstractArrayDefinition) ((def instanceof AbstractArrayDefinition) ? def : null); } - /** - * Lookup an array in a struct. If the name returns a non-array (like an - * int) then the method returns null - * - * @param name - * the name of the array - * @return the array or null. - * @deprecated use {@link ScopedDefinition#lookupArrayDefinition(String)} - */ - @Deprecated - @Nullable - public ArrayDefinition lookupArray(String name) { - Definition def = lookupDefinition(name); - return (ArrayDefinition) ((def instanceof ArrayDefinition) ? def : null); - } /** * Lookup an enum in a struct. If the name returns a non-enum (like an int) @@ -120,24 +105,6 @@ public abstract class ScopedDefinition extends Definition implements IDefinition return (IntegerDefinition) ((def instanceof IntegerDefinition) ? def : null); } - /** - * Lookup a sequence in a struct. If the name returns a non-sequence (like - * an int) then the method returns null - * - * @param name - * the name of the sequence - * @return the sequence or null if a definition is not found or it does not - * match the desired datatype. - * @since 3.0 - * @deprecated use {@link ScopedDefinition#lookupArrayDefinition(String)} - */ - @Deprecated - @Nullable - public SequenceDefinition lookupSequence(String name) { - Definition def = lookupDefinition(name); - return (SequenceDefinition) ((def instanceof SequenceDefinition) ? def : null); - } - /** * Lookup a string in a struct. If the name returns a non-string (like an * int) then the method returns null diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDeclaration.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDeclaration.java deleted file mode 100644 index e8739a93da..0000000000 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDeclaration.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Matthew Khouzam - Initial API and implementation - * Contributors: Simon Marchi - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.tracecompass.ctf.core.event.types; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer; -import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope; -import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.common.collect.Multimap; - -/** - * A CTF sequence declaration. - * - * An array where the size is fixed but declared in the trace, unlike array - * where it is declared with a literal - * @deprecated use {@link org.eclipse.tracecompass.internal.ctf.core.event.types.SequenceDeclaration} - * @version 1.0 - * @author Matthew Khouzam - * @author Simon Marchi - */ -@Deprecated -public class SequenceDeclaration extends CompoundDeclaration { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final IDeclaration fElemType; - private final String fLengthName; - private final Multimap fPaths = ArrayListMultimap.create(); - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Constructor - * - * @param lengthName - * the name of the field describing the length - * @param elemType - * The element type - */ - public SequenceDeclaration(String lengthName, IDeclaration elemType) { - fElemType = elemType; - fLengthName = lengthName; - } - - // ------------------------------------------------------------------------ - // Getters/Setters/Predicates - // ------------------------------------------------------------------------ - - @Override - public IDeclaration getElementType() { - return fElemType; - } - - /** - * Gets the name of the length field - * - * @return the name of the length field - */ - public String getLengthName() { - return fLengthName; - } - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - - /** - * @since 3.0 - */ - @SuppressWarnings("null") // immutablelist - @Override - public SequenceDefinition createDefinition( - IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException { - IDefinition lenDef = null; - - if (definitionScope != null) { - lenDef = definitionScope.lookupDefinition(getLengthName()); - } - - if (lenDef == null) { - throw new CTFReaderException("Sequence length field not found"); //$NON-NLS-1$ - } - - if (!(lenDef instanceof IntegerDefinition)) { - throw new CTFReaderException("Sequence length field not integer"); //$NON-NLS-1$ - } - - IntegerDefinition lengthDefinition = (IntegerDefinition) lenDef; - - if (lengthDefinition.getDeclaration().isSigned()) { - throw new CTFReaderException("Sequence length must not be signed"); //$NON-NLS-1$ - } - - long length = lengthDefinition.getValue(); - if ((length > Integer.MAX_VALUE) || (!input.canRead((int) length * fElemType.getMaximumSize()))) { - throw new CTFReaderException("Sequence length too long " + length); //$NON-NLS-1$ - } - - Collection collection = fPaths.get(fieldName); - while (collection.size() < length) { - fPaths.put(fieldName, fieldName + '[' + collection.size() + ']'); - } - List paths = (List) fPaths.get(fieldName); - Builder definitions = new ImmutableList.Builder<>(); - for (int i = 0; i < length; i++) { - definitions.add(fElemType.createDefinition(definitionScope, paths.get(i), input)); - } - return new SequenceDefinition(this, definitionScope, fieldName, definitions.build()); - } - - @Override - public String toString() { - /* Only used for debugging */ - return "[declaration] sequence[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$ - } - - /** - * @since 3.0 - */ - @Override - public int getMaximumSize() { - return Integer.MAX_VALUE; - } - -} diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDefinition.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDefinition.java deleted file mode 100644 index f4fb9d8e83..0000000000 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/SequenceDefinition.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Matthew Khouzam - Initial API and implementation - * Contributors: Simon Marchi - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.tracecompass.ctf.core.event.types; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; - -/** - * A CTF sequence definition (a fixed-size array). - * - * An array where the size is fixed but declared in the trace, unlike array - * where it is declared with a literal - * - * @deprecated use {@link AbstractArrayDefinition} - * @version 1.0 - * @author Matthew Khouzam - * @author Simon Marchi - */ -@Deprecated -public final class SequenceDefinition extends Definition { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final ImmutableList fDefinitions; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Constructor - * - * @param declaration - * the parent declaration - * @param definitionScope - * the parent scope - * @param fieldName - * the field name - * @param definitions - * Definitions - * @since 3.0 - */ - public SequenceDefinition(@NonNull SequenceDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, List definitions) { - super(declaration, definitionScope, fieldName); - fDefinitions = ImmutableList.copyOf(definitions); - } - - // ------------------------------------------------------------------------ - // Getters/Setters/Predicates - // ------------------------------------------------------------------------ - - @Override - public SequenceDeclaration getDeclaration() { - return (SequenceDeclaration) super.getDeclaration(); - } - - /** - * The length of the sequence in number of elements so a sequence of 5 - * GIANT_rediculous_long_ints is the same as a sequence of 5 bits. (5) - * - * @return the length of the sequence - */ - public int getLength() { - return fDefinitions.size(); - } - - /** - * Get the element at i - * - * @param i - * the index (cannot be negative) - * @return The element at I, if I > length, null, if I < 0, the method - * throws an out of bounds exception - */ - public Definition getElem(int i) { - if (i > fDefinitions.size()) { - return null; - } - return fDefinitions.get(i); - } - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - - if (getDeclaration().isString()) { - for (Definition def : fDefinitions) { - IntegerDefinition character = (IntegerDefinition) def; - - if (character.getValue() == 0) { - break; - } - - b.append(character.toString()); - } - } else { - b.append('['); - Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$ - b.append(joiner.join(fDefinitions)); - b.append(']'); - } - - return b.toString(); - } -} diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Utils.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Utils.java index 06f70e92f4..c140c80476 100644 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Utils.java +++ b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Utils.java @@ -139,24 +139,6 @@ public final class Utils { return uuid; } - /** - * Gets a UUID from an array defintion - * - * @param uuidDef - * the array defintions, must contain integer bytes - * @return the UUID - * @throws CTFReaderException - * if the definition contains less than 16 elements - * @since 3.1 - * @deprecated use - * {@link Utils#getUUIDfromDefinition(AbstractArrayDefinition uuidDef)} - */ - @Deprecated - public static UUID getUUIDfromDefinition(org.eclipse.tracecompass.ctf.core.event.types.ArrayDefinition uuidDef) throws CTFReaderException { - byte[] uuidArray = new byte[16]; - return getUUID(uuidDef, uuidArray); - } - /** * Creates a UUID object from an array of 16 bytes. * -- 2.34.1