Skip to content
1 change: 0 additions & 1 deletion pkgs/ffigen/lib/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export 'src/config_provider.dart'
Functions,
Globals,
Headers,
Integers,
Interfaces,
Macros,
NativeExternalBindings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ObjCBuiltInFunctions {

// A unique (but not human readable) ID for the generated library based on
// a hash of parts of the config.
static String _libraryIdFromConfigHash(Config config) => fnvHash32(
static String _libraryIdFromConfigHash(FfiGenerator config) => fnvHash32(
[
...config.headers.entryPoints,
config.output.dartFile,
Expand Down
121 changes: 6 additions & 115 deletions pkgs/ffigen/lib/src/config_provider/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ final class FfiGenerator {
/// Configuration for globals.
final Globals globals;

/// Configuration for integer types.
final Integers integers;

/// Configuration for macro constants.
final Macros macros;

Expand Down Expand Up @@ -61,16 +58,11 @@ final class FfiGenerator {
/// The configuration for outputting bindings.
final Output output;

/// Types imported from other Dart files, specified via the
/// unique-resource-identifer used in Clang.
///
/// Applies to all kinds of definitions.
// TODO(https://github.com/dart-lang/native/issues/2596): Remove this.
@Deprecated(
'Will be folded into imported fields of the various declarations. See '
'https://github.com/dart-lang/native/issues/2596.',
)
final Map<String, ImportedType> importedTypesByUsr;
/// Returns an [ImportedType] if the given [Declaration] should be imported
/// from another Dart library, or `null` otherwise.
final ImportedType? Function(Declaration declaration) importType;

static ImportedType? _defaultImportType(Declaration declaration) => null;

/// Stores all the library imports specified by user including those for ffi
/// and pkg_ffi.
Expand All @@ -92,7 +84,6 @@ final class FfiGenerator {
this.enums = Enums.excludeAll,
this.functions = Functions.excludeAll,
this.globals = Globals.excludeAll,
this.integers = const Integers(),
this.macros = Macros.excludeAll,
this.structs = Structs.excludeAll,
this.cpp,
Expand All @@ -101,11 +92,7 @@ final class FfiGenerator {
this.unnamedEnums = UnnamedEnums.excludeAll,
this.objectiveC,
required this.output,
@Deprecated(
'Will be folded into imported fields of the various declarations. See '
'https://github.com/dart-lang/native/issues/2596.',
)
this.importedTypesByUsr = const <String, ImportedType>{},
this.importType = _defaultImportType,
@Deprecated(
'In the future, this shoud be inferred from ImportedTypes. See '
'https://github.com/dart-lang/native/issues/2597.',
Expand Down Expand Up @@ -392,25 +379,6 @@ final class Globals extends Declarations {
Globals(include: Declarations.includeSet(names));
}

/// Configuration for integer types.
final class Integers {
/// Integer types imported from other Dart files.
// TODO(https://github.com/dart-lang/native/issues/2595): Change type.
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
final List<ImportedType> imported;

const Integers({
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
this.imported = const <ImportedType>[],
});
}

/// Configuration for macros.
final class Macros extends Declarations {
const Macros({super.rename, super.include});
Expand All @@ -428,14 +396,6 @@ final class Structs extends Declarations {
/// Whether structs that are dependencies should be included.
final CompoundDependencies dependencies;

/// Structs imported from other Dart files.
// TODO(https://github.com/dart-lang/native/issues/2595): Change type.
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
final List<ImportedType> imported;

/// Whether, and how, to override struct packing for the given struct.
final PackingValue? Function(Declaration declaration) packingOverride;

Expand All @@ -446,11 +406,6 @@ final class Structs extends Declarations {
super.rename,
super.renameMember,
this.dependencies = CompoundDependencies.opaque,
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
this.imported = const <ImportedType>[],
this.packingOverride = _packingOverrideDefault,
});

Expand All @@ -464,13 +419,6 @@ final class Structs extends Declarations {

/// Configuration for typedefs.
final class Typedefs extends Declarations {
/// Typedefs imported from other Dart files.
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
final List<ImportedType> imported;

/// If enabled, unused typedefs will also be generated.
final bool includeUnused;

Expand All @@ -480,11 +428,6 @@ final class Typedefs extends Declarations {
const Typedefs({
super.rename,
super.include,
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
this.imported = const <ImportedType>[],
this.includeUnused = false,
this.useSupportedTypedefs = true,
});
Expand Down Expand Up @@ -521,23 +464,11 @@ final class Unions extends Declarations {
/// Whether unions that are dependencies should be included.
final CompoundDependencies dependencies;

/// Unions imported from other Dart files.
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
final List<ImportedType> imported;

const Unions({
super.include,
super.rename,
super.renameMember,
this.dependencies = CompoundDependencies.opaque,
@Deprecated(
'This field will change type. See '
'https://github.com/dart-lang/native/issues/2595.',
)
this.imported = const <ImportedType>[],
});

static const excludeAll = Unions(include: Declarations.excludeAll);
Expand Down Expand Up @@ -762,43 +693,3 @@ final class DynamicLibraryBindings implements BindingStyle {
this.wrapperDocComment,
});
}

extension type Config(FfiGenerator ffiGen) implements FfiGenerator {
// ignore: deprecated_member_use_from_same_package
Map<String, ImportedType> get importedTypesByUsr => ffiGen.importedTypesByUsr;

// Override declarative user spec with what FFIgen internals expect.
Map<String, ImportedType> get typedefTypeMappings =>
Map<String, ImportedType>.fromEntries(
// ignore: deprecated_member_use_from_same_package
ffiGen.typedefs.imported.map(
(import) => MapEntry<String, ImportedType>(import.nativeType, import),
),
);

Map<String, ImportedType> get structTypeMappings =>
Map<String, ImportedType>.fromEntries(
// ignore: deprecated_member_use_from_same_package
ffiGen.structs.imported.map(
(import) => MapEntry<String, ImportedType>(import.nativeType, import),
),
);

// Override declarative user spec with what FFIgen internals expect.
Map<String, ImportedType> get unionTypeMappings =>
Map<String, ImportedType>.fromEntries(
// ignore: deprecated_member_use_from_same_package
ffiGen.unions.imported.map(
(import) => MapEntry<String, ImportedType>(import.nativeType, import),
),
);

// Override declarative user spec with what FFIgen internals expect.
Map<String, ImportedType> get importedIntegers =>
Map<String, ImportedType>.fromEntries(
// ignore: deprecated_member_use_from_same_package
ffiGen.integers.imported.map(
(import) => MapEntry<String, ImportedType>(import.nativeType, import),
),
);
}
Loading
Loading