Skip to content

Commit

Permalink
ctf.core: Add support for fixed signed integer field class
Browse files Browse the repository at this point in the history
Added the fixed signed integer field class. Null checks have also been
added for clock offsets and preamble UUIDs in this patch.

Change-Id: Ie2a44323bff42edc9619e18d696884e573f8b9f1
Signed-off-by: Sehr Moosabhoy <sehr.moosabhoy@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/203785
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
Sehr Moosabhoy authored and bhufmann committed Sep 1, 2023
1 parent e626ea4 commit 4aee677
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Expand Up @@ -68,7 +68,10 @@ public int getVersion() {
* @return the uuid
*/
public UUID getUuid() {
ByteBuffer bb = ByteBuffer.wrap(this.fUuid);
if (fUuid == null) {
return null;
}
ByteBuffer bb = ByteBuffer.wrap(fUuid);
long high = bb.getLong();
long low = bb.getLong();
return new UUID(high, low);
Expand Down
Expand Up @@ -145,7 +145,7 @@ public CTFClock parse(ICTFMetadataNode clock, ICommonTreeParserParameter unused)
ctfClock.addAttribute(DESCRIPTION, jsonClock.getPrecision());
}
JsonObject offset = jsonClock.getOffset();
if (offset.has(SECONDS) && offset.has(CYCLES)) {
if (offset != null && offset.has(SECONDS) && offset.has(CYCLES)) {
Long seconds = offset.get(SECONDS).getAsLong();
Long cycles = offset.get(CYCLES).getAsLong();
ctfClock.addAttribute(OFFSET, cycles);
Expand Down
Expand Up @@ -104,6 +104,9 @@ public IDeclaration parse(ICTFMetadataNode typealias, ICommonTreeParserParameter
if (JsonMetadataStrings.FIXED_UNSIGNED_INTEGER_FIELD.equals(type)) {
fieldClass.addProperty(SIGNED, false);
targetDeclaration = IntegerDeclarationParser.INSTANCE.parse(typealias, new IntegerDeclarationParser.Param(trace));
} else if (JsonMetadataStrings.FIXED_SIGNED_INTEGER_FIELD.equals(type)) {
fieldClass.addProperty(SIGNED, true);
targetDeclaration = IntegerDeclarationParser.INSTANCE.parse(typealias, new IntegerDeclarationParser.Param(trace));
} else if (JsonMetadataStrings.STATIC_LENGTH_BLOB.equals(type)) {
targetDeclaration = BlobDeclarationParser.INSTANCE.parse(typealias, null);
} else if (JsonMetadataStrings.NULL_TERMINATED_STRING.equals(type)) {
Expand Down
Expand Up @@ -127,6 +127,11 @@ private JsonMetadataStrings() {
*/
public static final String FIXED_UNSIGNED_INTEGER_FIELD = "fixed-length-unsigned-integer"; //$NON-NLS-1$

/**
* Type string for a signed integer field class
*/
public static final String FIXED_SIGNED_INTEGER_FIELD = "fixed-length-signed-integer"; //$NON-NLS-1$

/**
* Type string for a static length blob field class
*/
Expand Down

0 comments on commit 4aee677

Please sign in to comment.