Skip to content

Commit 5c1bb3f

Browse files
committed
smoke tests: add example output for Dart to showcase conversion
This commit shows that conversion headers are included for typealiases usage -- in such cases conversion headers are needed. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
1 parent c40928a commit 5c1bb3f

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

gluecodium/src/test/resources/smoke/typedefs/input/TypeDefs.lime

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,8 @@ class SomeDartClassThatUsesInternal {
9999
entity: DartInternalClassWithInternalTypedef
100100
)
101101
}
102+
103+
@Skip(Java, Kotlin, Swift)
104+
struct SomeDartStructWithTypedefField {
105+
someField: GlobalListTypeDef
106+
}

gluecodium/src/test/resources/smoke/typedefs/output/dart/lib/smoke.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
export 'src/smoke/global_list_type_def.dart' show GlobalListTypeDef;
44
export 'src/smoke/global_map_type_def.dart' show GlobalMapTypeDef;
55
export 'src/smoke/some_dart_class_that_uses_internal.dart' show SomeDartClassThatUsesInternal;
6+
export 'src/smoke/some_dart_struct_with_typedef_field.dart' show SomeDartStructWithTypedefField;
67
export 'src/smoke/type_collection.dart' show TypeCollection, TypeCollection_Point, TypeCollection_PointTypeDef, TypeCollection_StorageId, TypeCollection_StructHavingAliasFieldDefinedBelow;
78
export 'src/smoke/type_defs.dart' show TypeDefs, TypeDefs$Impl, TypeDefs_ComplexTypeDef, TypeDefs_NestedIntTypeDef, TypeDefs_NestedStructTypeDef, TypeDefs_PrimitiveTypeDef, TypeDefs_StructArray, TypeDefs_StructHavingAliasFieldDefinedBelow, TypeDefs_TestStruct, TypeDefs_TestStructTypeDef;
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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

Comments
 (0)