-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Add get_property_list
#707
Add get_property_list
#707
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-707 |
d401513
to
e9efb15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks also for the extra documentation!
#(#cfg_attrs)* | ||
impl ::godot::obj::cap::GodotGetPropertyList for #class_name { | ||
fn __godot_get_property_list(&mut self) -> Vec<::godot::builtin::meta::PropertyInfo> { | ||
// Only supported in godot api > 4.3. If support is added for earlier versions this is still needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably mean >= 4.3
here and not >
.
Also not exactly sure what you mean by "If support is added for earlier versions this is still needed.", could you maybe elaborate what you mean by "support" and "this is still needed"?
(also capitalization, "Godot API")
godot-core/src/builtin/meta/mod.rs
Outdated
use crate::engine::global; | ||
use crate::engine::global::{self, PropertyHint, PropertyUsageFlags}; | ||
use crate::property::{Export, PropertyHintInfo}; | ||
use crate::{builtin::*, property::Var}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flat 😉
// No UB or anything else like a crash or panic should happen when `property_can_revert` and `property_get_revert` return | ||
// inconsistent values, but in case something like that happens we should be able to detect it through this function. | ||
"property_changes" => { | ||
if INC.fetch_add(1, std::sync::atomic::Ordering::AcqRel) % 2 == 0 { | ||
None | ||
} else { | ||
Some(true.to_variant()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Add `property_can_revert`
Cleanup a couple of things
e9efb15
to
54ac2fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, feel free to merge when ready!
This does three main things
Adds
get_property_list
Also adds
property_get_revert/property_can_revert
(combined into one function).This allows the user to fully dynamically generate the property list as well as set all relevant options for the property list. This also provides a mechanism to group exports in the editor #226, however it's not the most ergonomic way as it requires all grouped properties to be defined in the
get_property_list
method.Adds some convenience functions to
PropertyInfo
This makes it easier to generate property infos corresponding to the usual property types. For instance to generate a
#[var]
declaration you can now just doPropertyInfo::new_var::<Type>("property_name")
rather than needing to specify all the individual properties.I also added documentation to each field of
PropertyInfo
since it's a more public facing type like this.Adds sys-conversions that pass ownership for
PropertyInfo
,GString
, andStringName
Unlike
sys()
, these methods namedinto_owned_(string/property)_sys
andfree_owned_(string/property)_sys
allow us to convert aPropertyInfo
directly into asys::GDExtensionPropertyInfo
while:free_*
function can appropriately free the value later)This is used in
get_property_list
andfree_property_list
to pass a list of property infos to Godot and then later free the values.closes #665