import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StringDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.VariantDefinition;
+import org.eclipse.tracecompass.internal.ctf.core.event.types.ByteArrayDefinition;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.ctf.core.CtfEnumPair;
*/
protected CtfTmfEventField(@NonNull String name, Object value, ITmfEventField[] fields) {
super(/* Strip the underscore from the field name if there is one */
- name.startsWith("_") ? checkNotNull(name.substring(1)) : name, //$NON-NLS-1$
+ name.startsWith("_") ? name.substring(1) : name, //$NON-NLS-1$
value,
fields);
}
* String The name to assign to this field
* @return The resulting CtfTmfEventField object
*/
- public static CtfTmfEventField parseField(IDefinition fieldDef,
+ public static @NonNull CtfTmfEventField parseField(IDefinition fieldDef,
@NonNull String fieldName) {
CtfTmfEventField field = null;
}
CompoundDeclaration arrDecl = (CompoundDeclaration) decl;
IDeclaration elemType = null;
- Collection<Definition> definitions = arrayDef.getDefinitions();
elemType = arrDecl.getElementType();
+ if (arrayDef instanceof ByteArrayDefinition) {
+ ByteArrayDefinition byteArrayDefinition = (ByteArrayDefinition) arrayDef;
+ /* it's a CTFIntegerArrayField */
+ int size = arrayDef.getLength();
+ long[] values = new long[size];
+ for (int i = 0; i < size; i++) {
+ values[i] = Byte.toUnsignedLong(byteArrayDefinition.getByte(i));
+ }
+ field = new CTFIntegerArrayField(fieldName, values,
+ 16,
+ false);
+
+ }
if (elemType instanceof IntegerDeclaration) {
/*
* Array of integers => CTFIntegerArrayField, unless it's a
field = new CTFStringField(fieldName, arrayDef.toString());
} else {
/* it's a CTFIntegerArrayField */
- int size = arrayDef.getDefinitions().size();
+ int size = arrayDef.getLength();
long[] values = new long[size];
for (int i = 0; i < size; i++) {
IDefinition elem = arrayDef.getDefinitions().get(i);
CtfTmfEventField[] elements = new CtfTmfEventField[arrayDef.getLength()];
/* Parse the elements of the array. */
int i = 0;
+ List<Definition> definitions = arrayDef.getDefinitions();
for (IDefinition definition : definitions) {
CtfTmfEventField curField = CtfTmfEventField.parseField(
definition, fieldName + '[' + i + ']');
List<ITmfEventField> list = new ArrayList<>();
/* Recursively parse the fields */
- for (String curFieldName : strDef.getFieldNames()) {
- String fn = checkNotNull(curFieldName);
+ for (String fn : strDef.getFieldNames()) {
list.add(CtfTmfEventField.parseField((IDefinition) strDef.getDefinition(fn), fn));
}
field = new CTFStructField(fieldName, list.toArray(new CtfTmfEventField[list.size()]));
* Is the value signed or not
*/
CTFIntegerField(@NonNull String name, long longValue, int base, boolean signed) {
- super(name, longValue, null);
+ super(name, Long.valueOf(longValue), null);
fSigned = signed;
fBase = base;
}