Skip to content

Commit 0c3475f

Browse files
committed
Don't codegen empty values in encoding functions (fixes #104)
1 parent 23dc40f commit 0c3475f

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

rust/bufferfish/src/compiler.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,8 @@ fn generate_typescript_struct_encoders(
344344
Fields::Unit => {
345345
if let Some(id) = packet_id {
346346
output.push_str(
347-
format!(
348-
"\nexport function encode{struct_name}(bf: Bufferfish, _value: {struct_name}): void {{\n",
349-
)
350-
.as_str(),
347+
format!("\nexport function encode{struct_name}(bf: Bufferfish): void {{\n",)
348+
.as_str(),
351349
);
352350

353351
if let Some(enum_name) = extract_enum_name_from_packet_id(&id)
@@ -611,17 +609,7 @@ fn generate_typescript_struct_decoders(item: ItemStruct, lines: &mut String) {
611609
lines.push_str(" ]\n");
612610
lines.push_str("}\n");
613611
}
614-
Fields::Unit => {
615-
// lines.push_str(
616-
// format!(
617-
// "\nexport function decode{struct_name}(bf: Bufferfish): {struct_name} {{\n"
618-
// )
619-
// .as_str(),
620-
// );
621-
// lines.push_str(" return {\n");
622-
// lines.push_str(" }\n");
623-
// lines.push_str("}\n");
624-
}
612+
Fields::Unit => {}
625613
}
626614
}
627615

0 commit comments

Comments
 (0)