Skip to content

[ffigen] fix method filtering and renaming - #3590

Open
Hassnaa9 wants to merge 2 commits into
dart-lang:mainfrom
Hassnaa9:fix-cpp-filter-rename
Open

[ffigen] fix method filtering and renaming#3590
Hassnaa9 wants to merge 2 commits into
dart-lang:mainfrom
Hassnaa9:fix-cpp-filter-rename

Conversation

@Hassnaa9

Copy link
Copy Markdown
Contributor

fixes: #3552

@Hassnaa9
Hassnaa9 force-pushed the fix-cpp-filter-rename branch from 4824091 to ceca878 Compare August 27, 2026 01:00
@liamappelbe
liamappelbe self-requested a review August 27, 2026 01:09
import 'util.dart';

void main() {
group('cpp_filter_rename_test', () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a bit weird. Most of the code in this test directly duplicates verify_bindings_test.dart. And if that duplication is removed, there's basically nothing left. I don't see any test that verifies the APIs are included/excluded/renamed correctly.

A better way to do this test would be to remove all the FfiGenerator stuff (since it's already generated in verify_bindings_test), and instead just try invoking the renamed APIs.

For the method and class that have been filtered out, you can read the bindings file into a string, and then verify that it doesn't contain the filtered API names.

public:
// This method will be included (renamed to 'greet').
void myMethod() {}
// This method will be filtered out via includeMember.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The filtering API isn't called includeMember anymore

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.

@liamappelbe Visitor filter??

///
/// Defaults to [originalName]. Can be changed via a visitor to rename the
/// method in the generated Dart class without affecting the glue symbol.
String dartName;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, renames should be handled through Symbols. That way deduping (eg due to overloads) will be handled automatically by the Scope. You already have a Symbol name. Use that. Look at how ObjCMethods do this.

@Hassnaa9
Hassnaa9 requested a review from liamappelbe August 27, 2026 04:40
if (method.isStatic) {
s.write('''\
static $dartReturn ${method.dartName}($dartParams) {
static $dartReturn ${method.name}($dartParams) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

method.name.name. Or maybe rename Symbol name to Symbol symbol?

/// A method or constructor belonging to a C++ class.
class CppMethod extends AstNode with HasLocalScope {
final Symbol name;
final String cGlueSymbol;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably be a Symbol, and be added to a rootCppScope in Context (like rootObjCScope)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ffigen] Test filtering and renaming C++ classes and methods

2 participants