Ravi,
In Dartino we have several options to work with byte and bit fiddling.
1. Direct access to memory through dartino:ffi's ForeignMemory interface
The
dartino:
ffi library expose direct access to memory through the
ForeignMemory interface.
ForeignMemory can be constructed from a pointer value (e.g. for manipulating peripherals) or by allocating on the C-heap.
ForeignMemory provides access to bytes, 16-bit, 32-bit and 64-bit values through methods getInt8, setInt8, getUint8, setUint8, getInt16, etc. Unfortunately the documentation we currently generate does not include the
builtin libraries, but the code with the interfaces can be found
here.
You can take a look at the STM32
GPIO configuration
code which this interface to configure STM32
GIPO.
2. The dart:typed_data library is supported
As Warren mentioned dart:typed_data provide a general Dart API for working with byte buffers. On Dartino all typed_data objects are backed by memory allocated on the C heap and not in the Dartino heap. That way typed_data objects can be used transparently with ffi.
3. Having infinite precision integers is an option in Dartino
Dartino does support infinite precision integers as specified in the Dart language specification. However there is an option to turn that off. Currently through the .dartino-settings file, where adding "dartino.enable-bigint": "false"
to the "constants" map will do that.
When infinite precision integers are turned off Dartino support 64-bit signed integers. That means that handling 32-bit signed and unsigned integers is well supported.
Adding specific sized integer types (e.g. int32) to Dart at the language level has been discussed, but there is no final decision at the moment.
The
Dartino support for infinite precision integers is provided through
Dart code, and if support is turned on this Dart code will be part of the compiled code. This is quite substantial, and makes the image bigger (byte codes for the this are about 15kb), so maybe we should change the default to have infinite precision integers turned off. The current semantics for overflow is to throw an exception when infinite precision integers are turned off.
Regards,
Søren