diff --git a/CHANGELOG.md b/CHANGELOG.md index 111f64f3d0..53ebfd5f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Gluecodium project Release Notes +## Unreleased +### Bug fixes: + * Dart: removed generation of redundant `default` clause in exhaustive switch-cases for enumerations. The redundant `default` caused linter warnings. + ## 13.10.1 Release date 2024-12-12 ### Bug fixes: diff --git a/gluecodium/src/main/resources/templates/dart/DartEnumeration.mustache b/gluecodium/src/main/resources/templates/dart/DartEnumeration.mustache index b6b13fadec..fa68ab6e96 100644 --- a/gluecodium/src/main/resources/templates/dart/DartEnumeration.mustache +++ b/gluecodium/src/main/resources/templates/dart/DartEnumeration.mustache @@ -49,9 +49,11 @@ int {{resolveName "Ffi"}}ToFfi({{resolveName this "" "ref"}} value{{#if external {{#set parent=this}}{{#uniqueEnumerators}} case {{resolveName parent "" "ref"}}{{#if external.dart.converter}}Internal{{/if}}.{{resolveName}}: return {{value}}; -{{/uniqueEnumerators}}{{/set}} +{{/uniqueEnumerators}}{{/set}}{{!! +}}{{#if aliasEnumerators}} default: throw StateError("Invalid enum value $value for {{resolveName}} enum."); +{{/if}} } } diff --git a/gluecodium/src/test/resources/smoke/attributes/output/dart/lib/src/smoke/attributes_enum.dart b/gluecodium/src/test/resources/smoke/attributes/output/dart/lib/src/smoke/attributes_enum.dart index a2f27e902f..e32a0ebc13 100644 --- a/gluecodium/src/test/resources/smoke/attributes/output/dart/lib/src/smoke/attributes_enum.dart +++ b/gluecodium/src/test/resources/smoke/attributes/output/dart/lib/src/smoke/attributes_enum.dart @@ -1,19 +1,23 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + @OnEnumeration enum AttributesEnum { @OnEnumerator nope } + // AttributesEnum "private" section, not exported. + int smokeAttributesenumToFfi(AttributesEnum value) { switch (value) { case AttributesEnum.nope: return 0; - default: - throw StateError("Invalid enum value $value for AttributesEnum enum."); } } + AttributesEnum smokeAttributesenumFromFfi(int handle) { switch (handle) { case 0: @@ -22,7 +26,9 @@ AttributesEnum smokeAttributesenumFromFfi(int handle) { throw StateError("Invalid numeric value $handle for AttributesEnum enum."); } } + void smokeAttributesenumReleaseFfiHandle(int handle) {} + final _smokeAttributesenumCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -35,6 +41,7 @@ final _smokeAttributesenumGetValueNullable = __lib.catchArgumentError(() => __li Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_AttributesEnum_get_value_nullable')); + Pointer smokeAttributesenumToFfiNullable(AttributesEnum? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeAttributesenumToFfi(value); @@ -42,6 +49,7 @@ Pointer smokeAttributesenumToFfiNullable(AttributesEnum? value) { smokeAttributesenumReleaseFfiHandle(_handle); return result; } + AttributesEnum? smokeAttributesenumFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeAttributesenumGetValueNullable(handle); @@ -49,6 +57,10 @@ AttributesEnum? smokeAttributesenumFromFfiNullable(Pointer handle) { smokeAttributesenumReleaseFfiHandle(_handle); return result; } + void smokeAttributesenumReleaseFfiHandleNullable(Pointer handle) => _smokeAttributesenumReleaseHandleNullable(handle); + // End of AttributesEnum "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart index af5189fd05..af7cf744f7 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments.dart @@ -122,8 +122,6 @@ int smokeCommentsSomeenumToFfi(Comments_SomeEnum value) { return 0; case Comments_SomeEnum.useful: return 1; - default: - throw StateError("Invalid enum value $value for Comments_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments_interface.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments_interface.dart index 2c041fe59b..c18ae7377d 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments_interface.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/comments_interface.dart @@ -108,8 +108,6 @@ int smokeCommentsinterfaceSomeenumToFfi(CommentsInterface_SomeEnum value) { return 0; case CommentsInterface_SomeEnum.useful: return 1; - default: - throw StateError("Invalid enum value $value for CommentsInterface_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments.dart index f502b7a89a..8a9728f244 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments.dart @@ -73,8 +73,6 @@ int smokeDeprecationcommentsSomeenumToFfi(DeprecationComments_SomeEnum value) { switch (value) { case DeprecationComments_SomeEnum.useless: return 0; - default: - throw StateError("Invalid enum value $value for DeprecationComments_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments_only.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments_only.dart index 74bc800fdc..df7dff4a17 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments_only.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/deprecation_comments_only.dart @@ -51,8 +51,6 @@ int smokeDeprecationcommentsonlySomeenumToFfi(DeprecationCommentsOnly_SomeEnum v switch (value) { case DeprecationCommentsOnly_SomeEnum.useless: return 0; - default: - throw StateError("Invalid enum value $value for DeprecationCommentsOnly_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart index 316bc58611..a87d56bc33 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments.dart @@ -53,8 +53,6 @@ int smokeExcludedcommentsSomeenumToFfi(ExcludedComments_SomeEnum value) { switch (value) { case ExcludedComments_SomeEnum.useless: return 0; - default: - throw StateError("Invalid enum value $value for ExcludedComments_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments_only.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments_only.dart index 350dc98ea2..59cd1e6ad5 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments_only.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/excluded_comments_only.dart @@ -37,8 +37,6 @@ int smokeExcludedcommentsonlySomeenumToFfi(ExcludedCommentsOnly_SomeEnum value) switch (value) { case ExcludedCommentsOnly_SomeEnum.useless: return 0; - default: - throw StateError("Invalid enum value $value for ExcludedCommentsOnly_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/platform_comments.dart b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/platform_comments.dart index f7559e6267..bf1d87e163 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/platform_comments.dart +++ b/gluecodium/src/test/resources/smoke/comments/output/dart/lib/src/smoke/platform_comments.dart @@ -42,8 +42,6 @@ int smokePlatformcommentsSomeenumToFfi(PlatformComments_SomeEnum value) { return 0; case PlatformComments_SomeEnum.useful: return 1; - default: - throw StateError("Invalid enum value $value for PlatformComments_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants.dart b/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants.dart index 244e98ab99..9bc4becaed 100644 --- a/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants.dart +++ b/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants.dart @@ -1,29 +1,42 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + + class Constants { static final bool boolConstant = true; + static final int intConstant = -11; + static final int uintConstant = 4294967295; + static final double floatConstant = 2.71; + static final double doubleConstant = -3.14; + static final String stringConstant = "Foo bar"; + static final Constants_StateEnum enumConstant = Constants_StateEnum.on; + } + enum Constants_StateEnum { off, on } + // Constants_StateEnum "private" section, not exported. + int smokeConstantsStateenumToFfi(Constants_StateEnum value) { switch (value) { case Constants_StateEnum.off: return 0; case Constants_StateEnum.on: return 1; - default: - throw StateError("Invalid enum value $value for Constants_StateEnum enum."); } } + Constants_StateEnum smokeConstantsStateenumFromFfi(int handle) { switch (handle) { case 0: @@ -34,7 +47,9 @@ Constants_StateEnum smokeConstantsStateenumFromFfi(int handle) { throw StateError("Invalid numeric value $handle for Constants_StateEnum enum."); } } + void smokeConstantsStateenumReleaseFfiHandle(int handle) {} + final _smokeConstantsStateenumCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -47,6 +62,7 @@ final _smokeConstantsStateenumGetValueNullable = __lib.catchArgumentError(() => Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_Constants_StateEnum_get_value_nullable')); + Pointer smokeConstantsStateenumToFfiNullable(Constants_StateEnum? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeConstantsStateenumToFfi(value); @@ -54,6 +70,7 @@ Pointer smokeConstantsStateenumToFfiNullable(Constants_StateEnum? value) { smokeConstantsStateenumReleaseFfiHandle(_handle); return result; } + Constants_StateEnum? smokeConstantsStateenumFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeConstantsStateenumGetValueNullable(handle); @@ -61,10 +78,14 @@ Constants_StateEnum? smokeConstantsStateenumFromFfiNullable(Pointer handle smokeConstantsStateenumReleaseFfiHandle(_handle); return result; } + void smokeConstantsStateenumReleaseFfiHandleNullable(Pointer handle) => _smokeConstantsStateenumReleaseHandleNullable(handle); + // End of Constants_StateEnum "private" section. + // Constants "private" section, not exported. + final _smokeConstantsCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(), Pointer Function() @@ -73,10 +94,14 @@ final _smokeConstantsReleaseHandle = __lib.catchArgumentError(() => __lib.native Void Function(Pointer), void Function(Pointer) >('library_smoke_Constants_release_handle')); + + + Pointer smokeConstantsToFfi(Constants value) { final _result = _smokeConstantsCreateHandle(); return _result; } + Constants smokeConstantsFromFfi(Pointer handle) { try { return Constants( @@ -84,8 +109,11 @@ Constants smokeConstantsFromFfi(Pointer handle) { } finally { } } + void smokeConstantsReleaseFfiHandle(Pointer handle) => _smokeConstantsReleaseHandle(handle); + // Nullable Constants + final _smokeConstantsCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -98,6 +126,7 @@ final _smokeConstantsGetValueNullable = __lib.catchArgumentError(() => __lib.nat Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Constants_get_value_nullable')); + Pointer smokeConstantsToFfiNullable(Constants? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeConstantsToFfi(value); @@ -105,6 +134,7 @@ Pointer smokeConstantsToFfiNullable(Constants? value) { smokeConstantsReleaseFfiHandle(_handle); return result; } + Constants? smokeConstantsFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeConstantsGetValueNullable(handle); @@ -112,6 +142,10 @@ Constants? smokeConstantsFromFfiNullable(Pointer handle) { smokeConstantsReleaseFfiHandle(_handle); return result; } + void smokeConstantsReleaseFfiHandleNullable(Pointer handle) => _smokeConstantsReleaseHandleNullable(handle); + // End of Constants "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants_interface.dart b/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants_interface.dart index b35cff9be7..8725c41f55 100644 --- a/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants_interface.dart +++ b/gluecodium/src/test/resources/smoke/constants/output/dart/lib/src/smoke/constants_interface.dart @@ -36,8 +36,6 @@ int smokeConstantsinterfaceStateenumToFfi(ConstantsInterface_StateEnum value) { return 0; case ConstantsInterface_StateEnum.on: return 1; - default: - throw StateError("Invalid enum value $value for ConstantsInterface_StateEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/constructors/output/dart/lib/src/smoke/constructors.dart b/gluecodium/src/test/resources/smoke/constructors/output/dart/lib/src/smoke/constructors.dart index b91850524b..9dbf2ed796 100644 --- a/gluecodium/src/test/resources/smoke/constructors/output/dart/lib/src/smoke/constructors.dart +++ b/gluecodium/src/test/resources/smoke/constructors/output/dart/lib/src/smoke/constructors.dart @@ -42,8 +42,6 @@ int smokeConstructorsErrorenumToFfi(Constructors_ErrorEnum value) { return 0; case Constructors_ErrorEnum.crashed: return 1; - default: - throw StateError("Invalid enum value $value for Constructors_ErrorEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/duplicate_names/output/dart/lib/src/smoke/alphabet.dart b/gluecodium/src/test/resources/smoke/duplicate_names/output/dart/lib/src/smoke/alphabet.dart index 0f30340ffa..b678cb524a 100644 --- a/gluecodium/src/test/resources/smoke/duplicate_names/output/dart/lib/src/smoke/alphabet.dart +++ b/gluecodium/src/test/resources/smoke/duplicate_names/output/dart/lib/src/smoke/alphabet.dart @@ -1,11 +1,16 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + enum Alphabet { a, b, c } + // Alphabet "private" section, not exported. + int smokeAlphabetToFfi(Alphabet value) { switch (value) { case Alphabet.a: @@ -14,10 +19,9 @@ int smokeAlphabetToFfi(Alphabet value) { return 1; case Alphabet.c: return 2; - default: - throw StateError("Invalid enum value $value for Alphabet enum."); } } + Alphabet smokeAlphabetFromFfi(int handle) { switch (handle) { case 0: @@ -30,7 +34,9 @@ Alphabet smokeAlphabetFromFfi(int handle) { throw StateError("Invalid numeric value $handle for Alphabet enum."); } } + void smokeAlphabetReleaseFfiHandle(int handle) {} + final _smokeAlphabetCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -43,6 +49,7 @@ final _smokeAlphabetGetValueNullable = __lib.catchArgumentError(() => __lib.nati Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_Alphabet_get_value_nullable')); + Pointer smokeAlphabetToFfiNullable(Alphabet? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeAlphabetToFfi(value); @@ -50,6 +57,7 @@ Pointer smokeAlphabetToFfiNullable(Alphabet? value) { smokeAlphabetReleaseFfiHandle(_handle); return result; } + Alphabet? smokeAlphabetFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeAlphabetGetValueNullable(handle); @@ -57,6 +65,10 @@ Alphabet? smokeAlphabetFromFfiNullable(Pointer handle) { smokeAlphabetReleaseFfiHandle(_handle); return result; } + void smokeAlphabetReleaseFfiHandleNullable(Pointer handle) => _smokeAlphabetReleaseHandleNullable(handle); + // End of Alphabet "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enum_starts_with_one.dart b/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enum_starts_with_one.dart index 366751cb36..65dfed8738 100644 --- a/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enum_starts_with_one.dart +++ b/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enum_starts_with_one.dart @@ -1,20 +1,24 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + enum EnumStartsWithOne { first, second } + // EnumStartsWithOne "private" section, not exported. + int smokeEnumstartswithoneToFfi(EnumStartsWithOne value) { switch (value) { case EnumStartsWithOne.first: return 1; case EnumStartsWithOne.second: return 2; - default: - throw StateError("Invalid enum value $value for EnumStartsWithOne enum."); } } + EnumStartsWithOne smokeEnumstartswithoneFromFfi(int handle) { switch (handle) { case 1: @@ -25,7 +29,9 @@ EnumStartsWithOne smokeEnumstartswithoneFromFfi(int handle) { throw StateError("Invalid numeric value $handle for EnumStartsWithOne enum."); } } + void smokeEnumstartswithoneReleaseFfiHandle(int handle) {} + final _smokeEnumstartswithoneCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -38,6 +44,7 @@ final _smokeEnumstartswithoneGetValueNullable = __lib.catchArgumentError(() => _ Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_EnumStartsWithOne_get_value_nullable')); + Pointer smokeEnumstartswithoneToFfiNullable(EnumStartsWithOne? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeEnumstartswithoneToFfi(value); @@ -45,6 +52,7 @@ Pointer smokeEnumstartswithoneToFfiNullable(EnumStartsWithOne? value) { smokeEnumstartswithoneReleaseFfiHandle(_handle); return result; } + EnumStartsWithOne? smokeEnumstartswithoneFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeEnumstartswithoneGetValueNullable(handle); @@ -52,6 +60,10 @@ EnumStartsWithOne? smokeEnumstartswithoneFromFfiNullable(Pointer handle) { smokeEnumstartswithoneReleaseFfiHandle(_handle); return result; } + void smokeEnumstartswithoneReleaseFfiHandleNullable(Pointer handle) => _smokeEnumstartswithoneReleaseHandleNullable(handle); + // End of EnumStartsWithOne "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enums.dart b/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enums.dart index 25a60f2975..6c89f2dea1 100644 --- a/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enums.dart +++ b/gluecodium/src/test/resources/smoke/enums/output/dart/lib/src/smoke/enums.dart @@ -36,8 +36,6 @@ int smokeEnumsSimpleenumToFfi(Enums_SimpleEnum value) { return 0; case Enums_SimpleEnum.second: return 1; - default: - throw StateError("Invalid enum value $value for Enums_SimpleEnum enum."); } } @@ -100,8 +98,6 @@ int smokeEnumsInternalerrorcodeToFfi(Enums_InternalErrorCode value) { return 0; case Enums_InternalErrorCode.errorFatal: return 999; - default: - throw StateError("Invalid enum value $value for Enums_InternalErrorCode enum."); } } diff --git a/gluecodium/src/test/resources/smoke/equatable/output/dart/lib/src/smoke/equatable.dart b/gluecodium/src/test/resources/smoke/equatable/output/dart/lib/src/smoke/equatable.dart index 6336bba019..0cdfcbefaf 100644 --- a/gluecodium/src/test/resources/smoke/equatable/output/dart/lib/src/smoke/equatable.dart +++ b/gluecodium/src/test/resources/smoke/equatable/output/dart/lib/src/smoke/equatable.dart @@ -1,25 +1,31 @@ + + import 'dart:ffi'; import 'package:collection/collection.dart'; import 'package:library/src/_library_context.dart' as __lib; import 'package:library/src/builtin_types__conversion.dart'; import 'package:library/src/generic_types__conversion.dart'; + + class Equatable { } + enum Equatable_SomeEnum { foo, bar } + // Equatable_SomeEnum "private" section, not exported. + int smokeEquatableSomeenumToFfi(Equatable_SomeEnum value) { switch (value) { case Equatable_SomeEnum.foo: return 0; case Equatable_SomeEnum.bar: return 1; - default: - throw StateError("Invalid enum value $value for Equatable_SomeEnum enum."); } } + Equatable_SomeEnum smokeEquatableSomeenumFromFfi(int handle) { switch (handle) { case 0: @@ -30,7 +36,9 @@ Equatable_SomeEnum smokeEquatableSomeenumFromFfi(int handle) { throw StateError("Invalid numeric value $handle for Equatable_SomeEnum enum."); } } + void smokeEquatableSomeenumReleaseFfiHandle(int handle) {} + final _smokeEquatableSomeenumCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -43,6 +51,7 @@ final _smokeEquatableSomeenumGetValueNullable = __lib.catchArgumentError(() => _ Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_Equatable_SomeEnum_get_value_nullable')); + Pointer smokeEquatableSomeenumToFfiNullable(Equatable_SomeEnum? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeEquatableSomeenumToFfi(value); @@ -50,6 +59,7 @@ Pointer smokeEquatableSomeenumToFfiNullable(Equatable_SomeEnum? value) { smokeEquatableSomeenumReleaseFfiHandle(_handle); return result; } + Equatable_SomeEnum? smokeEquatableSomeenumFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeEquatableSomeenumGetValueNullable(handle); @@ -57,20 +67,33 @@ Equatable_SomeEnum? smokeEquatableSomeenumFromFfiNullable(Pointer handle) smokeEquatableSomeenumReleaseFfiHandle(_handle); return result; } + void smokeEquatableSomeenumReleaseFfiHandleNullable(Pointer handle) => _smokeEquatableSomeenumReleaseHandleNullable(handle); + // End of Equatable_SomeEnum "private" section. + class Equatable_EquatableStruct { bool boolField; + int intField; + int longField; + double floatField; + double doubleField; + String stringField; + Equatable_NestedEquatableStruct structField; + Equatable_SomeEnum enumField; + List arrayField; + Map mapField; + Equatable_EquatableStruct(this.boolField, this.intField, this.longField, this.floatField, this.doubleField, this.stringField, this.structField, this.enumField, this.arrayField, this.mapField); @override bool operator ==(Object other) { @@ -88,6 +111,7 @@ class Equatable_EquatableStruct { DeepCollectionEquality().equals(arrayField, _other.arrayField) && DeepCollectionEquality().equals(mapField, _other.mapField); } + @override int get hashCode { int result = 7; @@ -104,7 +128,10 @@ class Equatable_EquatableStruct { return result; } } + + // Equatable_EquatableStruct "private" section, not exported. + final _smokeEquatableEquatablestructCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint8, Int32, Int64, Float, Double, Pointer, Pointer, Uint32, Pointer, Pointer), Pointer Function(int, int, int, double, double, Pointer, Pointer, int, Pointer, Pointer) @@ -153,6 +180,9 @@ final _smokeEquatableEquatablestructGetFieldmapField = __lib.catchArgumentError( Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_EquatableStruct_get_field_mapField')); + + + Pointer smokeEquatableEquatablestructToFfi(Equatable_EquatableStruct value) { final _boolFieldHandle = booleanToFfi(value.boolField); final _intFieldHandle = (value.intField); @@ -166,6 +196,10 @@ Pointer smokeEquatableEquatablestructToFfi(Equatable_EquatableStruct value final _mapFieldHandle = foobarMapofIntToStringToFfi(value.mapField); final _result = _smokeEquatableEquatablestructCreateHandle(_boolFieldHandle, _intFieldHandle, _longFieldHandle, _floatFieldHandle, _doubleFieldHandle, _stringFieldHandle, _structFieldHandle, _enumFieldHandle, _arrayFieldHandle, _mapFieldHandle); booleanReleaseFfiHandle(_boolFieldHandle); + + + + stringReleaseFfiHandle(_stringFieldHandle); smokeEquatableNestedequatablestructReleaseFfiHandle(_structFieldHandle); smokeEquatableSomeenumReleaseFfiHandle(_enumFieldHandle); @@ -173,6 +207,7 @@ Pointer smokeEquatableEquatablestructToFfi(Equatable_EquatableStruct value foobarMapofIntToStringReleaseFfiHandle(_mapFieldHandle); return _result; } + Equatable_EquatableStruct smokeEquatableEquatablestructFromFfi(Pointer handle) { final _boolFieldHandle = _smokeEquatableEquatablestructGetFieldboolField(handle); final _intFieldHandle = _smokeEquatableEquatablestructGetFieldintField(handle); @@ -186,19 +221,23 @@ Equatable_EquatableStruct smokeEquatableEquatablestructFromFfi(Pointer han final _mapFieldHandle = _smokeEquatableEquatablestructGetFieldmapField(handle); try { return Equatable_EquatableStruct( - booleanFromFfi(_boolFieldHandle), - (_intFieldHandle), - (_longFieldHandle), - (_floatFieldHandle), - (_doubleFieldHandle), - stringFromFfi(_stringFieldHandle), - smokeEquatableNestedequatablestructFromFfi(_structFieldHandle), - smokeEquatableSomeenumFromFfi(_enumFieldHandle), - foobarListofStringFromFfi(_arrayFieldHandle), + booleanFromFfi(_boolFieldHandle), + (_intFieldHandle), + (_longFieldHandle), + (_floatFieldHandle), + (_doubleFieldHandle), + stringFromFfi(_stringFieldHandle), + smokeEquatableNestedequatablestructFromFfi(_structFieldHandle), + smokeEquatableSomeenumFromFfi(_enumFieldHandle), + foobarListofStringFromFfi(_arrayFieldHandle), foobarMapofIntToStringFromFfi(_mapFieldHandle) ); } finally { booleanReleaseFfiHandle(_boolFieldHandle); + + + + stringReleaseFfiHandle(_stringFieldHandle); smokeEquatableNestedequatablestructReleaseFfiHandle(_structFieldHandle); smokeEquatableSomeenumReleaseFfiHandle(_enumFieldHandle); @@ -206,8 +245,11 @@ Equatable_EquatableStruct smokeEquatableEquatablestructFromFfi(Pointer han foobarMapofIntToStringReleaseFfiHandle(_mapFieldHandle); } } + void smokeEquatableEquatablestructReleaseFfiHandle(Pointer handle) => _smokeEquatableEquatablestructReleaseHandle(handle); + // Nullable Equatable_EquatableStruct + final _smokeEquatableEquatablestructCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -220,6 +262,7 @@ final _smokeEquatableEquatablestructGetValueNullable = __lib.catchArgumentError( Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_EquatableStruct_get_value_nullable')); + Pointer smokeEquatableEquatablestructToFfiNullable(Equatable_EquatableStruct? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeEquatableEquatablestructToFfi(value); @@ -227,6 +270,7 @@ Pointer smokeEquatableEquatablestructToFfiNullable(Equatable_EquatableStru smokeEquatableEquatablestructReleaseFfiHandle(_handle); return result; } + Equatable_EquatableStruct? smokeEquatableEquatablestructFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeEquatableEquatablestructGetValueNullable(handle); @@ -234,19 +278,31 @@ Equatable_EquatableStruct? smokeEquatableEquatablestructFromFfiNullable(Pointer< smokeEquatableEquatablestructReleaseFfiHandle(_handle); return result; } + void smokeEquatableEquatablestructReleaseFfiHandleNullable(Pointer handle) => _smokeEquatableEquatablestructReleaseHandleNullable(handle); + // End of Equatable_EquatableStruct "private" section. + class Equatable_EquatableNullableStruct { bool? boolField; + int? intField; + int? uintField; + double? floatField; + String? stringField; + Equatable_NestedEquatableStruct? structField; + Equatable_SomeEnum? enumField; + List? arrayField; + Map? mapField; + Equatable_EquatableNullableStruct._(this.boolField, this.intField, this.uintField, this.floatField, this.stringField, this.structField, this.enumField, this.arrayField, this.mapField); Equatable_EquatableNullableStruct() : boolField = null, intField = null, uintField = null, floatField = null, stringField = null, structField = null, enumField = null, arrayField = null, mapField = null; @@ -265,6 +321,7 @@ class Equatable_EquatableNullableStruct { DeepCollectionEquality().equals(arrayField, _other.arrayField) && DeepCollectionEquality().equals(mapField, _other.mapField); } + @override int get hashCode { int result = 7; @@ -280,7 +337,10 @@ class Equatable_EquatableNullableStruct { return result; } } + + // Equatable_EquatableNullableStruct "private" section, not exported. + final _smokeEquatableEquatablenullablestructCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer), Pointer Function(Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer) @@ -325,6 +385,9 @@ final _smokeEquatableEquatablenullablestructGetFieldmapField = __lib.catchArgume Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_EquatableNullableStruct_get_field_mapField')); + + + Pointer smokeEquatableEquatablenullablestructToFfi(Equatable_EquatableNullableStruct value) { final _boolFieldHandle = booleanToFfiNullable(value.boolField); final _intFieldHandle = intToFfiNullable(value.intField); @@ -347,6 +410,7 @@ Pointer smokeEquatableEquatablenullablestructToFfi(Equatable_EquatableNull foobarMapofIntToStringReleaseFfiHandleNullable(_mapFieldHandle); return _result; } + Equatable_EquatableNullableStruct smokeEquatableEquatablenullablestructFromFfi(Pointer handle) { final _boolFieldHandle = _smokeEquatableEquatablenullablestructGetFieldboolField(handle); final _intFieldHandle = _smokeEquatableEquatablenullablestructGetFieldintField(handle); @@ -359,14 +423,14 @@ Equatable_EquatableNullableStruct smokeEquatableEquatablenullablestructFromFfi(P final _mapFieldHandle = _smokeEquatableEquatablenullablestructGetFieldmapField(handle); try { return Equatable_EquatableNullableStruct._( - booleanFromFfiNullable(_boolFieldHandle), - intFromFfiNullable(_intFieldHandle), - uShortFromFfiNullable(_uintFieldHandle), - floatFromFfiNullable(_floatFieldHandle), - stringFromFfiNullable(_stringFieldHandle), - smokeEquatableNestedequatablestructFromFfiNullable(_structFieldHandle), - smokeEquatableSomeenumFromFfiNullable(_enumFieldHandle), - foobarListofStringFromFfiNullable(_arrayFieldHandle), + booleanFromFfiNullable(_boolFieldHandle), + intFromFfiNullable(_intFieldHandle), + uShortFromFfiNullable(_uintFieldHandle), + floatFromFfiNullable(_floatFieldHandle), + stringFromFfiNullable(_stringFieldHandle), + smokeEquatableNestedequatablestructFromFfiNullable(_structFieldHandle), + smokeEquatableSomeenumFromFfiNullable(_enumFieldHandle), + foobarListofStringFromFfiNullable(_arrayFieldHandle), foobarMapofIntToStringFromFfiNullable(_mapFieldHandle) ); } finally { @@ -381,8 +445,11 @@ Equatable_EquatableNullableStruct smokeEquatableEquatablenullablestructFromFfi(P foobarMapofIntToStringReleaseFfiHandleNullable(_mapFieldHandle); } } + void smokeEquatableEquatablenullablestructReleaseFfiHandle(Pointer handle) => _smokeEquatableEquatablenullablestructReleaseHandle(handle); + // Nullable Equatable_EquatableNullableStruct + final _smokeEquatableEquatablenullablestructCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -395,6 +462,7 @@ final _smokeEquatableEquatablenullablestructGetValueNullable = __lib.catchArgume Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_EquatableNullableStruct_get_value_nullable')); + Pointer smokeEquatableEquatablenullablestructToFfiNullable(Equatable_EquatableNullableStruct? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeEquatableEquatablenullablestructToFfi(value); @@ -402,6 +470,7 @@ Pointer smokeEquatableEquatablenullablestructToFfiNullable(Equatable_Equat smokeEquatableEquatablenullablestructReleaseFfiHandle(_handle); return result; } + Equatable_EquatableNullableStruct? smokeEquatableEquatablenullablestructFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeEquatableEquatablenullablestructGetValueNullable(handle); @@ -409,11 +478,15 @@ Equatable_EquatableNullableStruct? smokeEquatableEquatablenullablestructFromFfiN smokeEquatableEquatablenullablestructReleaseFfiHandle(_handle); return result; } + void smokeEquatableEquatablenullablestructReleaseFfiHandleNullable(Pointer handle) => _smokeEquatableEquatablenullablestructReleaseHandleNullable(handle); + // End of Equatable_EquatableNullableStruct "private" section. + class Equatable_NestedEquatableStruct { String fooField; + Equatable_NestedEquatableStruct(this.fooField); @override bool operator ==(Object other) { @@ -422,6 +495,7 @@ class Equatable_NestedEquatableStruct { Equatable_NestedEquatableStruct _other = other; return fooField == _other.fooField; } + @override int get hashCode { int result = 7; @@ -429,7 +503,10 @@ class Equatable_NestedEquatableStruct { return result; } } + + // Equatable_NestedEquatableStruct "private" section, not exported. + final _smokeEquatableNestedequatablestructCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -442,12 +519,16 @@ final _smokeEquatableNestedequatablestructGetFieldfooField = __lib.catchArgument Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_NestedEquatableStruct_get_field_fooField')); + + + Pointer smokeEquatableNestedequatablestructToFfi(Equatable_NestedEquatableStruct value) { final _fooFieldHandle = stringToFfi(value.fooField); final _result = _smokeEquatableNestedequatablestructCreateHandle(_fooFieldHandle); stringReleaseFfiHandle(_fooFieldHandle); return _result; } + Equatable_NestedEquatableStruct smokeEquatableNestedequatablestructFromFfi(Pointer handle) { final _fooFieldHandle = _smokeEquatableNestedequatablestructGetFieldfooField(handle); try { @@ -458,8 +539,11 @@ Equatable_NestedEquatableStruct smokeEquatableNestedequatablestructFromFfi(Point stringReleaseFfiHandle(_fooFieldHandle); } } + void smokeEquatableNestedequatablestructReleaseFfiHandle(Pointer handle) => _smokeEquatableNestedequatablestructReleaseHandle(handle); + // Nullable Equatable_NestedEquatableStruct + final _smokeEquatableNestedequatablestructCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -472,6 +556,7 @@ final _smokeEquatableNestedequatablestructGetValueNullable = __lib.catchArgument Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_NestedEquatableStruct_get_value_nullable')); + Pointer smokeEquatableNestedequatablestructToFfiNullable(Equatable_NestedEquatableStruct? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeEquatableNestedequatablestructToFfi(value); @@ -479,6 +564,7 @@ Pointer smokeEquatableNestedequatablestructToFfiNullable(Equatable_NestedE smokeEquatableNestedequatablestructReleaseFfiHandle(_handle); return result; } + Equatable_NestedEquatableStruct? smokeEquatableNestedequatablestructFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeEquatableNestedequatablestructGetValueNullable(handle); @@ -486,10 +572,14 @@ Equatable_NestedEquatableStruct? smokeEquatableNestedequatablestructFromFfiNulla smokeEquatableNestedequatablestructReleaseFfiHandle(_handle); return result; } + void smokeEquatableNestedequatablestructReleaseFfiHandleNullable(Pointer handle) => _smokeEquatableNestedequatablestructReleaseHandleNullable(handle); + // End of Equatable_NestedEquatableStruct "private" section. + // Equatable "private" section, not exported. + final _smokeEquatableCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(), Pointer Function() @@ -498,10 +588,14 @@ final _smokeEquatableReleaseHandle = __lib.catchArgumentError(() => __lib.native Void Function(Pointer), void Function(Pointer) >('library_smoke_Equatable_release_handle')); + + + Pointer smokeEquatableToFfi(Equatable value) { final _result = _smokeEquatableCreateHandle(); return _result; } + Equatable smokeEquatableFromFfi(Pointer handle) { try { return Equatable( @@ -509,8 +603,11 @@ Equatable smokeEquatableFromFfi(Pointer handle) { } finally { } } + void smokeEquatableReleaseFfiHandle(Pointer handle) => _smokeEquatableReleaseHandle(handle); + // Nullable Equatable + final _smokeEquatableCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -523,6 +620,7 @@ final _smokeEquatableGetValueNullable = __lib.catchArgumentError(() => __lib.nat Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_Equatable_get_value_nullable')); + Pointer smokeEquatableToFfiNullable(Equatable? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeEquatableToFfi(value); @@ -530,6 +628,7 @@ Pointer smokeEquatableToFfiNullable(Equatable? value) { smokeEquatableReleaseFfiHandle(_handle); return result; } + Equatable? smokeEquatableFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeEquatableGetValueNullable(handle); @@ -537,6 +636,10 @@ Equatable? smokeEquatableFromFfiNullable(Pointer handle) { smokeEquatableReleaseFfiHandle(_handle); return result; } + void smokeEquatableReleaseFfiHandleNullable(Pointer handle) => _smokeEquatableReleaseHandleNullable(handle); + // End of Equatable "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors.dart b/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors.dart index c5434ac919..c0ba967873 100644 --- a/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors.dart +++ b/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors.dart @@ -40,8 +40,6 @@ int smokeErrorsInternalerrorcodeToFfi(Errors_InternalErrorCode value) { return 0; case Errors_InternalErrorCode.errorFatal: return 1; - default: - throw StateError("Invalid enum value $value for Errors_InternalErrorCode enum."); } } @@ -107,8 +105,6 @@ int smokeErrorsExternalerrorsToFfi(Errors_ExternalErrors value) { return 1; case Errors_ExternalErrors.bust: return 2; - default: - throw StateError("Invalid enum value $value for Errors_ExternalErrors enum."); } } diff --git a/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors_interface.dart b/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors_interface.dart index 7eb1e2b8d3..80a78c0efb 100644 --- a/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors_interface.dart +++ b/gluecodium/src/test/resources/smoke/errors/output/dart/lib/src/smoke/errors_interface.dart @@ -53,8 +53,6 @@ int smokeErrorsinterfaceInternalerrorToFfi(ErrorsInterface_InternalError value) return 0; case ErrorsInterface_InternalError.errorFatal: return 1; - default: - throw StateError("Invalid enum value $value for ErrorsInterface_InternalError enum."); } } @@ -120,8 +118,6 @@ int smokeErrorsinterfaceExternalerrorsToFfi(ErrorsInterface_ExternalErrors value return 1; case ErrorsInterface_ExternalErrors.bust: return 2; - default: - throw StateError("Invalid enum value $value for ErrorsInterface_ExternalErrors enum."); } } diff --git a/gluecodium/src/test/resources/smoke/escaped_names/output/dart/lib/src/package/types.dart b/gluecodium/src/test/resources/smoke/escaped_names/output/dart/lib/src/package/types.dart index 7975f58627..e339888b0d 100644 --- a/gluecodium/src/test/resources/smoke/escaped_names/output/dart/lib/src/package/types.dart +++ b/gluecodium/src/test/resources/smoke/escaped_names/output/dart/lib/src/package/types.dart @@ -1,20 +1,27 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + + class Types { static final Types_Enum Const = Types_Enum.naN; + } + enum Types_Enum { naN } + // Types_Enum "private" section, not exported. + int packageTypesEnumToFfi(Types_Enum value) { switch (value) { case Types_Enum.naN: return 0; - default: - throw StateError("Invalid enum value $value for Types_Enum enum."); } } + Types_Enum packageTypesEnumFromFfi(int handle) { switch (handle) { case 0: @@ -23,7 +30,9 @@ Types_Enum packageTypesEnumFromFfi(int handle) { throw StateError("Invalid numeric value $handle for Types_Enum enum."); } } + void packageTypesEnumReleaseFfiHandle(int handle) {} + final _packageTypesEnumCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -36,6 +45,7 @@ final _packageTypesEnumGetValueNullable = __lib.catchArgumentError(() => __lib.n Uint32 Function(Pointer), int Function(Pointer) >('library_package_Types_Enum_get_value_nullable')); + Pointer packageTypesEnumToFfiNullable(Types_Enum? value) { if (value == null) return Pointer.fromAddress(0); final _handle = packageTypesEnumToFfi(value); @@ -43,6 +53,7 @@ Pointer packageTypesEnumToFfiNullable(Types_Enum? value) { packageTypesEnumReleaseFfiHandle(_handle); return result; } + Types_Enum? packageTypesEnumFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _packageTypesEnumGetValueNullable(handle); @@ -50,20 +61,27 @@ Types_Enum? packageTypesEnumFromFfiNullable(Pointer handle) { packageTypesEnumReleaseFfiHandle(_handle); return result; } + void packageTypesEnumReleaseFfiHandleNullable(Pointer handle) => _packageTypesEnumReleaseHandleNullable(handle); + // End of Types_Enum "private" section. class Types_ExceptionException implements Exception { final Types_Enum error; Types_ExceptionException(this.error); } + class Types_Struct { Types_Enum null; + Types_Struct._(this.null); Types_Struct() : null = Types_Enum.naN; } + + // Types_Struct "private" section, not exported. + final _packageTypesStructCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -76,12 +94,16 @@ final _packageTypesStructGetFieldnull = __lib.catchArgumentError(() => __lib.nat Uint32 Function(Pointer), int Function(Pointer) >('library_package_Types_Struct_get_field_null')); + + + Pointer packageTypesStructToFfi(Types_Struct value) { final _nullHandle = packageTypesEnumToFfi(value.null); final _result = _packageTypesStructCreateHandle(_nullHandle); packageTypesEnumReleaseFfiHandle(_nullHandle); return _result; } + Types_Struct packageTypesStructFromFfi(Pointer handle) { final _nullHandle = _packageTypesStructGetFieldnull(handle); try { @@ -92,8 +114,11 @@ Types_Struct packageTypesStructFromFfi(Pointer handle) { packageTypesEnumReleaseFfiHandle(_nullHandle); } } + void packageTypesStructReleaseFfiHandle(Pointer handle) => _packageTypesStructReleaseHandle(handle); + // Nullable Types_Struct + final _packageTypesStructCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -106,6 +131,7 @@ final _packageTypesStructGetValueNullable = __lib.catchArgumentError(() => __lib Pointer Function(Pointer), Pointer Function(Pointer) >('library_package_Types_Struct_get_value_nullable')); + Pointer packageTypesStructToFfiNullable(Types_Struct? value) { if (value == null) return Pointer.fromAddress(0); final _handle = packageTypesStructToFfi(value); @@ -113,6 +139,7 @@ Pointer packageTypesStructToFfiNullable(Types_Struct? value) { packageTypesStructReleaseFfiHandle(_handle); return result; } + Types_Struct? packageTypesStructFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _packageTypesStructGetValueNullable(handle); @@ -120,10 +147,14 @@ Types_Struct? packageTypesStructFromFfiNullable(Pointer handle) { packageTypesStructReleaseFfiHandle(_handle); return result; } + void packageTypesStructReleaseFfiHandleNullable(Pointer handle) => _packageTypesStructReleaseHandleNullable(handle); + // End of Types_Struct "private" section. + // Types "private" section, not exported. + final _packageTypesCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(), Pointer Function() @@ -132,10 +163,14 @@ final _packageTypesReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLi Void Function(Pointer), void Function(Pointer) >('library_package_Types_release_handle')); + + + Pointer packageTypesToFfi(Types value) { final _result = _packageTypesCreateHandle(); return _result; } + Types packageTypesFromFfi(Pointer handle) { try { return Types( @@ -143,8 +178,11 @@ Types packageTypesFromFfi(Pointer handle) { } finally { } } + void packageTypesReleaseFfiHandle(Pointer handle) => _packageTypesReleaseHandle(handle); + // Nullable Types + final _packageTypesCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -157,6 +195,7 @@ final _packageTypesGetValueNullable = __lib.catchArgumentError(() => __lib.nativ Pointer Function(Pointer), Pointer Function(Pointer) >('library_package_Types_get_value_nullable')); + Pointer packageTypesToFfiNullable(Types? value) { if (value == null) return Pointer.fromAddress(0); final _handle = packageTypesToFfi(value); @@ -164,6 +203,7 @@ Pointer packageTypesToFfiNullable(Types? value) { packageTypesReleaseFfiHandle(_handle); return result; } + Types? packageTypesFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _packageTypesGetValueNullable(handle); @@ -171,6 +211,10 @@ Types? packageTypesFromFfiNullable(Pointer handle) { packageTypesReleaseFfiHandle(_handle); return result; } + void packageTypesReleaseFfiHandleNullable(Pointer handle) => _packageTypesReleaseHandleNullable(handle); + // End of Types "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/enums.dart b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/enums.dart index c61a593cb7..2df57f3bcd 100644 --- a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/enums.dart +++ b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/enums.dart @@ -29,8 +29,6 @@ int smokeEnumsExternalenumToFfi(Enums_ExternalEnum value) { return 0; case Enums_ExternalEnum.barValue: return 1; - default: - throw StateError("Invalid enum value $value for Enums_ExternalEnum enum."); } } @@ -93,8 +91,6 @@ int smokeEnumsVeryexternalenumToFfi(Enums_VeryExternalEnum value) { return 0; case Enums_VeryExternalEnum.bar: return 1; - default: - throw StateError("Invalid enum value $value for Enums_VeryExternalEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_class.dart b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_class.dart index d59c0c53c7..47e718ce9c 100644 --- a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_class.dart +++ b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_class.dart @@ -24,8 +24,6 @@ int smokeExternalclassSomeenumToFfi(ExternalClass_SomeEnum value) { switch (value) { case ExternalClass_SomeEnum.someValue: return 0; - default: - throw StateError("Invalid enum value $value for ExternalClass_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_interface.dart b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_interface.dart index 7a5bd80180..1623ed6831 100644 --- a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_interface.dart +++ b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/external_interface.dart @@ -33,8 +33,6 @@ int smokeExternalinterfaceSomeenumToFfi(ExternalInterface_SomeEnum value) { switch (value) { case ExternalInterface_SomeEnum.someValue: return 0; - default: - throw StateError("Invalid enum value $value for ExternalInterface_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/http_client_response_compression_state.dart b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/http_client_response_compression_state.dart index 01d0153bb1..ccd2213133 100644 --- a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/http_client_response_compression_state.dart +++ b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/http_client_response_compression_state.dart @@ -1,7 +1,12 @@ + + import 'dart:ffi'; import 'package:foo/bar.dart' as bar; import 'package:library/src/_library_context.dart' as __lib; + + // HttpClientResponseCompressionState "private" section, not exported. + int smokeCompressionstateToFfi(bar.HttpClientResponseCompressionState value) { switch (value) { case bar.HttpClientResponseCompressionState.compressed: @@ -10,10 +15,9 @@ int smokeCompressionstateToFfi(bar.HttpClientResponseCompressionState value) { return 1; case bar.HttpClientResponseCompressionState.notCompressed: return 2; - default: - throw StateError("Invalid enum value $value for HttpClientResponseCompressionState enum."); } } + bar.HttpClientResponseCompressionState smokeCompressionstateFromFfi(int handle) { switch (handle) { case 0: @@ -26,7 +30,9 @@ bar.HttpClientResponseCompressionState smokeCompressionstateFromFfi(int handle) throw StateError("Invalid numeric value $handle for HttpClientResponseCompressionState enum."); } } + void smokeCompressionstateReleaseFfiHandle(int handle) {} + final _smokeCompressionstateCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -39,6 +45,7 @@ final _smokeCompressionstateGetValueNullable = __lib.catchArgumentError(() => __ Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_CompressionState_get_value_nullable')); + Pointer smokeCompressionstateToFfiNullable(bar.HttpClientResponseCompressionState? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeCompressionstateToFfi(value); @@ -46,6 +53,7 @@ Pointer smokeCompressionstateToFfiNullable(bar.HttpClientResponseCompressi smokeCompressionstateReleaseFfiHandle(_handle); return result; } + bar.HttpClientResponseCompressionState? smokeCompressionstateFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeCompressionstateGetValueNullable(handle); @@ -53,6 +61,10 @@ bar.HttpClientResponseCompressionState? smokeCompressionstateFromFfiNullable(Poi smokeCompressionstateReleaseFfiHandle(_handle); return result; } + void smokeCompressionstateReleaseFfiHandleNullable(Pointer handle) => _smokeCompressionstateReleaseHandleNullable(handle); + // End of HttpClientResponseCompressionState "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/string.dart b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/string.dart index 51d4db0f7a..4cd83ed240 100644 --- a/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/string.dart +++ b/gluecodium/src/test/resources/smoke/external_types/output/dart/lib/src/smoke/string.dart @@ -1,13 +1,18 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; import '../season_converter.dart'; + enum StringInternal { winter, spring, summer, autumn } + // String "private" section, not exported. + int smokeDartseasonToFfi(String valueExternal) { final value = SeasonConverter.convertToInternal(valueExternal); switch (value) { @@ -19,10 +24,9 @@ int smokeDartseasonToFfi(String valueExternal) { return 2; case StringInternal.autumn: return 3; - default: - throw StateError("Invalid enum value $value for String enum."); } } + String smokeDartseasonFromFfi(int handle) { switch (handle) { case 0: @@ -37,7 +41,9 @@ String smokeDartseasonFromFfi(int handle) { throw StateError("Invalid numeric value $handle for String enum."); } } + void smokeDartseasonReleaseFfiHandle(int handle) {} + final _smokeDartseasonCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -50,6 +56,7 @@ final _smokeDartseasonGetValueNullable = __lib.catchArgumentError(() => __lib.na Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_DartSeason_get_value_nullable')); + Pointer smokeDartseasonToFfiNullable(String? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeDartseasonToFfi(value); @@ -57,6 +64,7 @@ Pointer smokeDartseasonToFfiNullable(String? value) { smokeDartseasonReleaseFfiHandle(_handle); return result; } + String? smokeDartseasonFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeDartseasonGetValueNullable(handle); @@ -64,6 +72,10 @@ String? smokeDartseasonFromFfiNullable(Pointer handle) { smokeDartseasonReleaseFfiHandle(_handle); return result; } + void smokeDartseasonReleaseFfiHandleNullable(Pointer handle) => _smokeDartseasonReleaseHandleNullable(handle); + // End of String "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/field_constructors/output/dart/lib/src/smoke/field_constructors_nullable_types.dart b/gluecodium/src/test/resources/smoke/field_constructors/output/dart/lib/src/smoke/field_constructors_nullable_types.dart index 058e072ad8..831a503ac1 100644 --- a/gluecodium/src/test/resources/smoke/field_constructors/output/dart/lib/src/smoke/field_constructors_nullable_types.dart +++ b/gluecodium/src/test/resources/smoke/field_constructors/output/dart/lib/src/smoke/field_constructors_nullable_types.dart @@ -1,6 +1,9 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + class FieldConstructorsNullableTypes { FieldConstructorsNullableTypes_StructWithParameters? nullableField; @@ -22,8 +25,6 @@ int smokeFieldconstructorsnullabletypesFoodtypeToFfi(FieldConstructorsNullableTy return 0; case FieldConstructorsNullableTypes_FoodType.fruits: return 1; - default: - throw StateError("Invalid enum value $value for FieldConstructorsNullableTypes_FoodType enum."); } } @@ -225,4 +226,6 @@ FieldConstructorsNullableTypes? smokeFieldconstructorsnullabletypesFromFfiNullab void smokeFieldconstructorsnullabletypesReleaseFfiHandleNullable(Pointer handle) => _smokeFieldconstructorsnullabletypesReleaseHandleNullable(handle); -// End of FieldConstructorsNullableTypes "private" section. \ No newline at end of file +// End of FieldConstructorsNullableTypes "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/generic_types/output/dart/lib/src/smoke/generic_types_with_compound_types.dart b/gluecodium/src/test/resources/smoke/generic_types/output/dart/lib/src/smoke/generic_types_with_compound_types.dart index e7b0201720..61ecd3080c 100644 --- a/gluecodium/src/test/resources/smoke/generic_types/output/dart/lib/src/smoke/generic_types_with_compound_types.dart +++ b/gluecodium/src/test/resources/smoke/generic_types/output/dart/lib/src/smoke/generic_types_with_compound_types.dart @@ -42,8 +42,6 @@ int smokeGenerictypeswithcompoundtypesSomeenumToFfi(GenericTypesWithCompoundType return 0; case GenericTypesWithCompoundTypes_SomeEnum.bar: return 1; - default: - throw StateError("Invalid enum value $value for GenericTypesWithCompoundTypes_SomeEnum enum."); } } @@ -106,8 +104,6 @@ int smokeGenerictypeswithcompoundtypesExternalenumToFfi(GenericTypesWithCompound return 0; case GenericTypesWithCompoundTypes_ExternalEnum.off: return 1; - default: - throw StateError("Invalid enum value $value for GenericTypesWithCompoundTypes_ExternalEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listener_with_properties.dart b/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listener_with_properties.dart index 28a7632dc5..4bb04bd191 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listener_with_properties.dart +++ b/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listener_with_properties.dart @@ -80,8 +80,6 @@ int smokeListenerwithpropertiesResultenumToFfi(ListenerWithProperties_ResultEnum return 0; case ListenerWithProperties_ResultEnum.result: return 1; - default: - throw StateError("Invalid enum value $value for ListenerWithProperties_ResultEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listeners_with_return_values.dart b/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listeners_with_return_values.dart index 17593a6007..ac227e0001 100644 --- a/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listeners_with_return_values.dart +++ b/gluecodium/src/test/resources/smoke/listeners/output/dart/lib/src/smoke/listeners_with_return_values.dart @@ -60,8 +60,6 @@ int smokeListenerswithreturnvaluesResultenumToFfi(ListenersWithReturnValues_Resu return 0; case ListenersWithReturnValues_ResultEnum.result: return 1; - default: - throw StateError("Invalid enum value $value for ListenersWithReturnValues_ResultEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/free_enum.dart b/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/free_enum.dart index 779cc5631b..72d28246b3 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/free_enum.dart +++ b/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/free_enum.dart @@ -1,20 +1,24 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + enum FreeEnum { foo, bar } + // FreeEnum "private" section, not exported. + int smokeFreeenumToFfi(FreeEnum value) { switch (value) { case FreeEnum.foo: return 0; case FreeEnum.bar: return 1; - default: - throw StateError("Invalid enum value $value for FreeEnum enum."); } } + FreeEnum smokeFreeenumFromFfi(int handle) { switch (handle) { case 0: @@ -25,7 +29,9 @@ FreeEnum smokeFreeenumFromFfi(int handle) { throw StateError("Invalid numeric value $handle for FreeEnum enum."); } } + void smokeFreeenumReleaseFfiHandle(int handle) {} + final _smokeFreeenumCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -38,6 +44,7 @@ final _smokeFreeenumGetValueNullable = __lib.catchArgumentError(() => __lib.nati Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_FreeEnum_get_value_nullable')); + Pointer smokeFreeenumToFfiNullable(FreeEnum? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeFreeenumToFfi(value); @@ -45,6 +52,7 @@ Pointer smokeFreeenumToFfiNullable(FreeEnum? value) { smokeFreeenumReleaseFfiHandle(_handle); return result; } + FreeEnum? smokeFreeenumFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeFreeenumGetValueNullable(handle); @@ -52,6 +60,10 @@ FreeEnum? smokeFreeenumFromFfiNullable(Pointer handle) { smokeFreeenumReleaseFfiHandle(_handle); return result; } + void smokeFreeenumReleaseFfiHandleNullable(Pointer handle) => _smokeFreeenumReleaseHandleNullable(handle); + // End of FreeEnum "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/level_one.dart b/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/level_one.dart index cc21022c99..87aba900d9 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/level_one.dart +++ b/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/level_one.dart @@ -33,8 +33,6 @@ int smokeLeveloneLeveltwoLevelthreeLevelfourenumToFfi(LevelOne_LevelTwo_LevelThr switch (value) { case LevelOne_LevelTwo_LevelThree_LevelFourEnum.none: return 0; - default: - throw StateError("Invalid enum value $value for LevelOne_LevelTwo_LevelThree_LevelFourEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/outer_struct.dart b/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/outer_struct.dart index f5048ce587..da0b5d386c 100644 --- a/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/outer_struct.dart +++ b/gluecodium/src/test/resources/smoke/nesting/output/dart/lib/src/smoke/outer_struct.dart @@ -51,8 +51,6 @@ int smokeOuterstructInnerenumToFfi(OuterStruct_InnerEnum value) { return 0; case OuterStruct_InnerEnum.bar: return 1; - default: - throw StateError("Invalid enum value $value for OuterStruct_InnerEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/nullable/output/dart/lib/src/smoke/nullable.dart b/gluecodium/src/test/resources/smoke/nullable/output/dart/lib/src/smoke/nullable.dart index c9c199f322..26cca8abc4 100644 --- a/gluecodium/src/test/resources/smoke/nullable/output/dart/lib/src/smoke/nullable.dart +++ b/gluecodium/src/test/resources/smoke/nullable/output/dart/lib/src/smoke/nullable.dart @@ -75,8 +75,6 @@ int smokeNullableSomeenumToFfi(Nullable_SomeEnum value) { return 0; case Nullable_SomeEnum.off: return 1; - default: - throw StateError("Invalid enum value $value for Nullable_SomeEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/platform_names/output/dart/lib/src/smoke/wee_types.dart b/gluecodium/src/test/resources/smoke/platform_names/output/dart/lib/src/smoke/wee_types.dart index 092a30e98c..c645427b96 100644 --- a/gluecodium/src/test/resources/smoke/platform_names/output/dart/lib/src/smoke/wee_types.dart +++ b/gluecodium/src/test/resources/smoke/platform_names/output/dart/lib/src/smoke/wee_types.dart @@ -1,21 +1,27 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; import 'package:library/src/builtin_types__conversion.dart'; import 'package:meta/meta.dart'; + + class weeTypes { } + enum weeTypes_werrEnum { WEE_ITEM } + // weeTypes_werrEnum "private" section, not exported. + int smokePlatformnamesBasicenumToFfi(weeTypes_werrEnum value) { switch (value) { case weeTypes_werrEnum.WEE_ITEM: return 0; - default: - throw StateError("Invalid enum value $value for weeTypes_werrEnum enum."); } } + weeTypes_werrEnum smokePlatformnamesBasicenumFromFfi(int handle) { switch (handle) { case 0: @@ -24,7 +30,9 @@ weeTypes_werrEnum smokePlatformnamesBasicenumFromFfi(int handle) { throw StateError("Invalid numeric value $handle for weeTypes_werrEnum enum."); } } + void smokePlatformnamesBasicenumReleaseFfiHandle(int handle) {} + final _smokePlatformnamesBasicenumCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -37,6 +45,7 @@ final _smokePlatformnamesBasicenumGetValueNullable = __lib.catchArgumentError(() Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_PlatformNames_BasicEnum_get_value_nullable')); + Pointer smokePlatformnamesBasicenumToFfiNullable(weeTypes_werrEnum? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokePlatformnamesBasicenumToFfi(value); @@ -44,6 +53,7 @@ Pointer smokePlatformnamesBasicenumToFfiNullable(weeTypes_werrEnum? value) smokePlatformnamesBasicenumReleaseFfiHandle(_handle); return result; } + weeTypes_werrEnum? smokePlatformnamesBasicenumFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokePlatformnamesBasicenumGetValueNullable(handle); @@ -51,18 +61,28 @@ weeTypes_werrEnum? smokePlatformnamesBasicenumFromFfiNullable(Pointer hand smokePlatformnamesBasicenumReleaseFfiHandle(_handle); return result; } + void smokePlatformnamesBasicenumReleaseFfiHandleNullable(Pointer handle) => _smokePlatformnamesBasicenumReleaseHandleNullable(handle); + // End of weeTypes_werrEnum "private" section. + + class weeTypes_weeStruct { String WEE_FIELD; + weeTypes_weeStruct._(this.WEE_FIELD); + factory weeTypes_weeStruct.WeeCreate(String WeeParameter) => $prototype.WeeCreate(WeeParameter); + /// @nodoc @visibleForTesting static dynamic $prototype = weeTypes_weeStruct$Impl(); } + + // weeTypes_weeStruct "private" section, not exported. + final _smokePlatformnamesBasicstructCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -75,6 +95,9 @@ final _smokePlatformnamesBasicstructGetFieldstringField = __lib.catchArgumentErr Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_PlatformNames_BasicStruct_get_field_stringField')); + + + /// @nodoc @visibleForTesting class weeTypes_weeStruct$Impl { @@ -87,15 +110,20 @@ class weeTypes_weeStruct$Impl { return smokePlatformnamesBasicstructFromFfi(__resultHandle); } finally { smokePlatformnamesBasicstructReleaseFfiHandle(__resultHandle); + } + } + } + Pointer smokePlatformnamesBasicstructToFfi(weeTypes_weeStruct value) { final _WEE_FIELDHandle = stringToFfi(value.WEE_FIELD); final _result = _smokePlatformnamesBasicstructCreateHandle(_WEE_FIELDHandle); stringReleaseFfiHandle(_WEE_FIELDHandle); return _result; } + weeTypes_weeStruct smokePlatformnamesBasicstructFromFfi(Pointer handle) { final _WEE_FIELDHandle = _smokePlatformnamesBasicstructGetFieldstringField(handle); try { @@ -106,8 +134,11 @@ weeTypes_weeStruct smokePlatformnamesBasicstructFromFfi(Pointer handle) { stringReleaseFfiHandle(_WEE_FIELDHandle); } } + void smokePlatformnamesBasicstructReleaseFfiHandle(Pointer handle) => _smokePlatformnamesBasicstructReleaseHandle(handle); + // Nullable weeTypes_weeStruct + final _smokePlatformnamesBasicstructCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -120,6 +151,7 @@ final _smokePlatformnamesBasicstructGetValueNullable = __lib.catchArgumentError( Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_PlatformNames_BasicStruct_get_value_nullable')); + Pointer smokePlatformnamesBasicstructToFfiNullable(weeTypes_weeStruct? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokePlatformnamesBasicstructToFfi(value); @@ -127,6 +159,7 @@ Pointer smokePlatformnamesBasicstructToFfiNullable(weeTypes_weeStruct? val smokePlatformnamesBasicstructReleaseFfiHandle(_handle); return result; } + weeTypes_weeStruct? smokePlatformnamesBasicstructFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokePlatformnamesBasicstructGetValueNullable(handle); @@ -134,10 +167,14 @@ weeTypes_weeStruct? smokePlatformnamesBasicstructFromFfiNullable(Pointer h smokePlatformnamesBasicstructReleaseFfiHandle(_handle); return result; } + void smokePlatformnamesBasicstructReleaseFfiHandleNullable(Pointer handle) => _smokePlatformnamesBasicstructReleaseHandleNullable(handle); + // End of weeTypes_weeStruct "private" section. + // weeTypes "private" section, not exported. + final _smokePlatformnamesCreateHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(), Pointer Function() @@ -146,10 +183,14 @@ final _smokePlatformnamesReleaseHandle = __lib.catchArgumentError(() => __lib.na Void Function(Pointer), void Function(Pointer) >('library_smoke_PlatformNames_release_handle')); + + + Pointer smokePlatformnamesToFfi(weeTypes value) { final _result = _smokePlatformnamesCreateHandle(); return _result; } + weeTypes smokePlatformnamesFromFfi(Pointer handle) { try { return weeTypes( @@ -157,8 +198,11 @@ weeTypes smokePlatformnamesFromFfi(Pointer handle) { } finally { } } + void smokePlatformnamesReleaseFfiHandle(Pointer handle) => _smokePlatformnamesReleaseHandle(handle); + // Nullable weeTypes + final _smokePlatformnamesCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Pointer), Pointer Function(Pointer) @@ -171,6 +215,7 @@ final _smokePlatformnamesGetValueNullable = __lib.catchArgumentError(() => __lib Pointer Function(Pointer), Pointer Function(Pointer) >('library_smoke_PlatformNames_get_value_nullable')); + Pointer smokePlatformnamesToFfiNullable(weeTypes? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokePlatformnamesToFfi(value); @@ -178,6 +223,7 @@ Pointer smokePlatformnamesToFfiNullable(weeTypes? value) { smokePlatformnamesReleaseFfiHandle(_handle); return result; } + weeTypes? smokePlatformnamesFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokePlatformnamesGetValueNullable(handle); @@ -185,6 +231,10 @@ weeTypes? smokePlatformnamesFromFfiNullable(Pointer handle) { smokePlatformnamesReleaseFfiHandle(_handle); return result; } + void smokePlatformnamesReleaseFfiHandleNullable(Pointer handle) => _smokePlatformnamesReleaseHandleNullable(handle); + // End of weeTypes "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/properties/output/dart/lib/src/smoke/properties.dart b/gluecodium/src/test/resources/smoke/properties/output/dart/lib/src/smoke/properties.dart index 8d654fbd04..d696b85425 100644 --- a/gluecodium/src/test/resources/smoke/properties/output/dart/lib/src/smoke/properties.dart +++ b/gluecodium/src/test/resources/smoke/properties/output/dart/lib/src/smoke/properties.dart @@ -59,8 +59,6 @@ int smokePropertiesInternalerrorcodeToFfi(Properties_InternalErrorCode value) { return 0; case Properties_InternalErrorCode.errorFatal: return 999; - default: - throw StateError("Invalid enum value $value for Properties_InternalErrorCode enum."); } } diff --git a/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_auto_tag.dart b/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_auto_tag.dart index aae8e43990..720ca04f90 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_auto_tag.dart +++ b/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_auto_tag.dart @@ -1,20 +1,24 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + enum SkipEnumeratorAutoTag { one, three } + // SkipEnumeratorAutoTag "private" section, not exported. + int smokeSkipenumeratorautotagToFfi(SkipEnumeratorAutoTag value) { switch (value) { case SkipEnumeratorAutoTag.one: return 0; case SkipEnumeratorAutoTag.three: return 1; - default: - throw StateError("Invalid enum value $value for SkipEnumeratorAutoTag enum."); } } + SkipEnumeratorAutoTag smokeSkipenumeratorautotagFromFfi(int handle) { switch (handle) { case 0: @@ -25,7 +29,9 @@ SkipEnumeratorAutoTag smokeSkipenumeratorautotagFromFfi(int handle) { throw StateError("Invalid numeric value $handle for SkipEnumeratorAutoTag enum."); } } + void smokeSkipenumeratorautotagReleaseFfiHandle(int handle) {} + final _smokeSkipenumeratorautotagCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -38,6 +44,7 @@ final _smokeSkipenumeratorautotagGetValueNullable = __lib.catchArgumentError(() Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_SkipEnumeratorAutoTag_get_value_nullable')); + Pointer smokeSkipenumeratorautotagToFfiNullable(SkipEnumeratorAutoTag? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeSkipenumeratorautotagToFfi(value); @@ -45,6 +52,7 @@ Pointer smokeSkipenumeratorautotagToFfiNullable(SkipEnumeratorAutoTag? val smokeSkipenumeratorautotagReleaseFfiHandle(_handle); return result; } + SkipEnumeratorAutoTag? smokeSkipenumeratorautotagFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeSkipenumeratorautotagGetValueNullable(handle); @@ -52,6 +60,10 @@ SkipEnumeratorAutoTag? smokeSkipenumeratorautotagFromFfiNullable(Pointer h smokeSkipenumeratorautotagReleaseFfiHandle(_handle); return result; } + void smokeSkipenumeratorautotagReleaseFfiHandleNullable(Pointer handle) => _smokeSkipenumeratorautotagReleaseHandleNullable(handle); + // End of SkipEnumeratorAutoTag "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_explicit_tag.dart b/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_explicit_tag.dart index 12c84e643c..739a902ad8 100644 --- a/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_explicit_tag.dart +++ b/gluecodium/src/test/resources/smoke/skip/output/dart/lib/src/smoke/skip_enumerator_explicit_tag.dart @@ -1,11 +1,16 @@ + + import 'dart:ffi'; import 'package:library/src/_library_context.dart' as __lib; + enum SkipEnumeratorExplicitTag { zero, one, three } + // SkipEnumeratorExplicitTag "private" section, not exported. + int smokeSkipenumeratorexplicittagToFfi(SkipEnumeratorExplicitTag value) { switch (value) { case SkipEnumeratorExplicitTag.zero: @@ -14,10 +19,9 @@ int smokeSkipenumeratorexplicittagToFfi(SkipEnumeratorExplicitTag value) { return 3; case SkipEnumeratorExplicitTag.three: return 4; - default: - throw StateError("Invalid enum value $value for SkipEnumeratorExplicitTag enum."); } } + SkipEnumeratorExplicitTag smokeSkipenumeratorexplicittagFromFfi(int handle) { switch (handle) { case 0: @@ -30,7 +34,9 @@ SkipEnumeratorExplicitTag smokeSkipenumeratorexplicittagFromFfi(int handle) { throw StateError("Invalid numeric value $handle for SkipEnumeratorExplicitTag enum."); } } + void smokeSkipenumeratorexplicittagReleaseFfiHandle(int handle) {} + final _smokeSkipenumeratorexplicittagCreateHandleNullable = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction< Pointer Function(Uint32), Pointer Function(int) @@ -43,6 +49,7 @@ final _smokeSkipenumeratorexplicittagGetValueNullable = __lib.catchArgumentError Uint32 Function(Pointer), int Function(Pointer) >('library_smoke_SkipEnumeratorExplicitTag_get_value_nullable')); + Pointer smokeSkipenumeratorexplicittagToFfiNullable(SkipEnumeratorExplicitTag? value) { if (value == null) return Pointer.fromAddress(0); final _handle = smokeSkipenumeratorexplicittagToFfi(value); @@ -50,6 +57,7 @@ Pointer smokeSkipenumeratorexplicittagToFfiNullable(SkipEnumeratorExplicit smokeSkipenumeratorexplicittagReleaseFfiHandle(_handle); return result; } + SkipEnumeratorExplicitTag? smokeSkipenumeratorexplicittagFromFfiNullable(Pointer handle) { if (handle.address == 0) return null; final _handle = _smokeSkipenumeratorexplicittagGetValueNullable(handle); @@ -57,6 +65,10 @@ SkipEnumeratorExplicitTag? smokeSkipenumeratorexplicittagFromFfiNullable(Pointer smokeSkipenumeratorexplicittagReleaseFfiHandle(_handle); return result; } + void smokeSkipenumeratorexplicittagReleaseFfiHandleNullable(Pointer handle) => _smokeSkipenumeratorexplicittagReleaseHandleNullable(handle); + // End of SkipEnumeratorExplicitTag "private" section. + + diff --git a/gluecodium/src/test/resources/smoke/structs/output/dart/lib/src/smoke/structs.dart b/gluecodium/src/test/resources/smoke/structs/output/dart/lib/src/smoke/structs.dart index 83887d9872..5b1b2029f7 100644 --- a/gluecodium/src/test/resources/smoke/structs/output/dart/lib/src/smoke/structs.dart +++ b/gluecodium/src/test/resources/smoke/structs/output/dart/lib/src/smoke/structs.dart @@ -39,8 +39,6 @@ int smokeStructsFoobarToFfi(Structs_FooBar value) { return 0; case Structs_FooBar.bar: return 1; - default: - throw StateError("Invalid enum value $value for Structs_FooBar enum."); } } diff --git a/gluecodium/src/test/resources/smoke/throwing_constructors/output/dart/lib/src/smoke/external_class.dart b/gluecodium/src/test/resources/smoke/throwing_constructors/output/dart/lib/src/smoke/external_class.dart index d1eab4f8d9..99cbaa1f8c 100644 --- a/gluecodium/src/test/resources/smoke/throwing_constructors/output/dart/lib/src/smoke/external_class.dart +++ b/gluecodium/src/test/resources/smoke/throwing_constructors/output/dart/lib/src/smoke/external_class.dart @@ -31,8 +31,6 @@ int smokeExternalclassErrorenumToFfi(ExternalClass_ErrorEnum value) { return 0; case ExternalClass_ErrorEnum.crashed: return 1; - default: - throw StateError("Invalid enum value $value for ExternalClass_ErrorEnum enum."); } } diff --git a/gluecodium/src/test/resources/smoke/visibility_attribute/output/dart/lib/src/smoke/public_class.dart b/gluecodium/src/test/resources/smoke/visibility_attribute/output/dart/lib/src/smoke/public_class.dart index 509c36bcba..29db16827b 100644 --- a/gluecodium/src/test/resources/smoke/visibility_attribute/output/dart/lib/src/smoke/public_class.dart +++ b/gluecodium/src/test/resources/smoke/visibility_attribute/output/dart/lib/src/smoke/public_class.dart @@ -24,8 +24,6 @@ int smokePublicclassInternalenumToFfi(PublicClass_InternalEnum value) { return 0; case PublicClass_InternalEnum.bar: return 1; - default: - throw StateError("Invalid enum value $value for PublicClass_InternalEnum enum."); } }