Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method renamer should include type names. #1007

Closed
yanshouwang opened this issue Mar 14, 2024 · 3 comments
Closed

Method renamer should include type names. #1007

yanshouwang opened this issue Mar 14, 2024 · 3 comments
Assignees
Labels
lang-objective_c Related to Objective C support package:ffigen

Comments

@yanshouwang
Copy link

yanshouwang commented Mar 14, 2024

When I tried to generate the UIImage bindings, the generated code shows some errors:
截屏2024-03-14 16 06 04
The wrong code is generated as follow

....
  ffi.Pointer<CGImage> get CGImage {
    return _lib._objc_msgSend_1228(_id, _lib._sel_CGImage1);
  }
...
final class CGImage extends ffi.Opaque {}
...

Maybe the CGImage property should changed to cgImage?
https://developer.apple.com/documentation/coreimage/ciimage/1687603-cgimage

@yanshouwang yanshouwang changed the title ffigen generated error code with UIImage class. ffigen generated wrong code with UIImage class. Mar 14, 2024
@liamappelbe
Copy link
Contributor

Does it work if you manually edit the generated code to rename the getter?

I think we use separate renamers for types vs methods. If we made the method renamer aware of all the type names, then it would rename this getter to CGImage1.

@yanshouwang
Copy link
Author

Does it work if you manually edit the generated code to rename the getter?

I think we use separate renamers for types vs methods. If we made the method renamer aware of all the type names, then it would rename this getter to CGImage1.

Yes, I can fix this error manually, why don't use cgImage instead of CGImage?

@liamappelbe
Copy link
Contributor

Yes, I can fix this error manually

I'm not actually asking you to fix it manually. I just wanted to confirm that this fix would work before I implement it.

why don't use cgImage instead of CGImage?

The renaming needs to be something that ffigen can do programmatically. Renaming CGImage to cgImage isn't something I can do automatically in ffigen (how would it know to make only the first 2 letters lower case?).

@liamappelbe liamappelbe added the lang-objective_c Related to Objective C support label Mar 22, 2024
@liamappelbe liamappelbe changed the title ffigen generated wrong code with UIImage class. Method renamer should include type names. Mar 22, 2024
liamappelbe added a commit that referenced this issue Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-objective_c Related to Objective C support package:ffigen
Projects
Status: Done
Development

No branches or pull requests

2 participants