Bug 367864 - Specify Big or Little Endian for multi-byte structure primitives
Summary: Specify Big or Little Endian for multi-byte structure primitives
Status: RESOLVED FIXED
Alias: None
Product: okteta
Classification: Applications
Component: Structures Tool (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: ---
Assignee: Alex Richardson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-26 18:10 UTC by Aaron Bishop
Modified: 2016-08-28 15:48 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Bishop 2016-08-26 18:10:26 UTC
version 0.19.3 (not available in drop version list)

I'm trying to write a structure for ANSI X9.37 files which encode the total length of each record as an unsigned 32 bit integer. Normally these are in Motorola byte order or Big Endian. Also, TIFF files can either by II or MM for Intel or Motorola byte order numerics.

Reproducible: Always

Steps to Reproduce:
1. Create a file with the following hex:
00 00 00 50
2. Create a structure with the following ods:
<?xml version="1.0" encoding="UTF-8"?>
<data><struct name="mm_example"><primitive type="uint32-be" /></struct></data>
3. Open the structure and the file.
4. Change the primitive type to "uint32".
5. Open the structure and the file.

Actual Results:  
On first opening with type="uint32-be", you get "uint32-be" does not name a valid primitive type.
With type="uint32", you get the correct structure, but the value is 1342177280

Expected Results:  
With type="uint32", the value should be 80
Comment 1 Alex Richardson 2016-08-26 22:05:55 UTC
You can use <primitive type="uint32" byteOrder="big-endian"\> to get the desired result.

Or do you want to be able to have type aliases so that  type="uint32-be" refers to that? That is not implemented yet and I'm not sure it makes sense. You could achieve that when using javascript structure definitions (https://userbase.kde.org/Okteta/Writing_structure_definitions):

function uint32_be() {
  var ret = uint32()
  ret.byteOrder = "big-endian"
  return ret;
}

function init() {
  var mm_example = struct({foo: uint32_be()}
  return mm_example;
}
Comment 2 Aaron Bishop 2016-08-28 15:48:14 UTC
my apologies, I don't know how I missed the byteOrder documentation. No need for another alias.