robusta icon indicating copy to clipboard operation
robusta copied to clipboard

Add capability to specify input Signature

Open EliseChouleur opened this issue 2 years ago • 6 comments

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.

EliseChouleur avatar Nov 26 '21 16:11 EliseChouleur

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.

giovanniberti avatar Nov 30 '21 12:11 giovanniberti

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.

EliseChouleur avatar Nov 30 '21 13:11 EliseChouleur

@giovanniberti What do you think of the provided example ? Do you have suggestions ?

EliseChouleur avatar Dec 17 '21 23:12 EliseChouleur

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:

giovanniberti avatar Dec 24 '21 14:12 giovanniberti

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 ^^'

EliseChouleur avatar Aug 08 '22 15:08 EliseChouleur

No problem, I'll check out the new changes as soon as I can 😃

giovanniberti avatar Aug 09 '22 07:08 giovanniberti

Hi @giovanniberti ! Did you have some time to check ? :)

EliseChouleur avatar Oct 18 '22 16:10 EliseChouleur