--- source: tests/struct.rs expression: out --- /// bindings for `libstruct` import 'dart:ffi'; import 'dart:io'; import 'package:ffi/ffi.dart' as ffi; // ignore_for_file: unused_import, camel_case_types, non_constant_identifier_names final DynamicLibrary _dl = _open(); /// Reference to the Dynamic Library, it should be only used for low-level access final DynamicLibrary dl = _dl; DynamicLibrary _open() { if (Platform.isWindows) return DynamicLibrary.open('struct.dll'); if (Platform.isAndroid) return DynamicLibrary.open('libstruct.so'); if (Platform.isIOS) return DynamicLibrary.executable(); throw UnsupportedError('This platform is not supported.'); } /// C struct `NormalStruct`. class NormalStruct extends Struct { @Int32() int a; Pointer b; static Pointer allocate() { return ffi.allocate(); } static NormalStruct from(int ptr) { return Pointer.fromAddress(ptr).ref; } } /// C struct `TypedStruct`. class TypedStruct extends Struct { @Int32() int a; @Int32() int b; Pointer c; @Int64() int d; static Pointer allocate() { return ffi.allocate(); } static TypedStruct from(int ptr) { return Pointer.fromAddress(ptr).ref; } }