Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Fixing rust operations with 0 parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkedy committed Jul 15, 2022
1 parent 07cacec commit 6821408
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wapc/widl-codegen",
"version": "0.0.9",
"version": "0.0.10",
"description": "Flexible code generation using WIDL",
"keywords": [
"webassembly",
Expand Down
24 changes: 15 additions & 9 deletions src/rust/wrappers_visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class WrapperFuncsVisitor extends BaseVisitor {
const operation = context.operation!;
this.write(
`#[cfg(feature = "guest")]
fn ${functionName(
operation.name.value
)}_wrapper(input_payload: &[u8]) -> CallResult {\n`
fn ${functionName(operation.name.value)}_wrapper(${
operation.parameters.length == 0 ? "_" : ""
}input_payload: &[u8]) -> CallResult {\n`
);
if (operation.isUnary()) {
this.write(`let input = deserialize::<${expandType(
Expand All @@ -89,12 +89,18 @@ fn ${functionName(
).toUpperCase()}.read().unwrap().unwrap();
let result = lock(input)?;\n`);
} else {
this.write(`let input = deserialize::<${capitalize(
operation.name.value
)}Args>(input_payload)?;
let lock = ${functionName(
operation.name.value
).toUpperCase()}.read().unwrap().unwrap();\n`);
if (operation.parameters.length > 0) {
this.write(
`let input = deserialize::<${capitalize(
operation.name.value
)}Args>(input_payload)?;\n`
);
}
this.write(
`let lock = ${functionName(
operation.name.value
).toUpperCase()}.read().unwrap().unwrap();\n`
);
this.write(
`let result = lock(${varAccessArg("input", operation.parameters)})?;\n`
);
Expand Down

0 comments on commit 6821408

Please sign in to comment.