robusta
robusta copied to clipboard
Add capability to specify input Signature
Macro added to be capable to force an input signature. This is useful on Android as the parameters can be specific object passed by JObject type. But without the force macro, the JNI will not find the method as the signature is wrong.
I'm not sure this is the right way to do it, and maybe there already is the capability to force that but couldn't find it.
Hi! First of all thank you again for the PR!
One question: is this strictly necessary? I mean, if the signature expects an android.context.Context
could it not work with just something like:
#[derive(Signature, TryIntoJavaValue)]
#[package(android.context)]
struct Context { ... }
Btw, I'm not against the change per se (it would be hell to cover an API such as android's this way), I just want to understand if this is made for convenience or for other reasons.
This is useful on Android as the parameters can be specific object passed by JObject type
Could you give me an example?
I'm not sure this is the right way to do it, and maybe there already is the capability to force that but couldn't find it.
You're right, currently the macro does not have a way to override the generated signature.
Hello !
Actually I tried to use a structure as you described, but I couldn't make it work. I'll make a simple demo in order to show you the need and maybe you'll know how to manage it.
I could also use a simple Object as input to my Java function and then cast it to a Context, but I found this less sexy ^^ So don't hesitate if you think this PR is not really useful.
@giovanniberti What do you think of the provided example ? Do you have suggestions ?
Sorry for missing for almost a month, I'm going to review the code in the next few days and get back to you :slightly_smiling_face:
Hello @giovanniberti Sorry to have taken so long to take your comments into account Concerning darling, I'm still a beginner at macro usage (learn already so much from you) and it's usage is not straighforward to me ^^'
No problem, I'll check out the new changes as soon as I can 😃
Hi @giovanniberti ! Did you have some time to check ? :)