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

Expanding Any derive to provide more features automatically #96

Closed
5 tasks done
udoprog opened this issue Sep 22, 2020 · 0 comments
Closed
5 tasks done

Expanding Any derive to provide more features automatically #96

udoprog opened this issue Sep 22, 2020 · 0 comments
Labels
compiler Issues related to the compiler. enhancement New feature or request

Comments

@udoprog
Copy link
Collaborator

udoprog commented Sep 22, 2020

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 udoprog added enhancement New feature or request compiler Issues related to the compiler. labels Sep 22, 2020
@udoprog udoprog closed this as completed Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Issues related to the compiler. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant