Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into develop
  • Loading branch information
codac-dev committed Apr 17, 2023
2 parents 1bb366b + 91cb113 commit 6a3a0c5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 11 deletions.
22 changes: 12 additions & 10 deletions Resources/Python/Source/StandardParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,26 @@ def __init__(self):
field.addParseAction(tokenMap(str.rstrip), tokenMap(str.lstrip)) #Remove any spaces from the field

string = QuotedString(quoteChar='"', multiline=True)
string_no_quotes = Word(printables, excludeChars='{}=/*')
string_no_quotes = Word(printables, excludeChars='{}=/*,')

#The code below was givign issues when comparing hex numbers against unquoted strings.
#number = pyparsing_common.number()
#hex_number = pyparsing_common.hex_integer()
#scalar_value = (number | hex_number | string)
scalar_value = (string | string_no_quotes)

#The code below does not work with space delimited values.
#arr_list = Forward()
#arr_list <<= delimitedList(scalar_value, ',')
#arr_list.setParseAction(lambda t: ParseResults(t[:]))
arr_list = OneOrMore(scalar_value)

arr_list = delimitedList(scalar_value)
arr_value = Group(LBRACE + arr_list + RBRACE)
mat_value = Group(LBRACE + OneOrMore(arr_value) + RBRACE)
cub_value = Group(LBRACE + OneOrMore(mat_value) + RBRACE)
variable_value = scalar_value | arr_value | mat_value | cub_value

arr_list_spaces = OneOrMore(scalar_value)
arr_value_spaces = Group(LBRACE + arr_list_spaces + RBRACE)

mat_value = Group(LBRACE + delimitedList(arr_value) + RBRACE)
mat_value_spaces = Group(LBRACE + OneOrMore(arr_value_spaces) + RBRACE)

cub_value = Group(LBRACE + delimitedList(mat_value) + RBRACE)
cub_value_spaces = Group(LBRACE + OneOrMore(mat_value_spaces) + RBRACE)
variable_value = scalar_value | arr_value | mat_value | cub_value | arr_value_spaces | mat_value_spaces | cub_value_spaces

node = Forward()

Expand Down
36 changes: 36 additions & 0 deletions Resources/Python/Test/Test_StandardParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def test_arrays(self):
self.assertTrue(ret['A'][1] == 'B')
self.assertTrue(ret['A'][2] == '3')

cfg = 'A = {"A", "B", 3,"4"}'
ret = self.parser.parse_string(cfg)
self.assertTrue(ret['A'][0] == 'A')
self.assertTrue(ret['A'][1] == 'B')
self.assertTrue(ret['A'][2] == '3')
self.assertTrue(ret['A'][3] == '4')

"""
cfg = 'A = {{2} {3 -3} {"A" "B" 3} {0}}'
ret = self.parser.parse_string(cfg)
self.assertTrue(ret['A'][0][0] == '2')
Expand All @@ -95,6 +103,22 @@ def test_arrays(self):
self.assertTrue(ret['A'][2][1] == 'B')
self.assertTrue(ret['A'][2][2] == '3')
self.assertTrue(ret['A'][3][0] == '0')
"""

cfg = 'A = {3, -3}'
ret = self.parser.parse_string(cfg)
self.assertTrue(ret['A'][0] == '3')
self.assertTrue(ret['A'][1] == '-3')

cfg = 'A = {{2}, {3, -3}, {"A", "B", 3}, {0}}'
ret = self.parser.parse_string(cfg)
self.assertTrue(ret['A'][0][0] == '2')
self.assertTrue(ret['A'][1][0] == '3')
self.assertTrue(ret['A'][1][1] == '-3')
self.assertTrue(ret['A'][2][0] == 'A')
self.assertTrue(ret['A'][2][1] == 'B')
self.assertTrue(ret['A'][2][2] == '3')
self.assertTrue(ret['A'][3][0] == '0')

cfg = 'A = {{{1 2} /*Ignore me*/ {3 4}} {{5} {"A" "B"} {"C"}}}//Ignore me!'
ret = self.parser.parse_string(cfg)
Expand All @@ -107,6 +131,18 @@ def test_arrays(self):
self.assertTrue(ret['A'][1][1][1] == 'B')
self.assertTrue(ret['A'][1][2][0] == 'C')

cfg = 'A = {{{1, 2}, /*Ignore me*/ {3, 4}}, {{5}, {"A", "B"}, {"C"}}}//Ignore me!'
ret = self.parser.parse_string(cfg)
self.assertTrue(ret['A'][0][0][0] == '1')
self.assertTrue(ret['A'][0][0][1] == '2')
self.assertTrue(ret['A'][0][1][0] == '3')
self.assertTrue(ret['A'][0][1][1] == '4')
self.assertTrue(ret['A'][1][0][0] == '5')
self.assertTrue(ret['A'][1][1][0] == 'A')
self.assertTrue(ret['A'][1][1][1] == 'B')
self.assertTrue(ret['A'][1][2][0] == 'C')


def test_cfg_file(self):
ret = {}
with open('test_file.cfg') as f:
Expand Down
5 changes: 4 additions & 1 deletion Source/Core/BareMetal/L5GAMs/MemoryMapOutputBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ MemoryMapOutputBroker::~MemoryMapOutputBroker() {

bool MemoryMapOutputBroker::Execute() {
uint32 n;
/*lint -e{613} null pointer checked before.*/
uint32 i = dataSource->GetCurrentStateBuffer();
bool ret = true;
for (n = 0u; (n < numberOfCopies) && (ret); n++) {
if (copyTable != NULL_PTR(MemoryMapBrokerCopyTableEntry *)) {
ret = MemoryOperationsHelper::Copy(copyTable[n].dataSourcePointer, copyTable[n].gamPointer, copyTable[n].copySize);
uint32 dataSourceIndex = ((i * numberOfCopies) + n);
ret = MemoryOperationsHelper::Copy(copyTable[dataSourceIndex].dataSourcePointer, copyTable[n].gamPointer, copyTable[n].copySize);
}
}
return ret;
Expand Down

0 comments on commit 6a3a0c5

Please sign in to comment.