-
Notifications
You must be signed in to change notification settings - Fork 133
Providing each Wayland interface instance with access to their client #4860
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
Open
mattkae
wants to merge
3
commits into
wayland-rs-global-filter
Choose a base branch
from
wayland-rs-client-per-object
base: wayland-rs-global-filter
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,48 @@ impl CppBuilder { | |
| } | ||
| } | ||
|
|
||
| if !class.protected_constructor_args.is_empty() | ||
| || !class.protected_members.is_empty() | ||
| { | ||
| result.push_str("protected:\n"); | ||
|
|
||
| if !class.protected_constructor_args.is_empty() { | ||
| let ctor_args_str: Vec<String> = class | ||
| .protected_constructor_args | ||
| .iter() | ||
| .map(|arg| { | ||
| format!( | ||
| "{} {}", | ||
| cpp_arg_type_to_cpp_source(&arg.cpp_type, true), | ||
| arg.name | ||
| ) | ||
| }) | ||
| .collect(); | ||
| let initialiser_list: Vec<String> = class | ||
| .protected_constructor_args | ||
| .iter() | ||
| .map(|arg| format!("{} ( std::move({}) )", arg.name, arg.name)) | ||
| .collect(); | ||
| result.push_str(&format!( | ||
| " {}({}) : {} {{}}\n", | ||
| class.name, | ||
| ctor_args_str.join(", "), | ||
| initialiser_list.join(", ") | ||
| )); | ||
| result.push_str("\n"); | ||
| } | ||
|
|
||
| for member in &class.protected_members { | ||
| result.push_str(&format!( | ||
| " {} {};\n", | ||
| cpp_arg_type_to_cpp_source(&member.cpp_type, true), | ||
| member.name | ||
| )); | ||
| } | ||
|
|
||
| result.push_str("\n"); | ||
| } | ||
|
|
||
| result.push_str("private:\n"); | ||
| for member in &class.private_members { | ||
| if member.optional { | ||
|
|
@@ -338,6 +380,8 @@ pub struct CppClass { | |
| pub name: String, | ||
| pub methods: Vec<CppMethod>, | ||
| pub enums: Vec<CppEnum>, | ||
| pub protected_constructor_args: Vec<CppArg>, | ||
| pub protected_members: Vec<CppArg>, | ||
| pub private_members: Vec<CppArg>, | ||
| } | ||
|
|
||
|
|
@@ -347,6 +391,8 @@ impl CppClass { | |
| name: sanitize_identifier(&name.into()), | ||
| methods: vec![], | ||
| enums: vec![], | ||
| protected_constructor_args: vec![], | ||
| protected_members: vec![], | ||
| private_members: vec![], | ||
| } | ||
| } | ||
|
|
@@ -365,6 +411,20 @@ impl CppClass { | |
| .expect("enums cannot be empty after push") | ||
| } | ||
|
|
||
| pub fn add_protected_constructor_arg(&mut self, arg: CppArg) -> &mut CppArg { | ||
| self.protected_constructor_args.push(arg); | ||
| self.protected_constructor_args | ||
| .last_mut() | ||
| .expect("protected_constructor_args cannot be empty after push") | ||
|
Comment on lines
+416
to
+418
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kinda redundant to check right after pushing. What is this trying to assert? |
||
| } | ||
|
|
||
| pub fn add_protected_member(&mut self, member: CppArg) -> &mut CppArg { | ||
| self.protected_members.push(member); | ||
| self.protected_members | ||
| .last_mut() | ||
| .expect("members cannot be empty after push") | ||
| } | ||
|
|
||
| pub fn add_private_member(&mut self, member: CppArg) -> &mut CppArg { | ||
| self.private_members.push(member); | ||
| self.private_members | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think I've seen this pattern before while reviewing related code. Might be worth refactoring out at some point (not urgent)