Update code to allow struct with one generic parameter

This commit is contained in:
2023-10-11 17:10:20 +02:00
parent 9caeb447c3
commit 613cf68fc3
6 changed files with 318 additions and 153 deletions

View File

@@ -18,17 +18,17 @@ export interface @s.name @{
export class MRPCConnector @{
url: string;
private __create_msg(service: string, method: string, data: any) @{
return @{service, method, data@};
@}
public constructor(url: string) @{
this.url = url;
@}
@for s in &rpc.services { @for m in &s.methods {
public @(s.name)_@(m.name)(@method_args(m))@method_ret(m) @{
const __msg = @{
service: '@s.name',
method: '@m.name',
data: @{@m.args.iter().map(|a| &a.name).join(",")@}
@};
const __msg = this.__create_msg('@s.name', '@m.name', @{@m.args.iter().map(|a| &a.name).join(",")@});
@if m.ret.is_some() && !m.ret_stream {return fetch(this.url, @{
method: 'POST',
body: JSON.stringify(__msg)