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: 65 additions & 8 deletions api/csolution-openapi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: csolution rpc
version: 0.0.7
version: 0.0.8
description: Specification of remote procedure call methods for CMSIS csolution integration
license:
name: Apache 2.0
Expand Down Expand Up @@ -87,6 +87,17 @@ paths:
'200':
description: OK
content: {application/json: {schema: {$ref: '#/components/schemas/GetUsedItemsResponse'}}}
/rpc/GetContextInfo:
post:
summary: Get combined context info
description: Get combined context info (device, board, variables, components and packs used)
tags: [/rpc]
requestBody:
content: {application/json: {schema: {$ref: '#/components/schemas/GetContextInfoRequest'}}}
responses:
'200':
description: OK
content: {application/json: {schema: {$ref: '#/components/schemas/GetContextInfoResponse'}}}
/rpc/GetPacksInfo:
post:
summary: Get packs information
Expand Down Expand Up @@ -288,6 +299,10 @@ components:
description: optional error/warning/info message
required:
- success
Attributes:
type: object
additionalProperties:
type: string
Common:
type: object
properties:
Expand Down Expand Up @@ -391,9 +406,8 @@ components:
type: string
description: Processor core type
attributes:
type: object
additionalProperties:
type: string
$ref: '#/components/schemas/Attributes'
description: Processor attributes
required:
- core
Memory:
Expand Down Expand Up @@ -724,6 +738,32 @@ components:
required:
- components
- packs
Variables:
type: object
additionalProperties:
type: string
description: Resolved context variables
ContextInfo:
allOf:
- $ref: '#/components/schemas/UsedItems'
- properties:
board:
$ref: '#/components/schemas/Board'
device:
$ref: '#/components/schemas/Device'
pname:
type: string
description: Processor name used in context
variables:
$ref: '#/components/schemas/Variables'
attributes:
$ref: '#/components/schemas/Attributes'
description: RTE target attributes
required:
- device
- pname
- attributes
- variables
LogMessages:
allOf:
- $ref: '#/components/schemas/SuccessResult'
Expand Down Expand Up @@ -918,10 +958,7 @@ components:
- $ref: '#/components/schemas/SuccessResult'
- properties:
variables:
type: object
additionalProperties:
type: string
description: Resolved context variables
$ref: '#/components/schemas/Variables'
required:
- variables
GetVariablesRequest:
Expand Down Expand Up @@ -1127,6 +1164,26 @@ components:
- properties:
result:
$ref: '#/components/schemas/UsedItems'
GetContextInfoRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
- properties:
method:
type: string
const: GetContextInfo
params:
type: object
properties:
context:
type: string
required:
- context
GetContextInfoResponse:
allOf:
- $ref: '#/x-jsonrpc-envelope-response'
- properties:
result:
$ref: '#/components/schemas/ContextInfo'
GetDeviceListRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand Down
22 changes: 20 additions & 2 deletions codegen/src/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Arm Limited. All rights reserved.
* Copyright (c) 2025-2026 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -44,10 +44,16 @@ export interface Member {
optional?: boolean;
}

export interface CustomType {
cppType: string;
tsType: string;
}

export interface Struct {
description?: string;
members?: Member[];
extends?: string[];
customType?: CustomType;
}

export interface Function {
Expand All @@ -66,7 +72,7 @@ export class Codegen {

readonly header =
`/*
* Copyright (c) 2025 Arm Limited. All rights reserved.
* Copyright (c) 2025-2026 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -257,6 +263,12 @@ using namespace jsonrpccxx;\n`;
this.collectStructs(this.getTypeName(name), item);
}
this.collectStruct(parent, obj.items ?? obj);
} else if (obj.additionalProperties) {
// Handle types defined with additionalProperties (e.g., map/record types)
const {cpp, ts} = this.getType(parent, obj);
this.structs[parent] = {
description: obj.description,
customType: { cppType: cpp, tsType: ts } };
}
if (obj.allOf && Array.isArray(obj.allOf)) {
for (const item of obj.allOf) {
Expand Down Expand Up @@ -394,6 +406,9 @@ using namespace jsonrpccxx;\n`;
let structContent = '';
const forwardDeclaration = new Set<string>;
//TODO: content += `${struct.description ? ` // ${struct.description}\n` : ''}`;
if (struct.customType) {
structContent += ` using ${name} = ${struct.customType.cppType};\n`;
}
if (struct.members) {
structContent += ` struct ${name}`;
if (struct.extends) {
Expand Down Expand Up @@ -464,6 +479,9 @@ ${this.genCppNamespace()}\n${this.genCppClass()}\n${this.cppFooter}\n`;
let content = '';
for (const name in this.structs) {
const struct = this.structs[name];
if (struct.customType) {
content += `export type ${name} = ${struct.customType.tsType};\n`;
}
if (struct.members) {
content += `export interface ${name}`;
if (struct.extends) {
Expand Down