Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1b014b7
[ffigen] Vibe coded prototype of transformer API
liamappelbe Jul 20, 2026
7044019
fix tests and migrate existing Dart API ffigen configs
liamappelbe Jul 20, 2026
39c2a1b
nits
liamappelbe Jul 20, 2026
bd69dfe
fix tests
liamappelbe Jul 21, 2026
66b3ab2
Delete old API, and migrate a bunch more configs
liamappelbe Jul 23, 2026
68bba3a
visitChildren
liamappelbe Jul 29, 2026
dbba048
callback based visitor
liamappelbe Jul 29, 2026
dcd9218
shard the IncludeSetVisitor
liamappelbe Jul 29, 2026
4e08daf
flip isExcluded to isIncluded, and make visitor list non-null
liamappelbe Jul 29, 2026
36358a9
per-enum warning
liamappelbe Jul 29, 2026
cc8cb0b
remove include transitive flags
liamappelbe Jul 29, 2026
13f4370
missed some files
liamappelbe Jul 29, 2026
c2ed9c8
Move more bools to the AST
liamappelbe Jul 29, 2026
30fde52
cleaning
liamappelbe Jul 30, 2026
e1fb622
bug fixes
liamappelbe Jul 30, 2026
173954c
Headers -> Input
liamappelbe Jul 30, 2026
22839e7
Move varArgs
liamappelbe Jul 30, 2026
983d31f
more cleanup
liamappelbe Jul 30, 2026
cceba6d
Split out _VisitorImpl
liamappelbe Jul 30, 2026
1de61b7
migrate all configs
liamappelbe Jul 30, 2026
bd53b4f
Merge branch 'main' into ffigen_transformer
liamappelbe Jul 31, 2026
a532462
config docs
liamappelbe Aug 3, 2026
b86079b
typedefTypeMappings -> typedefImports
liamappelbe Aug 3, 2026
1b767f7
mac only test
liamappelbe Aug 3, 2026
b57df8c
fix large_test
liamappelbe Aug 3, 2026
2b5a5b3
cleaning up ObjC bindings
liamappelbe Aug 3, 2026
4f3aacc
fixes
liamappelbe Aug 3, 2026
e60f0c8
clean up
liamappelbe Aug 3, 2026
ac6d86f
clean up
liamappelbe Aug 3, 2026
3df1a17
clean up
liamappelbe Aug 3, 2026
a2006b2
cleaning
liamappelbe Aug 3, 2026
eaad4da
more cleanup
liamappelbe Aug 4, 2026
c4b1e14
clean up
liamappelbe Aug 4, 2026
98c09b9
fix enum recommendation behavior
liamappelbe Aug 4, 2026
c425c00
clean
liamappelbe Aug 4, 2026
eb0f393
clean up
liamappelbe Aug 4, 2026
aa9fb00
clean up
liamappelbe Aug 4, 2026
a68ad13
clean up
liamappelbe Aug 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkgs/code_assets/example/host_name/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import 'package:ffigen/ffigen.dart';

