dart-sdk/sdk/lib/ffi/dynamic_library.dart
Samir Jindel e64738ffbc [vm/ffi] DynamicLibrary.process() and DynamicLibrary.executable()
Change-Id: I6be84f24f0ac245ba176748e4a3ec1ba782798ce
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-debug-x64-try,vm-kernel-mac-debug-x64-try,vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113687
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2019-08-19 14:24:01 +00:00

44 lines
1.6 KiB
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.
part of dart.ffi;
/// Represents a dynamically loaded C library.
class DynamicLibrary {
/// Creates a dynamic library holding all global symbols.
///
/// Any symbol in a library currently loaded with global visibility (including
/// the executable itself) may be resolved in this library.
///
/// This feature is not available on Windows, instead an exception is thrown.
external factory DynamicLibrary.process();
/// Creates a dynamic library representing the running executable.
external factory DynamicLibrary.executable();
/// Loads a dynamic library file with local visibility.
///
/// Throws an [ArgumentError] if loading the dynamic library fails.
external factory DynamicLibrary.open(String name);
/// Looks up a symbol in the [DynamicLibrary] and returns its address in
/// memory. Equivalent of dlsym.
///
/// Throws an [ArgumentError] if it fails to lookup the symbol.
external Pointer<T> lookup<T extends NativeType>(String symbolName);
/// Helper that combines lookup and cast to a Dart function.
external F lookupFunction<T extends Function, F extends Function>(
String symbolName);
/// Dynamic libraries are equal if they load the same library.
external bool operator ==(other);
/// The hash code for a DynamicLibrary only depends on the loaded library
external int get hashCode;
/// The handle to the dynamic library.
external Pointer<Void> get handle;
}