Skip to content

Conversation

@jgeralnik
Copy link
Contributor

This is far from comprehensive but is all of the functions that I am currently using from vision framework.

I tried following the guide in the README - none of these functions have any meaningful limitations on their parameters.

The only point that I am unsure of is the last one:

If the method can throw an exception if provided with invalid inputs, it is not safe. Consider declaring a helper method that checks the preconditions first!

I would really like to add the function VNImageRequestHandler::performRequests_error as a safe function as well. It can throw an exception if it gets invalid parameters, but the rust function returns a Result<(), Retained<NSError>> so I'm not sure why it should be considered unsafe.

Either way - I couldn't get header-translator to generate a version of the function marked safe - tried with class.VNImageRequestHandler.methods."performRequests:error:_".unsafe = false but it didn't work (possibly due to the underscore)

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Dec 9, 2024
@madsmtm
Copy link
Owner

madsmtm commented Dec 9, 2024

Thanks a lot!

If the method can throw an exception if provided with invalid inputs, it is not safe. Consider declaring a helper method that checks the preconditions first!

I would really like to add the function VNImageRequestHandler::performRequests_error as a safe function as well. It can throw an exception if it gets invalid parameters, but the rust function returns a Result<(), Retained<NSError>> so I'm not sure why it should be considered unsafe.

Sorry, that was outdated, exceptions have been safe since #669. I've removed the note in 5048147.

Either way - I couldn't get header-translator to generate a version of the function marked safe - tried with class.VNImageRequestHandler.methods."performRequests:error:_".unsafe = false but it didn't work (possibly due to the underscore)

Yeah, the underscore is wrong in this context, it should just be the selector (so class.VNImageRequestHandler.methods."performRequests:error:".unsafe = false).

@jgeralnik
Copy link
Contributor Author

Thanks, added VNImageRequestHandler::perform as a safe function as well

Copy link
Owner

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Cool! Could you rebase (both this PR and the objc2-generated branch)? Then I'll merge it after

@jgeralnik
Copy link
Contributor Author

Rebased (objc2-generated didn't need rebasing since there haven't been any changes there recently)

@madsmtm
Copy link
Owner

madsmtm commented Dec 9, 2024

Sorry, I should've said "squash", my bad 🙄

@jgeralnik
Copy link
Contributor Author

Ah, whoops. Squashed now

@madsmtm
Copy link
Owner

madsmtm commented Dec 9, 2024

Thanks!

@madsmtm madsmtm merged commit f0f6a5b into madsmtm:master Dec 9, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-framework Affects the framework crates and the translator for them enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants