Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 25 additions & 48 deletions api/csolution-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,18 @@ components:
- properties:
result:
$ref: '#/components/schemas/SuccessResult'
LoadSolutionParams:
type: object
properties:
solution:
type: string
description: Path to <solution>.csolution.yml
activeTarget:
type: string
description: Active target set in the format <target-type>[@<set>]
required:
- solution
- activeTarget
LoadSolutionRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand All @@ -971,17 +983,7 @@ components:
type: string
const: LoadSolution
params:
type: object
properties:
solution:
type: string
description: Path to <solution>.csolution.yml
activeTarget:
type: string
description: Active target set in the format <target-type>[@<set>]
required:
- solution
- activeTarget
$ref: '#/components/schemas/LoadSolutionParams'
LoadSolutionResponse:
allOf:
- $ref: '#/x-jsonrpc-envelope-response'
Expand Down Expand Up @@ -1281,6 +1283,15 @@ components:
- properties:
result:
$ref: '#/components/schemas/DraftProjectsInfo'
ConvertSolutionParams:
allOf:
- $ref: '#/components/schemas/LoadSolutionParams'
- properties:
updateRte:
type: boolean
description: Create/update configuration files
required:
- updateRte
ConvertSolutionRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand All @@ -1289,21 +1300,7 @@ components:
type: string
const: ConvertSolution
params:
type: object
properties:
solution:
type: string
description: Path to <solution>.csolution.yml
activeTarget:
type: string
description: Active target set in the format <target-type>[@<set>]
updateRte:
type: boolean
description: Create/update configuration files
required:
- solution
- activeTarget
- updateRte
$ref: '#/components/schemas/ConvertSolutionParams'
ConvertSolutionResult:
allOf:
- $ref: '#/components/schemas/SuccessResult'
Expand Down Expand Up @@ -1332,17 +1329,7 @@ components:
type: string
const: DiscoverLayers
params:
type: object
properties:
solution:
type: string
description: Path to <solution>.csolution.yml
activeTarget:
type: string
description: Active target set in the format <target-type>[@<set>]
required:
- solution
- activeTarget
$ref: '#/components/schemas/LoadSolutionParams'
DiscoverLayersResponse:
allOf:
- $ref: '#/x-jsonrpc-envelope-response'
Expand All @@ -1357,17 +1344,7 @@ components:
type: string
const: ListMissingPacks
params:
type: object
properties:
solution:
type: string
description: Path to <solution>.csolution.yml
activeTarget:
type: string
description: Active target set in the format <target-type>[@<set>]
required:
- solution
- activeTarget
$ref: '#/components/schemas/LoadSolutionParams'
ListMissingPacksResult:
allOf:
- $ref: '#/components/schemas/SuccessResult'
Expand Down
36 changes: 29 additions & 7 deletions codegen/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,26 @@ using namespace jsonrpccxx;\n`;
}
}

public genCppParams(name: string, cppParams: string[], cppRegParams: string[]) {
const struct = this.structs[name];
if (struct) {
if (struct.extends) {
for (const parent of struct.extends) {
if (parent in this.structs) {
this.genCppParams(parent, cppParams, cppRegParams);
}
}
}
if (struct.members) {
for (const element of struct.members) {
const cppType = element.cppType in this.structs ? `RpcArgs::${element.cppType}` : element.cppType;
cppParams.push(`const ${cppType}& ${element.name}`);
cppRegParams.push(`"${element.name}"`);
}
}
}
}

public collectFunction(name: string, params: any, result: any, description?: string) {
const cppResult = this.getType(name, result, 'Result', 'RpcArgs::').cpp;
let cppFunction = `virtual ${cppResult} ${name}(`;
Expand All @@ -282,13 +302,15 @@ using namespace jsonrpccxx;\n`;
const tsFunction = `${this.pascalToCamel(name)}(${tsParamsType ? `args: ${tsParamsType}` : ``}): Promise<${tsResultType}>`;
const tsImplementation = `this.get('${name}'${tsParamsType ? `, args` : ``})`;

if (params && params.properties) {
const cppParams: string[] = [];
const cppRegParams: string[] = [];
for (const [param, item] of Object.entries(params.properties)) {
cppParams.push(`const ${this.getType(name, item, '', 'RpcArgs::').cpp}& ${param}`);
cppRegParams.push(`"${param}"`);
}
let paramsName = this.getTypeName(name, 'Params');
if ((params as any)?.$ref) {
const ref = (params as any).$ref.match(/^#\/components\/schemas\/(.*)/);
paramsName = ref[1];
}
const cppParams: string[] = [];
const cppRegParams: string[] = [];
this.genCppParams(paramsName, cppParams, cppRegParams);
if (cppParams.length > 0) {
cppFunction += cppParams.join(", ");
cppRegistration += `, { ${cppRegParams.join(', ')} }`;
} else {
Expand Down