Skip to content

Commit 88d3ddb

Browse files
committed
Set number as schema type for address and size nodes
1 parent 05218d3 commit 88d3ddb

File tree

9 files changed

+43
-48
lines changed

9 files changed

+43
-48
lines changed

external/json-schema-validator.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ index 0beb613..0a9122b 100644
6565
if (type)
6666
type->validate(ptr, instance, patch, e);
6767
- else
68-
+ else if (!instance.is_number())
68+
+ else if (!instance.is_string() || instance.get_ref<const json::string_t&>().find("0x") != 0)
6969
e.error(ptr, instance, "unexpected instance type");
7070

7171
if (enum_.first) {

external/yaml-cpp.patch

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,6 @@ index 3dbe401..0dd0b17 100644
9090
case TildeNull:
9191
_Set(m_nullFmt, value, scope);
9292
return true;
93-
diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp
94-
index 6cdf6de..f80d722 100644
95-
--- a/src/emitterutils.cpp
96-
+++ b/src/emitterutils.cpp
97-
@@ -159,6 +159,11 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
98-
return false;
99-
}
100-
101-
+ // check hexadecimal prefix
102-
+ if (str.find("0x") == 0) {
103-
+ return false;
104-
+ }
105-
+
106-
// check the start
107-
const RegEx& start = (flowType == FlowType::Flow ? Exp::PlainScalarInFlow()
108-
: Exp::PlainScalar());
10993
diff --git a/src/exceptions.cpp b/src/exceptions.cpp
11094
index 43a7976..af99fd6 100644
11195
--- a/src/exceptions.cpp

libs/ymlschemachecker/test/data/sample-data/clayer.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
layer:
2-
name: false
2+
name: 2
33
defines:
44
- DEF_LAYER2
55
- DEF: oxff

tools/projmgr/include/ProjMgrYamlParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class ProjMgrYamlParser {
262262
void ParseProcessor(const YAML::Node& parent, ProcessorItem& processor);
263263
void ParseBoolean(const YAML::Node& parent, const std::string& key, bool& value, bool def);
264264
void ParseString(const YAML::Node& parent, const std::string& key, std::string& value);
265+
void ParseNumber(const YAML::Node& parent, const std::string& file, const std::string& key, std::string& value);
265266
void ParseInt(const YAML::Node& parent, const std::string& key, int& value);
266267
void ParseVector(const YAML::Node& parent, const std::string& key, std::vector<std::string>& value);
267268
void ParseVectorOfStringPairs(const YAML::Node& parent, const std::string& key, std::vector<std::pair<std::string, std::string>>& value);

tools/projmgr/schemas/common.schema.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,8 +1659,8 @@
16591659
"name": { "type": "string", "description": "Memory identifier." },
16601660
"access": { "type": "string", "description": "Memory access permission." },
16611661
"algorithm":{ "type": "string", "description": "Programming algorithm." },
1662-
"start": { "type": "string", "description": "Memory start address." },
1663-
"size": { "type": "string", "description": "Memory size." }
1662+
"start": { "type": "number", "description": "Memory start address." },
1663+
"size": { "type": "number", "description": "Memory size." }
16641664
},
16651665
"additionalProperties": false
16661666
},
@@ -1674,10 +1674,10 @@
16741674
"type": "object",
16751675
"properties": {
16761676
"algorithm":{ "type": "string", "description": "Programming algorithm." },
1677-
"start": { "type": "string", "description": "Memory start address." },
1678-
"size": { "type": "string", "description": "Memory size." },
1679-
"ram-start":{ "type": "string", "description": "RAM Memory start address." },
1680-
"ram-size": { "type": "string", "description": "RAM Memory size." },
1677+
"start": { "type": "number", "description": "Memory start address." },
1678+
"size": { "type": "number", "description": "Memory size." },
1679+
"ram-start":{ "type": "number", "description": "RAM Memory start address." },
1680+
"ram-size": { "type": "number", "description": "RAM Memory size." },
16811681
"default": { "type": "boolean", "description": "Default memory." }
16821682
},
16831683
"additionalProperties": false

tools/projmgr/src/ProjMgr.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,21 +524,21 @@ bool ProjMgr::GenerateYMLConfigurationFiles() {
524524
}
525525
}
526526

