Skip to content

Commit

Permalink
Merge pull request #30 from rdkcentral/development/jsongen-clash-dete…
Browse files Browse the repository at this point in the history
…ction-fix

[JsonGen] Improve name clash detection
  • Loading branch information
pwielders authored Jul 27, 2023
2 parents de8f53f + 3418a04 commit 5241f67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
10 changes: 7 additions & 3 deletions JsonGenerator/source/header_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def ConvertParameter(var):
properties["example"] = pair[0]
properties["description"] = pair[1]
else:
properties["description"] = var.meta.brief
properties["description"] = var.meta.brief.strip()

return properties

Expand Down Expand Up @@ -592,7 +592,7 @@ def BuildResult(vars, is_property=False):
obj["obsolete"] = True

if method.retval.meta.brief:
obj["summary"] = method.retval.meta.brief
obj["summary"] = method.retval.meta.brief.strip()

if method.retval.meta.details:
obj["description"] = method.retval.meta.details
Expand Down Expand Up @@ -646,18 +646,22 @@ def BuildResult(vars, is_property=False):
varsidx = 1
else:
raise CppParseError(method.vars[0], "failed to determine type of notification id parameter")

if method.retval.meta.is_listener:
obj["statuslistener"] = True

params = BuildParameters(method.vars[varsidx:], rpc_format, False)
retvals = BuildResult(method.vars[varsidx:])
if retvals and retvals["type"] != "null":
raise CppParseError(method, "output parameters are invalid for JSON-RPC events")

if method.retval.meta.is_deprecated:
obj["deprecated"] = True
elif method.retval.meta.is_obsolete:
obj["obsolete"] = True

if method.retval.meta.brief:
obj["summary"] = method.retval.meta.brief
obj["summary"] = method.retval.meta.brief.strip()

if method.retval.meta.details:
obj["description"] = method.retval.meta.details
Expand Down
34 changes: 23 additions & 11 deletions ProxyStubGenerator/CppParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,12 @@ def __Search(tree, found, T):
else:
ref |= Ref.POINTER
elif self.type[typeIdx] == "&":
if ref & Ref.POINTER:
raise ParserError("pointer to a reference is not valid C++")
ref |= Ref.REFERENCE
elif self.type[typeIdx] == "&&":
if ref & Ref.POINTER:
raise ParserError("pointer to a reference is not valid C++")
ref |= Ref.RVALUE_REFERENCE
elif self.type[typeIdx] == "const":
ref |= Ref.CONST
Expand Down Expand Up @@ -1039,18 +1043,22 @@ def __init__(self, parent_block, name, ret_type, valid_specifiers=["static", "ex
self.stub = False
self.is_excluded = False

for method in self.parent.methods:
if method.name == self.name:
if self.parent.is_json:
if method.retval.meta.is_property:
if method.retval.meta.text:
self.retval.meta.text = method.retval.meta.text
if method.retval.meta.alt:
self.retval.meta.alt = method.retval.meta.alt
elif not method.omit and not method.is_excluded and not method.retval.meta.text:
raise ParserError("'%s': JSON-RPC name clash detected, resolve with @text tag" % method.name)
def Append(self):
if not self.is_excluded and not self.omit:
test_name = self.retval.meta.text if self.retval.meta.text else self.name
for method in self.parent.methods:
name = method.retval.meta.text if method.retval.meta.text else method.name
if name == test_name:
if self.parent.is_json:
if method.retval.meta.is_property:
if method.retval.meta.text:
self.retval.meta.text = method.retval.meta.text
if method.retval.meta.alt:
self.retval.meta.alt = method.retval.meta.alt
elif not method.omit and not method.is_excluded:
raise ParserError("'%s': JSON-RPC name clash detected, resolve with @text tag" % name)

break
break

self.parent.methods.append(self)

Expand Down Expand Up @@ -1987,6 +1995,8 @@ def Parse(contents,log = None):
raise ParserError("@compliant used without @json")
if collapsed_next or extended_next:
raise ParserError("@compliant and @uncompliant used together")
if exclude_next:
raise ParserError("@json:omit is invalid here (applies to methods only)")

json_next = False
json_version = ""
Expand Down Expand Up @@ -2133,6 +2143,8 @@ def Parse(contents,log = None):
method.specifiers.append(" ".join(last_template_def))
last_template_def = []

method.Append()

# try to detect a function/macro call
function_call = not ret_type and ((name != current_block[-1].name) and (name !=
("~" + current_block[-1].name)))
Expand Down

0 comments on commit 5241f67

Please sign in to comment.