MatejSloboda / Dijkstra_map_for_Godot

MIT License
78 stars 13 forks source link

starts transition to 0.11.0 (fails to build right now, need a bit of help) #112

Closed astrale-sharp closed 2 years ago

astrale-sharp commented 2 years ago

This PR does most of the work (untested) but i must have some of the new export syntax confused about #[methods] #[derive] etc.

start to resolve #111 but im stuck and i need help with errors i don't know how to resolve

note that the first commit just corrects some typos but im unsure how to make a separated PR

astrale-sharp commented 2 years ago

This is now completly working except for the method duplicate_graph_from which i cant seem to make compile as of right now... When you uncomment the code you get this error which is quite confusing

errors :

the method `map` exists for struct `gdnative::prelude::Instance<Interface>`, but its trait bounds were not satisfied
the following trait bounds were not satisfied:
`gdnative::object::bounds::RefImplBound: gdnative::object::bounds::SafeDeref<gdnative::prelude::RefCounted, gdnative::prelude::Shared>`
`gdnative::prelude::Instance<Interface>: std::iter::Iterator`
which is required by `&mut gdnative::prelude::Instance<Interface>: std::iter::Iterator`
goblinJoel commented 2 years ago

No Rust experience, so just throwing random guesses in case something clicks:

astrale-sharp commented 2 years ago

Hey :) the new api doesn't require to have _owner as part of the signature anymore so I removed it on all methods when the rust version isn't sufficient, rustc kindly warns you (which it did with me and i updated so it's not the problem)

For some reason in the following code we can't use map anymore and i can't get my head around why, i dont understand the trait errors very well

 let mut cast;
        unsafe {
            cast = source_instance
                .to_object::<Reference>()
                .unwrap()
                .assume_safe()
                .assume_shared();
        }

        match cast
            .cast_instance::<Interface>()
            .as_ref()
            // .and_then(|reference| unsafe { reference.assume_safe() }.cast_instance::<Interface>())
            .and_then(|interface| {
                interface.map(|interface, _| {
                    self.dijkstra = interface.dijkstra.clone();
                })
            }) 
astrale-sharp commented 2 years ago

If you need it working, it currently works on this draft without duplicate_graph_from(), you'd have to

  1. pull from this draft the simplest command would be git clone https://github.com/astrale-sharp/Dijkstra_map_for_Godot-1
  2. compile the code cargo run --release
  3. move the generated bin in target/release/libdijkstra_map_gd.so to addons/dijkstra-map/Dijkstra_map_library/bin/ + your OS

Hope that's helping, ask if you need help with something!

goblinJoel commented 2 years ago

Thanks for posting the workaround. If I get to the point where I can't put off the 3.5 upgrade anymore, I'll be sure to try it if it's not solved by then! I don't think I'm using duplicate_graph_from() right now.