rune icon indicating copy to clipboard operation
rune copied to clipboard

Expanding Any derive to provide more features automatically

Open udoprog opened this issue 3 years ago • 0 comments

The Any derive should be expanded to provide the following glue code automatically:

Getters and setters for any fields which are pub, and not explicitly marked as #[any(skip)].

Constructor glue so that the type can be constructed in Rune with syntax appropriate for the type.

For example:

#[derive(Any)]
struct Npc {
    x: i64,
    y: i64,
}

#[derive(Any)]
struct Point(i64, i64);

Can be constructed like this in Rune (unless any field is marked as non-public or #[any(skip)]):

let npc = Npc { x: 10, y: 10 };
let p = Point(20, 40);

Note: this would be implementation by using a generated constructor and mapping the appropriate constructor syntax in Rune using CompileMeta to this constructor.

Checklist

  • [ ] Generating getters and setters for field not marked with #[any(skip)].
  • [ ] Generating constructors and mapping them in the Rune compiler through CompileMeta.
    • [ ] For tuple types.
    • [ ] For struct types.
    • [ ] For enum types (tuple and struct variants).

udoprog avatar Sep 22 '20 00:09 udoprog