|
| 1 | + |
| 2 | + |
| 3 | +import 'dart:ffi'; |
| 4 | +import 'package:library/src/_library_context.dart' as __lib; |
| 5 | +import 'package:library/src/generic_types__conversion.dart'; |
| 6 | +import 'package:library/src/smoke/global_list_type_def.dart'; |
| 7 | + |
| 8 | + |
| 9 | +class SomeDartStructWithTypedefField { |
| 10 | + GlobalListTypeDef someField; |
| 11 | + |
| 12 | + SomeDartStructWithTypedefField(this.someField); |
| 13 | +} |
| 14 | + |
| 15 | + |
| 16 | +// SomeDartStructWithTypedefField "private" section, not exported. |
| 17 | + |
| 18 | +final _smokeSomedartstructwithtypedeffieldCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< |
| 19 | + Pointer<Void> Function(Pointer<Void>), |
| 20 | + Pointer<Void> Function(Pointer<Void>) |
| 21 | + >('library_smoke_SomeDartStructWithTypedefField_create_handle')); |
| 22 | +final _smokeSomedartstructwithtypedeffieldReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< |
| 23 | + Void Function(Pointer<Void>), |
| 24 | + void Function(Pointer<Void>) |
| 25 | + >('library_smoke_SomeDartStructWithTypedefField_release_handle')); |
| 26 | +final _smokeSomedartstructwithtypedeffieldGetFieldsomeField = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< |
| 27 | + Pointer<Void> Function(Pointer<Void>), |
| 28 | + Pointer<Void> Function(Pointer<Void>) |
| 29 | + >('library_smoke_SomeDartStructWithTypedefField_get_field_someField')); |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +Pointer<Void> smokeSomedartstructwithtypedeffieldToFfi(SomeDartStructWithTypedefField value) { |
| 34 | + final _someFieldHandle = foobarListofFloatToFfi(value.someField); |
| 35 | + final _result = _smokeSomedartstructwithtypedeffieldCreateHandle(_someFieldHandle); |
| 36 | + foobarListofFloatReleaseFfiHandle(_someFieldHandle); |
| 37 | + return _result; |
| 38 | +} |
| 39 | + |
| 40 | +SomeDartStructWithTypedefField smokeSomedartstructwithtypedeffieldFromFfi(Pointer<Void> handle) { |
| 41 | + final _someFieldHandle = _smokeSomedartstructwithtypedeffieldGetFieldsomeField(handle); |
| 42 | + try { |
| 43 | + return SomeDartStructWithTypedefField( |
| 44 | + foobarListofFloatFromFfi(_someFieldHandle) |
| 45 | + ); |
| 46 | + } finally { |
| 47 | + foobarListofFloatReleaseFfiHandle(_someFieldHandle); |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +void smokeSomedartstructwithtypedeffieldReleaseFfiHandle(Pointer<Void> handle) => _smokeSomedartstructwithtypedeffieldReleaseHandle(handle); |
| 52 | + |
| 53 | +// Nullable SomeDartStructWithTypedefField |
| 54 | + |
| 55 | +final _smokeSomedartstructwithtypedeffieldCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< |
| 56 | + Pointer<Void> Function(Pointer<Void>), |
| 57 | + Pointer<Void> Function(Pointer<Void>) |
| 58 | + >('library_smoke_SomeDartStructWithTypedefField_create_handle_nullable')); |
| 59 | +final _smokeSomedartstructwithtypedeffieldReleaseHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< |
| 60 | + Void Function(Pointer<Void>), |
| 61 | + void Function(Pointer<Void>) |
| 62 | + >('library_smoke_SomeDartStructWithTypedefField_release_handle_nullable')); |
| 63 | +final _smokeSomedartstructwithtypedeffieldGetValueNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< |
| 64 | + Pointer<Void> Function(Pointer<Void>), |
| 65 | + Pointer<Void> Function(Pointer<Void>) |
| 66 | + >('library_smoke_SomeDartStructWithTypedefField_get_value_nullable')); |
| 67 | + |
| 68 | +Pointer<Void> smokeSomedartstructwithtypedeffieldToFfiNullable(SomeDartStructWithTypedefField? value) { |
| 69 | + if (value == null) return Pointer<Void>.fromAddress(0); |
| 70 | + final _handle = smokeSomedartstructwithtypedeffieldToFfi(value); |
| 71 | + final result = _smokeSomedartstructwithtypedeffieldCreateHandleNullable(_handle); |
| 72 | + smokeSomedartstructwithtypedeffieldReleaseFfiHandle(_handle); |
| 73 | + return result; |
| 74 | +} |
| 75 | + |
| 76 | +SomeDartStructWithTypedefField? smokeSomedartstructwithtypedeffieldFromFfiNullable(Pointer<Void> handle) { |
| 77 | + if (handle.address == 0) return null; |
| 78 | + final _handle = _smokeSomedartstructwithtypedeffieldGetValueNullable(handle); |
| 79 | + final result = smokeSomedartstructwithtypedeffieldFromFfi(_handle); |
| 80 | + smokeSomedartstructwithtypedeffieldReleaseFfiHandle(_handle); |
| 81 | + return result; |
| 82 | +} |
| 83 | + |
| 84 | +void smokeSomedartstructwithtypedeffieldReleaseFfiHandleNullable(Pointer<Void> handle) => |
| 85 | + _smokeSomedartstructwithtypedeffieldReleaseHandleNullable(handle); |
| 86 | + |
| 87 | +// End of SomeDartStructWithTypedefField "private" section. |
| 88 | + |
| 89 | + |
0 commit comments