Pointer<T extends NativeType>.fromAddress constructor

Pointer<T extends NativeType>.fromAddress(
  1. int ptr, [
  2. Memory? bindTo
])

Constructs a pointer from an address.

The optional parameter bindTo can be ommited, if and only if Memory.global is set, which is then used as Memory to bind to.

Implementation

factory Pointer.fromAddress(int ptr, [Memory? bindTo]) {
  bindTo = Memory.global;
  Memory m;
  if (bindTo != null) {
    m = bindTo;
  } else {
    throw new StateError(
        'No global memory set and no explcity memory to bind to given!');
  }
  return new Pointer._(ptr, m, _isUnsizedType<T>() ? null : sizeOf<T>());
}