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
Partial properties generation #640
Conversation
README.md
Outdated
@@ -189,6 +189,12 @@ cfg_condition = "mycond" | |||
name = "baseline-position" | |||
version = "3.10" | |||
ignore = true | |||
[[object.property]] | |||
name = "events" | |||
# generate only `connect_property_notify_event`, without `get_property_events` and `set_property_events` |
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.
Shouldn't it be connect_property_notify_eventS
?
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.
Strange, but is not:
fn connect_property_notify_event<F: Fn(&Self, &gdk::EventProperty) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &gdk::EventProperty) -> Inhibit + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "property-notify-event",
transmute(property_notify_event_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
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.
Let's call it dark magic haha.
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 was right, I looked to wrong function: connect_property_events_notify
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.
Ah now it seems more logical! (And explain why I couldn't find it...)
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.
IMHO needed other name instead "object.property.generate", maybe for
PropertyGenerateFlags
too.
generate seems fine to me
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.
Oh sorry, forgot to answer this question: seems fine to me as well.
Seems good to me. Thanks a lot for adding it! |
4c64bc5
to
9df71d6
Compare
README.md
Outdated
name = "events" | ||
# generate only `connect_property_events_notify`, without `get_property_events` and `set_property_events` | ||
# supported values: "get", "set", "notify", | ||
# also supported union "get|set" and inverting "not(notify)" |
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.
Why so complicated that we even need nom? :)
I would simply list the things that should be generated. What is the use-case of negations?
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.
For 3 only cases not
really unusable, I was do it automatically.
Maybe better only support union with simple list splitting and parsing.
I also thought that we need other generate flags in future (for signal), but seems I mixed up with something.
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.
Yes better just have a list :)
9df71d6
to
8f0ca08
Compare
Changed expression parsing |
README.md
Outdated
name = "events" | ||
# generate only `connect_property_events_notify`, without `get_property_events` and `set_property_events` | ||
# supported values: "get", "set", "notify", also allowed union "get|set" | ||
generate = "notify" |
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.
Why not a toml list of strings?
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.
Then we need accept both array and single value: too much work on Toml types,
and only array IMHO redundantly.
Can change if @GuillaumeGomez prefer array too.
Looks good to me otherwise |
@GuillaumeGomez Which config format for flags you prefer: |
I have a preference for |
Ok, then I do it tomorrow |
8f0ca08
to
b17fb50
Compare
Updated |
src/analysis/properties.rs
Outdated
let name_for_func = nameutil::signal_to_snake(&name); | ||
let var_name = nameutil::mangle_keywords(&*name_for_func).into_owned(); | ||
let get_func_name = format!("get_property_{}", name_for_func); | ||
let set_func_name = format!("set_property_{}", name_for_func); | ||
let check_get_func_name = format!("get_{}", name_for_func); | ||
let check_set_func_name = format!("set_{}", name_for_func); | ||
|
||
let mut readable = prop.readable; | ||
let mut readable = prop.readable && generate.contains(PropertyGenerateFlags::GET); |
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.
It should probably warn if GET
is configured but the property is write-only (and same for writable)
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.
Good idea
Seems good to me except for some cosmetic detail #640 (review) |
Added commit with warning |
Maybe it need be error for faster detection |
…twritable property
7e9a488
to
702e550
Compare
Fine with me either way :) Thanks! |
Then I merge it |
Part of #639 and #510
cc @GuillaumeGomez, @sdroege
IMHO needed other name instead "object.property.generate", maybe for
PropertyGenerateFlags
too.WIP as I don't like current parser implementation and try to rework it.