Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mlofjard
Copy link
Contributor

Some subfields are referencing fields that come after themselves in the message. This is allowed by spec, but means that data messages have to be pre-read to include all potential reference fields. I did this with d.PeekUintBits, but had to wrap in since that method ignores d.Endian.

Maybe my peekUintBitsEndian should be moved to the decode package?

switch fDef.Type {
case "enum", "uint8", "uint8z", "byte":
val = peekUintBitsEndian(d, 8)
valMap[fDef.Name] = valueType{value: val, typ: fDef.Format}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these use d.U(<nBits>)? that one should respect current endian

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes maybe something like PeekUintBitsEndian could be useful... wonder even if peekUintBits should actually respect current endian? or maybe those should be d.Peek<type> like d.PeekU(24)? could probably even generate code for those.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dammit =) I was looking at the d.U (and all the d.Ux, d.UxLE etc) functions in the lounge at the hotel in Brussels, and now they completely slipped my mind. Yes, d.U would work and look better. I'll fix it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 maybe the decode API is not the most "discoverable", have some vague idea how maybe it could be made nicer, maybe use generic and methods chaining more? but the current keep it "dumb" and generate-design it quite nice also :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And just as you merged, I realized that although there are no reference fields that are also array types, there might be some that would throw of the value gathering, so I need to fix that too. =) another PR incoming soon

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, no worries!

@mlofjard mlofjard force-pushed the fit-peek-reference-fields branch from 72df677 to f7b067b Compare February 12, 2024 14:28
@wader
Copy link
Owner

wader commented Feb 12, 2024

👍 Will merge once CI is happy

I wonder if one could have a type to bit size table somehow and simplify it even more?

When reviewing the code i was thinking if there are some things that are now looked up by string could use int constant somehow?

@wader wader merged commit 4f2cdce into wader:master Feb 12, 2024
@mlofjard
Copy link
Contributor Author

👍 Will merge once CI is happy

I wonder if one could have a type to bit size table somehow and simplify it even more?

When reviewing the code i was thinking if there are some things that are now looked up by string could use int constant somehow?

Generally fDef.size should dictate how many bytes to read for each field, since there are many fields (those labeled UNKNOWN_X) that are not in the official Profile spec.

@mlofjard mlofjard deleted the fit-peek-reference-fields branch February 12, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants