0400593d1c
Issue: https://github.com/dart-lang/sdk/issues/35881 Change-Id: I67ff49fef950c7c507f5006c357909cd09914c5f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106903 Commit-Queue: Daco Harkes <dacoharkes@google.com> Auto-Submit: Daco Harkes <dacoharkes@google.com> Reviewed-by: Samir Jindel <sjindel@google.com>
39 lines
971 B
Dart
39 lines
971 B
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "dart:_internal" show patch;
|
|
|
|
DynamicLibrary _open(String name) native "Ffi_dl_open";
|
|
|
|
@patch
|
|
@pragma("vm:entry-point")
|
|
class DynamicLibrary {
|
|
@patch
|
|
factory DynamicLibrary.open(String name) {
|
|
return _open(name);
|
|
}
|
|
|
|
@patch
|
|
Pointer<T> lookup<T extends NativeType>(String symbolName)
|
|
native "Ffi_dl_lookup";
|
|
|
|
// TODO(dacoharkes): Expose this to users, or extend Pointer?
|
|
// https://github.com/dart-lang/sdk/issues/35881
|
|
int getHandle() native "Ffi_dl_getHandle";
|
|
|
|
@patch
|
|
bool operator ==(other) {
|
|
if (other == null) return false;
|
|
return getHandle() == other.getHandle();
|
|
}
|
|
|
|
@patch
|
|
int get hashCode {
|
|
return getHandle().hashCode;
|
|
}
|
|
|
|
@patch
|
|
Pointer<Void> get handle => fromAddress(getHandle());
|
|
}
|