void main() {
final packageRoot = Platform.script.resolve('../');
final functions = Functions.includeSet({'gethostname'});
const visitors = [IncludeSetVisitor({'gethostname'})];
final FfiGenerator generator;
if (Platform.isWindows) {
generator = FfiGenerator(
headers: Headers(entryPoints: [packageRoot.resolve('src/windows.h')]),
functions: functions,
visitors: visitors,
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/windows.dart'),
preamble: '''
Expand All @@ -27,7 +27,7 @@ void main() {
} else {
generator = FfiGenerator(
headers: Headers(entryPoints: [packageRoot.resolve('src/unix.h')]),
functions: functions,
visitors: visitors,
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/unix.dart'),
preamble: '''
Expand Down
20 changes: 8 additions & 12 deletions pkgs/code_assets/example/mini_audio/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@ void main() {
headers: Headers(
entryPoints: [packageRoot.resolve('third_party/miniaudio.h')],
),
functions: Functions(
include: (decl) => {
visitors: const [
Comment thread
dcharkes marked this conversation as resolved.
IncludeSetVisitor({
'ma_engine_init',
'ma_engine_play_sound',
'ma_engine_uninit',
}.contains(decl.originalName),
recordUse: (_) => true,
),
structs: Structs(
include: (decl) => {'ma_engine'}.contains(decl.originalName),
),
enums: Enums(
include: (decl) => {'ma_result'}.contains(decl.originalName),
silenceWarning: true,
),
'ma_engine',
'ma_result',
}),
RecordUseVisitor(),
],
enums: const Enums(silenceWarning: true),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we need to think where to put everything that doesn't end up in visitors that fit next to the declaration-type-specific config before. How many of such elements are there?

@liamappelbe liamappelbe Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYM? I figured we'd just leave those fields where they are, in the hierarchy. Are you suggesting we delete the whole existing hierarchy?

output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/miniaudio.g.dart'),
recordUseMapping: packageRoot.resolve(
Expand Down
8 changes: 4 additions & 4 deletions pkgs/code_assets/example/sqlite/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ void main() {
headers: Headers(
entryPoints: [packageRoot.resolve('third_party/sqlite/sqlite3.h')],
),
functions: Functions(
include: (decl) => {'sqlite3_libversion'}.contains(decl.originalName),
recordUse: (_) => true,
),
visitors: const [
IncludeSetVisitor({'sqlite3_libversion'}),
RecordUseVisitor(),
],
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/sqlite3.g.dart'),
recordUseMapping: packageRoot.resolve(
Expand Down
5 changes: 4 additions & 1 deletion pkgs/code_assets/example/sqlite_no_link/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ void main() {
headers: Headers(
entryPoints: [packageRoot.resolve('third_party/sqlite/sqlite3.h')],
),
functions: Functions.includeSet({'sqlite3_libversion'}),
visitors: const [
IncludeSetVisitor({'sqlite3_libversion'}),
RecordUseVisitor(),
],
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/sqlite3.g.dart'),
preamble: '''
Expand Down
5 changes: 4 additions & 1 deletion pkgs/code_assets/example/sqlite_prebuilt/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ void main() {
headers: Headers(
entryPoints: [packageRoot.resolve('third_party/sqlite/sqlite3.h')],
),
functions: Functions.includeSet({'sqlite3_libversion'}),
visitors: const [
IncludeSetVisitor({'sqlite3_libversion'}),
RecordUseVisitor(),
],
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/sqlite3.g.dart'),
preamble: '''
Expand Down
8 changes: 4 additions & 4 deletions pkgs/code_assets/example/stb_image/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ void main() {
headers: Headers(
entryPoints: [packageRoot.resolve('third_party/stb_image.h')],
),
functions: Functions(
include: (decl) => {'stbi_info'}.contains(decl.originalName),
recordUse: (_) => true,
),
visitors: const [
IncludeSetVisitor({'stbi_info'}),
RecordUseVisitor(),
],
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/stb_image.g.dart'),
recordUseMapping: packageRoot.resolve(
Expand Down
4 changes: 3 additions & 1 deletion pkgs/ffigen/example/add/tool/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ FfiGenerator getConfig(Uri packageRoot) {
return FfiGenerator(
output: Output(dartFile: packageRoot.resolve('lib/add.g.dart')),
headers: Headers(entryPoints: [packageRoot.resolve('src/add.h')]),
functions: Functions.includeSet({'add'}),
visitors: [
const IncludeSetVisitor({'add'}),
],
);
}

Expand Down
1 change: 0 additions & 1 deletion pkgs/ffigen/example/ffinative/lib/generated_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ external ffi.Pointer<ffi.Float> divide(int a, int b);
@ffi.Native<ffi.Pointer<ffi.Double> Function(ffi.Float, ffi.Float)>()
external ffi.Pointer<ffi.Double> dividePrecision(double a, double b);

/// Version of the native C library
@ffi.Native<ffi.Pointer<ffi.Char>>()
external final ffi.Pointer<ffi.Char> library_version;

Expand Down
Loading
Loading