Adding some Readme stuff

This commit is contained in:
K35 2022-01-03 21:08:25 +00:00
parent aa983c9960
commit 99563959c6
3 changed files with 15 additions and 5 deletions

View File

@ -29,6 +29,10 @@ type Test {
} }
service TestService { service TestService {
@Description("This Function adds two number")
@Param("v1", "The first Number")
@Param("v2", "The second Number")
@Returns("The added values of the two numbers")
AddNumbers(v1: number, v2: number): number; AddNumbers(v1: number, v2: number): number;

View File

@ -28,6 +28,7 @@ type AddValueResponse {
service TestService { service TestService {
@Description("Add two numbers") @Description("Add two numbers")
@Param("request", "Parameter containing the two numbers") @Param("request", "Parameter containing the two numbers")
@Returns("")
AddValuesSingleParam(request: AddValueRequest): AddValueResponse; AddValuesSingleParam(request: AddValueRequest): AddValueResponse;
@Description("Add two numbers") @Description("Add two numbers")

View File

@ -308,10 +308,15 @@ export class TypescriptTarget extends CompileTarget {
(e) => `${e.name}: ${toJSType(e.type) + (e.array ? "[]" : "")}` (e) => `${e.name}: ${toJSType(e.type) + (e.array ? "[]" : "")}`
) )
.join(", "); .join(", ");
//TODO: Prio 1 : Verify and strip input parameters //TODO: Prio 1 : Verify and strip input parameters
//TODO: Prio 2 : Add optional parameters to this and the declaration file //TODO: Prio 2 : Add optional parameters to this and the declaration file
// const verifyInputs = () => {
// }
if (!fnc.return) { if (!fnc.return) {
a(1, `${fnc.name}(${params}): void {`); a(1, `${fnc.name}(${params}): void {`);1
a(2, `this._provider.sendMessage({`); a(2, `this._provider.sendMessage({`);
a(3, `jsonrpc: "2.0",`); a(3, `jsonrpc: "2.0",`);
a(3, `method: "${def.name}.${fnc.name}",`); a(3, `method: "${def.name}.${fnc.name}",`);
@ -334,11 +339,11 @@ export class TypescriptTarget extends CompileTarget {
a(3, `});`); a(3, `});`);
a(2, `}).then(result => {`); a(2, `}).then(result => {`);
if (fnc.return.array) { if (fnc.return.array) {
a(2, `for(const elm of result) {`); a(3, `for(let i = 0; i < result.length; i++) {`);
a(3, `apply_${fnc.return.type}(elm);`); a(4, `result[i] = apply_${fnc.return.type}(result[i]);`);
a(2, `}`); a(3, `}`);
} else { } else {
a(3, `apply_${fnc.return.type}(result);`); a(3, `result = apply_${fnc.return.type}(result);`);
} }
a(3, `return result;`); a(3, `return result;`);
a(2, `});`); a(2, `});`);