@@ -271,6 +271,26 @@ using namespace jsonrpccxx;\n`;
271271 }
272272 }
273273
274+ public genCppParams ( name : string , cppParams : string [ ] , cppRegParams : string [ ] ) {
275+ const struct = this . structs [ name ] ;
276+ if ( struct ) {
277+ if ( struct . extends ) {
278+ for ( const parent of struct . extends ) {
279+ if ( parent in this . structs ) {
280+ this . genCppParams ( parent , cppParams , cppRegParams ) ;
281+ }
282+ }
283+ }
284+ if ( struct . members ) {
285+ for ( const element of struct . members ) {
286+ const cppType = element . cppType in this . structs ? `RpcArgs::${ element . cppType } ` : element . cppType ;
287+ cppParams . push ( `const ${ cppType } & ${ element . name } ` ) ;
288+ cppRegParams . push ( `"${ element . name } "` ) ;
289+ }
290+ }
291+ }
292+ }
293+
274294 public collectFunction ( name : string , params : any , result : any , description ?: string ) {
275295 const cppResult = this . getType ( name , result , 'Result' , 'RpcArgs::' ) . cpp ;
276296 let cppFunction = `virtual ${ cppResult } ${ name } (` ;
@@ -282,13 +302,15 @@ using namespace jsonrpccxx;\n`;
282302 const tsFunction = `${ this . pascalToCamel ( name ) } (${ tsParamsType ? `args: ${ tsParamsType } ` : `` } ): Promise<${ tsResultType } >` ;
283303 const tsImplementation = `this.get('${ name } '${ tsParamsType ? `, args` : `` } )` ;
284304
285- if ( params && params . properties ) {
286- const cppParams : string [ ] = [ ] ;
287- const cppRegParams : string [ ] = [ ] ;
288- for ( const [ param , item ] of Object . entries ( params . properties ) ) {
289- cppParams . push ( `const ${ this . getType ( name , item , '' , 'RpcArgs::' ) . cpp } & ${ param } ` ) ;
290- cppRegParams . push ( `"${ param } "` ) ;
291- }
305+ let paramsName = this . getTypeName ( name , 'Params' ) ;
306+ if ( ( params as any ) ?. $ref ) {
307+ const ref = ( params as any ) . $ref . match ( / ^ # \/ c o m p o n e n t s \/ s c h e m a s \/ ( .* ) / ) ;
308+ paramsName = ref [ 1 ] ;
309+ }
310+ const cppParams : string [ ] = [ ] ;
311+ const cppRegParams : string [ ] = [ ] ;
312+ this . genCppParams ( paramsName , cppParams , cppRegParams ) ;
313+ if ( cppParams . length > 0 ) {
292314 cppFunction += cppParams . join ( ", " ) ;
293315 cppRegistration += `, { ${ cppRegParams . join ( ', ' ) } }` ;
294316 } else {
0 commit comments