Skip to content

Commit

Permalink
fix ToGodot todo
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Sep 22, 2024
1 parent 1750a45 commit 3a716d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions godot-core/src/meta/ref_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ where
where Self: 'v;

fn to_godot(&self) -> Self::ToVia<'_> {
match self.shared_ref {
Some(r) => r.to_godot(),
None => todo!("implement mapping of RefArg(RawGd<T>).to_godot()"),
}
let shared_ref = self
.shared_ref
.expect("Objects are currently mapped through ObjectArg; RefArg shouldn't be null");

shared_ref.to_godot()
}
}

Expand Down
9 changes: 6 additions & 3 deletions itest/rust/src/object_tests/object_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,18 @@ fn object_engine_roundtrip() {
obj.free();
}

#[itest(focus)]
#[itest]
fn object_null_argument() {
// Objects currently use ObjectArg instead of RefArg, so this scenario shouldn't occur. Test can be updated if code is refactored.

let null_obj = Option::<Gd<Node>>::None;

let via = null_obj.to_godot();
let ffi = via.to_ffi();
//dbg!(ffi);

ffi.to_godot();
expect_panic("not yet implemented: pass objects through RefArg", || {
ffi.to_godot();
});
}

#[itest]
Expand Down

0 comments on commit 3a716d6

Please sign in to comment.