Skip to content

Commit 0629cd5

Browse files
Import and export static methods
1 parent 1c61360 commit 0629cd5

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

crates/d/src/lib.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,9 @@ impl<'a> DInterfaceGenerator<'a> {
946946

947947
fn get_d_signature(&mut self, func: &Function) -> DSig {
948948
match &func.kind {
949-
FunctionKind::Freestanding | FunctionKind::Method(_) => {}
949+
FunctionKind::Freestanding | FunctionKind::Method(_) | FunctionKind::Static(_) => {}
950950

951951
FunctionKind::AsyncFreestanding
952-
| FunctionKind::Static(_)
953952
| FunctionKind::Constructor(_)
954953
| FunctionKind::AsyncMethod(_)
955954
| FunctionKind::AsyncStatic(_) => {
@@ -972,6 +971,10 @@ impl<'a> DInterfaceGenerator<'a> {
972971
let escaped_name = escape_d_identifier(&lower_name);
973972

974973
res.name = escaped_name.into();
974+
res.static_member = match &func.kind {
975+
FunctionKind::Static(_) => true,
976+
_ => false,
977+
};
975978

976979
res.result
977980
.push_str(&(self.optional_type_name(func.result.as_ref(), self.fqn)));
@@ -1008,11 +1011,17 @@ impl<'a> DInterfaceGenerator<'a> {
10081011
fn import_func(&mut self, func: &Function) {
10091012
match &func.kind {
10101013
FunctionKind::Freestanding => {}
1014+
FunctionKind::Constructor(_) => {
1015+
self.src.push_str(&format!(
1016+
"// TODO: Import FunctionKind::Constructor - {}\n",
1017+
func.name
1018+
));
1019+
return;
1020+
}
10111021
FunctionKind::Method(_) => {}
1022+
FunctionKind::Static(_) => {}
10121023
kind => {
1013-
self.src
1014-
.push_str(&format!("// TODO: Import {kind:?} - {}\n", func.name));
1015-
return;
1024+
todo!("Import {kind:?} - {}\n", func.name);
10161025
}
10171026
}
10181027

@@ -1114,12 +1123,14 @@ impl<'a> DInterfaceGenerator<'a> {
11141123
match &func.kind {
11151124
FunctionKind::Freestanding => {}
11161125
FunctionKind::Constructor(_) => {
1117-
todo!("Export FunctionKind::Constructor - {}\n", func.name);
1126+
self.src.push_str(&format!(
1127+
"// TODO: Export FunctionKind::Constructor - {}\n",
1128+
func.name
1129+
));
1130+
return;
11181131
}
11191132
FunctionKind::Method(_) => {}
1120-
FunctionKind::Static(_) => {
1121-
todo!("Export FunctionKind::Static - {}\n", func.name);
1122-
}
1133+
FunctionKind::Static(_) => {}
11231134
kind => {
11241135
todo!("Export {kind:?} - {}\n", func.name);
11251136
}
@@ -1389,7 +1400,7 @@ impl<'a> InterfaceGenerator<'a> for DInterfaceGenerator<'a> {
13891400
}
13901401

13911402
self.src
1392-
.push_str("void drop() {\n__import__drop(__handle);\n}\n");
1403+
.push_str("\nvoid drop() {\n__import__drop(__handle);\n}\n");
13931404

13941405
self.src.push_str(&format!(
13951406
"@wasmImport!(\"{}\", \"[resource-drop]{}\")\n",

0 commit comments

Comments
 (0)