527-
// Generate cbuild index file
528-
if (!m_allContexts.empty()) {
529-
map<string, ExecutesItem> executes;
530-
m_worker.GetExecutes(executes);
531-
if (!m_emitter.GenerateCbuildIndex(m_processedContexts, m_failedContext, executes)) {
532-
return false;
533-
}
534-
}
535-
536527
// Generate cbuild-run file
537528
if (m_contextSet && !m_processedContexts.empty()) {
538529
if (!m_runDebug.CollectSettings(m_processedContexts)) {
539-
return false;
530+
result = false;
540531
}
541532
if (!m_emitter.GenerateCbuildRun(m_runDebug.Get())) {
533+
result = false;
534+
}
535+
}
536+
537+
// Generate cbuild index file
538+
if (!m_allContexts.empty()) {
539+
map<string, ExecutesItem> executes;
540+
m_worker.GetExecutes(executes);
541+
if (!m_emitter.GenerateCbuildIndex(m_processedContexts, m_failedContext, executes)) {
542542
return false;
543543
}
544544
}

tools/projmgr/src/ProjMgrYamlParser.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,16 @@ void ProjMgrYamlParser::ParseString(const YAML::Node& parent, const string& key,
362362
}
363363
}
364364

365+
void ProjMgrYamlParser::ParseNumber(const YAML::Node& parent, const string& file, const string& key, string& value) {
366+
if (parent[key].IsDefined()) {
367+
value = parent[key].as<string>();
368+
if (!regex_match(value, regex("^(0x[0-9a-fA-F]+)$|^([0-9]*)$"))) {
369+
YAML::Mark mark = parent[key].Mark();
370+
ProjMgrLogger::Get().Warn("number must be integer or hexadecimal prefixed by 0x", "", file, mark.line + 1, mark.column + 1);
371+
}
372+
}
373+
}
374+
365375
void ProjMgrYamlParser::ParseInt(const YAML::Node& parent, const string& key, int& value) {
366376
if (parent[key].IsDefined()) {
367377
value = parent[key].as<int>();
@@ -920,9 +930,9 @@ bool ProjMgrYamlParser::ParseTargetType(const YAML::Node& parent, const string&
920930
MemoryItem memoryItem;
921931
ParseString(memoryEntry, YAML_NAME, memoryItem.name);
922932
ParseString(memoryEntry, YAML_ACCESS, memoryItem.access);
923-
ParseString(memoryEntry, YAML_START, memoryItem.start);
924-
ParseString(memoryEntry, YAML_SIZE, memoryItem.size);
925933
ParseString(memoryEntry, YAML_ALGORITHM, memoryItem.algorithm);
934+
ParseNumber(memoryEntry, file, YAML_START, memoryItem.start);
935+
ParseNumber(memoryEntry, file, YAML_SIZE, memoryItem.size);
926936
targetType.memory.push_back(memoryItem);
927937
}
928938
}

tools/projmgr/test/data/TestRunDebug/ref/TestHW.cbuild-run.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ cbuild-run:
99
board-pack: ARM::[email protected]
1010
programming:
1111
- algorithm: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/Flash/CortexM4Device.FLM
12-
start: "0x00000000"
13-
size: "0x00020000"
12+
start: 0x00000000
13+
size: 0x00020000
1414
- algorithm: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/Flash/CortexM4SubFamily.FLM
15-
start: "0x00000000"
16-
size: "0x00040000"
15+
start: 0x00000000
16+
size: 0x00040000
1717
default: true
1818
- algorithm: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/Flash/FAMILY.FLM
19-
start: "0x00000000"
20-
size: "0x00040000"
19+
start: 0x00000000
20+
size: 0x00040000
2121
default: true
2222
- algorithm: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/Flash/BOARD.FLM
23-
start: "0x80000000"
24-
size: "0x00020000"
23+
start: 0x80000000
24+
size: 0x00020000
2525
default: true
2626
- algorithm: ../data/TestRunDebug/CustomAlgo.flm
27-
start: "0x80000000"
28-
size: "0x00010000"
27+
start: 0x80000000
28+
size: 0x00010000
2929
system-descriptions:
3030
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/SVD/ARMCM4.svd
3131
type: svd

tools/projmgr/test/data/TestRunDebug/run-debug.csolution.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ solution:
99
board: RteTest Test device variant
1010
device: RteTest_ARMCM4_NOFP
1111
memory:
12-
- start: "0x80000000"
13-
size: "0x00010000"
12+
- start: 0x80000000
13+
size: 0x00010000
1414
name: CustomMemory
1515
access: rwx
1616
algorithm: CustomAlgo.flm

0 commit comments

Comments
 (0)