Child pages
  • Coding Style and Guidelines for Contributors

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added bit-byte 0b 1b stuff

...

Our goal is all-64-bit capabilities. Unfortunately, many Java and Scala libraries do not allow offsets or positions larger than a signed 32-bit Int can hold.

Someday, maybe those libraries will be updated so that, for example, a byte array can hold an entire video, which is bigger than 2GBytes. For now we're stuck.

...

Unless specified below, all code should following the Scala Style Guide.

Bits, Bytes, 1-based, and zero-based indexing

DFDL and XML use 1-based indexing. Java, Scala, and all their libraries (except XML libraries?) are zero-based.

Also, DFDL allows expression of lengths and alignments in bits, bytes, or characters.

Some naming conventions make code maintenance much easier even if they make identifiers bigger.

Using these identifiers can eliminate the need for many code comments to clarify this stuff.

The convention is to begin the identifier with either bit, byte, or char, (or other like 'child'), and suffix it with 1b or 0b.

Examples:

  • bitPosition0b - means position, measured in bits, first bit is at position 0.
  • childIndex1b - child index, first child is at index 1.

 

 

Line Endings

All files should use Unix line endings (i.e. \n).

...