Skip to content

Revisit PropertyInfo in public APIs #1429

@Bromeon

Description

@Bromeon

The PropertyInfo struct's purpose is 90% godot-rust internal type information, and 10% public API. As such, the latter has been neglected for the most part. Some public API examples:

There are several issues related to `PropertyInfo:

  1. Some methods like property_sys(), empty_sys() should likely be private/hidden.

  2. There are naming collisions between Object::get_property_list and IObject::get_property_list.

    • While Rust allows this, it can still be confusing. Godot solves this with the _ prefix.
    • We might want to rename some virtual methods to on_*, to make clear that they're the queried as a result of some public method call.
    • Similar for set/get vs. set_property/get_property -- something like on_set/on_get might be clearer.
    • Prior art: on_notification instead of Godot's _notification.
  3. The struct itself is quite low-level.

    • This is probably OK if we recommend to use constructor new_var::<T>("property_name")
    • However, field class_id: ClassId cannot be set for non-class properties, as ClassId has no longer a public none() constructor.
      Either we provide this, or data model needs to change (e.g. more towards ElementType enum, without script?)
  4. There is also MethodInfo, but it seems unused in public APIs?

  5. EditorSetting::add_property_info() and ProjectSettings::add_property_info() take a hint but as dictionary.

    • Could a conversion, or directly type-safe method help here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: ffiLow-level components and interaction with GDExtension APIquality-of-lifeNo new functionality, but improves ergonomics/internals

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions