blob: 0d281c5d348d2a85c88702639fd60d7025e9794d [file]
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:ffigen/ffigen.dart';
FfiGenerator getConfig([Uri? packageRoot]) {
packageRoot ??= Uri.directory(Directory.current.path);
final testDir = packageRoot.resolve('test/native_objc_test/');
return FfiGenerator(
output: Output(
dart: DartOutput(path: testDir.resolve('protocol_test_bindings.dart')),
objectiveCFile: testDir.resolve('protocol_test_bindings.m'),
style: const NativeExternalBindings(assetId: 'package:ffigen/objc_test'),
),
input: Input(entryPoints: [testDir.resolve('protocol_test.h')]),
objectiveC: const ObjectiveC(),
visitors: [
Visitor(
func: (node) {
const include = {
'getClass',
'getClassName',
'objc_autoreleasePoolPop',
'objc_autoreleasePoolPush',
};
node.isIncluded = include.contains(node.name);
},
objCInterface: (node) {
const include = {
'ProtocolConsumer',
'ObjCProtocolImpl',
'ObjCProtocolImplMissingMethod',
};
node.isIncluded = include.contains(node.originalName);
},
objCProtocol: (node) {
const include = {
'EmptyProtocol',
'MyProtocol',
'SecondaryProtocol',
'UnusedProtocol',
};
node.isIncluded = include.contains(node.originalName);
},
),
],
);
}