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

Autoclone Reference to<T: Clone + X> #382

Open
kwek20 opened this issue Mar 17, 2021 · 1 comment
Open

Autoclone Reference to<T: Clone + X> #382

kwek20 opened this issue Mar 17, 2021 · 1 comment
Labels
enhancement Java/JNI Case specific only for Java/JNI interface generation

Comments

@kwek20
Copy link

kwek20 commented Mar 17, 2021

Hey! In order to make the library easier to use, i was wondering if theres a way to add something like automatically cloning a reference for a T that is cloneable.
It already exists in a Vec(I think?), but i dont see it on any regular T, and flapigen currently returns
error: Do not know conversation from such rust type '& Tester' to Java type

(Not sure if this typemap is corrrect)

Example:

foreign_typemap!(
    ($p:r_type) <T: SwigForeignClass + Clone> &T => swig_i_type!(T) {
        $out = swig_from_rust_to_i_type(T, $p.clone(), ret);
    };
);

#[derive(Clone)]
pub struct Tester {

}

foreign_class!(
    #[derive(Clone)]
    class Tester {
        self_type Tester;
        private constructor = empty;
        fn Tester::test(&self) -> &Tester {
            let t = Tester { };
            &t
        }
    }
);

@kwek20 kwek20 changed the title Autoclone Reference to T: Clone Autoclone Reference to<T: Clone + X> Mar 17, 2021
@Dushistov Dushistov added enhancement Java/JNI Case specific only for Java/JNI interface generation labels Mar 17, 2021
@Dushistov
Copy link
Owner

There is #169 almost about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Java/JNI Case specific only for Java/JNI interface generation
Projects
None yet
Development

No branches or pull requests

2 participants