summaryrefslogtreecommitdiffstats
path: root/vendor/windows-bindgen/src/rust/method_names.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/windows-bindgen/src/rust/method_names.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/windows-bindgen/src/rust/method_names.rs')
-rw-r--r--vendor/windows-bindgen/src/rust/method_names.rs38
1 files changed, 32 insertions, 6 deletions
diff --git a/vendor/windows-bindgen/src/rust/method_names.rs b/vendor/windows-bindgen/src/rust/method_names.rs
index 2d5a508ae..14a9d6501 100644
--- a/vendor/windows-bindgen/src/rust/method_names.rs
+++ b/vendor/windows-bindgen/src/rust/method_names.rs
@@ -7,8 +7,8 @@ impl MethodNames {
Self(BTreeMap::new())
}
- pub fn add(&mut self, writer: &Writer, method: MethodDef) -> TokenStream {
- let name = method_def_special_name(writer.reader, method);
+ pub fn add(&mut self, method: MethodDef) -> TokenStream {
+ let name = method_def_special_name(method);
let overload = self.0.entry(name.to_string()).or_insert(0);
*overload += 1;
if *overload > 1 {
@@ -18,13 +18,39 @@ impl MethodNames {
}
}
- pub fn add_vtable_types(&mut self, writer: &Writer, def: TypeDef) {
- for def in type_def_vtables(writer.reader, def) {
+ pub fn add_vtable_types(&mut self, def: TypeDef) {
+ for def in type_def_vtables(def) {
if let Type::TypeDef(def, _) = def {
- for method in writer.reader.type_def_methods(def) {
- self.add(writer, method);
+ for method in def.methods() {
+ self.add(method);
}
}
}
}
}
+
+fn method_def_special_name(row: MethodDef) -> String {
+ let name = row.name();
+ if row.flags().contains(MethodAttributes::SpecialName) {
+ if name.starts_with("get") {
+ name[4..].to_string()
+ } else if name.starts_with("put") {
+ format!("Set{}", &name[4..])
+ } else if name.starts_with("add") {
+ name[4..].to_string()
+ } else if name.starts_with("remove") {
+ format!("Remove{}", &name[7..])
+ } else {
+ name.to_string()
+ }
+ } else {
+ if let Some(attribute) = row.find_attribute("OverloadAttribute") {
+ for (_, arg) in attribute.args() {
+ if let Value::String(name) = arg {
+ return name;
+ }
+ }
+ }
+ name.to_string()
+ }
+}