-
Notifications
You must be signed in to change notification settings - Fork 211
Closed
Labels
c: exportComponent: export (mod export, derive)Component: export (mod export, derive)quality-of-lifeNo new functionality, but improves ergonomics/internalsNo new functionality, but improves ergonomics/internals
Milestone
Description
From Endr on Discord:
It'd allow for more fine-grained control over how the object is borrowed in _process or other methods. It's sometimes convenient to pass down the instance to dependent objects. Currently the object has to be borrowed in the exported method, so others can't mutably borrow it through the instance. It can be workarounded with
(Rc<RefCell<Data>>, TRef<Base>)pair, but it reimplements Instance in some way and adds more annoyances than needed.
Note that a TInstance interface is available using manual registration, although no example is readily available. It might be interesting to expand something like this into a full example project:
#[derive(Copy, Clone, Default)]
struct MyMethod;
#[derive(FromVarargs)]
struct Args {
my_arg: i32,
#[opt] my_opt_arg: Option<i32>,
}
impl StaticArgsMethod<MyScript> for MyMethod {
type Args = Args;
fn call(&self, this: TInstance<'_, MyScript>, args: Args) -> Variant {
do_whatever_with(this);
Variant::new(args.my_arg + args.my_opt_arg.unwrap_or(0))
}
fn site() -> Option<$crate::log::Site<'static>> {
Some(godot_site!(MyScript::MyMethod))
}
}Metadata
Metadata
Assignees
Labels
c: exportComponent: export (mod export, derive)Component: export (mod export, derive)quality-of-lifeNo new functionality, but improves ergonomics/internalsNo new functionality, but improves ergonomics/internals