Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4 4 #52

Closed
wants to merge 25 commits into from
Closed

R4 4 #52

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0952147
[StubGen] Support int24
sebaszm Apr 4, 2023
e0ce817
Merge pull request #14 from rdkcentral/development/int24
pwielders Apr 4, 2023
a391e08
[StubGen] Also consider non-pure-virtual methods for interface dump (…
sebaszm Apr 7, 2023
36b7a70
[JsonGen] Restore event listener functionality
sebaszm Apr 7, 2023
e57de7c
Merge pull request #16 from rdkcentral/development/restore-event-list…
pwielders Apr 14, 2023
d8f1a5a
[Stubgen] Allow controlling of security options globally
sebaszm Apr 27, 2023
721a6c0
Merge pull request #17 from rdkcentral/development/add-security-opt-t…
pwielders Apr 28, 2023
a718680
[StubGen] Fix @stubgen:skip when placed in an included file (#18)
sebaszm May 9, 2023
a9a2ca1
[JsonGen] Do not attempt emitting RPC code for destructors (#19)
sebaszm May 9, 2023
dcb9c15
[JsonGen] Add --no-versioning and --no-push-warning options
sebaszm May 9, 2023
b7e6fca
Merge pull request #20 from rdkcentral/development/json-gen-add-bc-op…
pwielders May 9, 2023
65649a5
[JsonGen] On no-push-warnings use plain gcc pragma instead
sebaszm May 12, 2023
ec6376d
Merge pull request #21 from rdkcentral/development/use-pragma-instead
MFransen69 May 12, 2023
b92a2d7
Merge branch 'master' into R4
Divya-563 May 22, 2023
3936d99
Change Json generation not identical case to Warn
HaseenaSainul May 22, 2023
dd8aeb0
Merge pull request #23 from rdkcentral/development/METROL-761
pwielders May 23, 2023
383c045
[JsonGen] Don't emit enum registration tables for aliases (#22)
sebaszm May 23, 2023
5aef2f9
[JsonGen] Fix alt and text tags for properties, detect name clashes
sebaszm Jun 2, 2023
83014d7
Merge pull request #24 from rdkcentral/development/fix-alt-text-for-p…
pwielders Jun 5, 2023
861344f
[JsonGen] Add support for prefix tag
sebaszm Jun 21, 2023
06c1580
Merge pull request #25 from rdkcentral/developement/jsongen-prefix
pwielders Jun 22, 2023
aceb7cc
ConfigGenerator: add missing parameters for Plugin::Config
bramoosterhuis Jun 24, 2023
ec35b9f
Merge pull request #26 from rdkcentral/development/add-missing-config…
pwielders Jun 25, 2023
2502d51
[JsonGen] Fix interfaces in namespaces
sebaszm Jun 27, 2023
790c7f0
Merge pull request #27 from rdkcentral/development/fix-interfaces-in-…
pwielders Jun 27, 2023
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
2 changes: 1 addition & 1 deletion ConfigGenerator/config_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ def ordered(obj):
json2 = ordered(json.load(json_file_2)) if args.ignoreorder else json.load(json_file_2)

if json1 != json2:
log.Error(f"JSON Input files are not identical")
log.Warn(f"JSON Input files are not identical")
sys.exit(1)
12 changes: 9 additions & 3 deletions ConfigGenerator/params.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
autostart
callsign
communicator
configuration
persistentpathpostfix
precondition
resumed
startmode
startuporder
systemrootpath
terminations
callsign
persistentpathpostfix
configuration
volatilepathpostfix
webui
4 changes: 4 additions & 0 deletions JsonGenerator/JsonGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
files.append(p)

for path in files:

trackers.object_tracker.Reset()
trackers.enum_tracker.Reset()

try:
log.Header(path)

Expand Down
3 changes: 2 additions & 1 deletion JsonGenerator/source/class_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ def _EmitEnumRegistration(root, enum):
count = 0

for obj in trackers.enum_tracker.objects:
if not obj.is_duplicate and not obj.included_from:
if not obj.is_duplicate and not obj.included_from and ("@register" not in obj.schema or obj.schema["@register"]):
emit.Line()
_EmitEnumRegistration(root, obj)
obj.schema["@register"] = False
count += 1

emit.Line()
Expand Down
3 changes: 0 additions & 3 deletions JsonGenerator/source/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ def _ParseJsonRpcSchema(schema):
else:
return None

trackers.object_tracker.Reset()
trackers.enum_tracker.Reset()

directory = os.path.dirname(path)
filename = (schema["info"]["namespace"]) if "info" in schema and "namespace" in schema["info"] else ""
filename += (schema["info"]["class"]) if "info" in schema and "class" in schema["info"] else ""
Expand Down
2 changes: 1 addition & 1 deletion JsonGenerator/source/documentation_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def Create(log, schema, path, indent_size = 4):
input_basename = os.path.basename(path)
output_path = os.path.dirname(path) + os.sep + input_basename.replace(".json", "") + ".md"

with Emitter(output_path, config.INDENT_SIZE) as emit:
with Emitter(output_path, config.INDENT_SIZE, 10000) as emit:
def bold(string):
return "**%s**" % string

Expand Down
4 changes: 2 additions & 2 deletions JsonGenerator/source/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# limitations under the License.

class Emitter():
def __init__(self, file_name, indent_size):
def __init__(self, file_name, indent_size, max_line_length = 160):
self.file = open(file_name, "w") if file_name else None
self.indent_size = indent_size
self.indent = 0
self.threshold = 160
self.threshold = max_line_length
self.lines = []

def __del__(self):
Expand Down
68 changes: 46 additions & 22 deletions JsonGenerator/source/header_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ def __init__(self, obj, msg):
else:
super(CppParseError, self).__init__(msg)


def LoadInterface(file, log, all = False, includePaths = []):

def StripFrameworkNamespace(identifier):
return str(identifier).replace("::" + config.FRAMEWORK_NAMESPACE + "::", "")

def StripInterfaceNamespace(identifier):
return str(identifier).replace(config.INTERFACE_NAMESPACE + "::", "")

try:
tree = CppParser.ParseFiles([os.path.join(os.path.dirname(os.path.realpath(__file__)),
posixpath.normpath(config.DEFAULT_DEFINITIONS_FILE)), file], includePaths, log)
Expand Down Expand Up @@ -88,15 +96,12 @@ def _EvaluateRpcFormat(obj):
info["format"] = rpc_format.value

if not face.obj.parent.full_name.endswith(config.INTERFACE_NAMESPACE):
info["namespace"] = face.obj.parent.name
info["namespace"] = face.obj.parent.name[1:] if (face.obj.parent.name[0] == "I" and face.obj.parent.name[1].isupper()) else face.obj.parent.name

info["class"] = face.obj.name[1:] if face.obj.name[0] == "I" else face.obj.name
scoped_face = face.obj.full_name.split("::")[1:]

if scoped_face[0] == config.FRAMEWORK_NAMESPACE:
scoped_face = scoped_face[1:]

info["interface"] = "::".join(scoped_face)
info["interface"] = StripInterfaceNamespace("::" + "::".join(scoped_face))
info["sourcefile"] = os.path.basename(file)

if face.obj.sourcelocation:
Expand All @@ -119,12 +124,6 @@ def _EvaluateRpcFormat(obj):
def ResolveTypedef(type):
return type.Resolve()

def StripFrameworkNamespace(identifier):
return str(identifier).replace("::" + config.FRAMEWORK_NAMESPACE + "::", "")

def StripInterfaceNamespace(identifier):
return str(identifier).replace(config.INTERFACE_NAMESPACE + "::", "").replace("::" + config.FRAMEWORK_NAMESPACE + "::", "")

def ConvertType(var):
var_type = ResolveTypedef(var.type)
cppType = var_type.Type()
Expand Down Expand Up @@ -195,13 +194,11 @@ def ConvertType(var):
elif isinstance(cppType, CppParser.Enum):

if len(cppType.items) > 1:
enum_values = [e.auto_value for e in cppType.items]

for i, e in enumerate(cppType.items, 0):
if enum_values[i - 1] != enum_values[i]:
raise CppParseError(var, "enumerator values in an enum must all be explicit or all be implied")
autos = [e.auto_value for e in cppType.items].count(True)
if autos != 0 and (autos != len(cppType.items)):
raise CppParseError(var, "enumerator values in an enum must all be explicit or all be implied")

enum_spec = { "enum": [e.meta.text if e.meta.text else e.name.replace("_"," ").title().replace(" ","") for e in cppType.items], "scoped": var.type.Type().scoped }
enum_spec = { "enum": [e.meta.text if e.meta.text else e.name.replace("_"," ").title().replace(" ","") for e in cppType.items], "scoped": var_type.Type().scoped }
enum_spec["ids"] = [e.name for e in cppType.items]
enum_spec["hint"] = var.type.Type().name

Expand All @@ -215,26 +212,36 @@ def ConvertType(var):
result = ["array", { "items": enum_spec } ]
else:
result = ["string", enum_spec]


if isinstance(var.type.Type(), CppParser.Typedef):
result[1]["@register"] = False

# POD objects
elif isinstance(cppType, CppParser.Class):
def GenerateObject(ctype):
def GenerateObject(ctype, was_typdef):
properties = dict()

for p in ctype.vars:
name = p.name.lower()

if isinstance(ResolveTypedef(p.type).Type(), CppParser.Class):
_, props = GenerateObject(ResolveTypedef(p.type).Type())
_, props = GenerateObject(ResolveTypedef(p.type).Type(), isinstance(p.type.Type(), CppParser.Typedef))
properties[name] = props
properties[name]["type"] = "object"
properties[name]["original_type"] = StripFrameworkNamespace(p.type.Type().full_name)
else:
properties[name] = ConvertParameter(p)

properties[name]["@originalname"] = p.name

if was_typdef:
properties[name]["@register"] = False

return "object", { "properties": properties, "required": list(properties.keys()) }

result = GenerateObject(cppType)
result = GenerateObject(cppType, isinstance(var.type.Type(), CppParser.Typedef))

# All other types are not supported
else:
raise CppParseError(var, "unable to convert C++ type to JSON type: %s" % cppType.type)
Expand Down Expand Up @@ -405,14 +412,26 @@ def BuildResult(vars, is_property=False):

if method.is_excluded:
if event_params:
log.WarnLine(method, "'%s()': @json:omit is redundant for notification registration methods" % method.name)
log.WarnLine(method, "'%s': @json:omit is redundant for notification registration methods" % method.name)

continue

prefix = (face.obj.parent.name.lower() + "_") if face.obj.parent.full_name != config.INTERFACE_NAMESPACE else ""
if face.obj.json_prefix:
prefix = (face.obj.json_prefix + "::")
elif face.obj.parent.full_name != config.INTERFACE_NAMESPACE:
prefix = (face.obj.parent.name.lower() + "_")
else:
prefix = ""

method_name = method.retval.meta.text if method.retval.meta.text else method.name
method_name_lower = method_name.lower()

if method.retval.meta.alt == method_name_lower:
log.WarnLine(method, "%s': alternative name is same as original name" % method.name)

if method.retval.meta.text == method_name_lower:
log.WarnLine(method, "%s': changed function name is same as original name" % method.name)

for e in event_params:
exists = any(x.obj.type == e.type.type for x in event_interfaces)

Expand Down Expand Up @@ -533,6 +552,11 @@ def BuildResult(vars, is_property=False):

if obj["params"] == None or obj["params"]["type"] == "null":
raise CppParseError(method.vars[value], "property setter method must have one input parameter")

if method.retval.meta.alt:
properties[prefix + method.retval.meta.alt] = copy.deepcopy(obj)
properties[prefix + method.retval.meta.alt]["deprecated"] = True

else:
raise CppParseError(method, "property method must have one parameter")

Expand Down
4 changes: 2 additions & 2 deletions JsonGenerator/source/json_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(self, name, parent, schema, included=None):

# Do some sanity check on the type name
if parent and not isinstance(parent, JsonArray):
if not is_generated:
if not is_generated and not self.original_name:
if not self.name.replace("_", "").isalnum():
raise JsonParseError("Invalid characters in identifier name: '%s'" % self.print_name)

Expand Down Expand Up @@ -728,7 +728,7 @@ def function_name(self):
return self.cpp_name

def Headline(self):
return "%s%s%s" % (self.json_name, (" - " + self.summary.split(".", 1)[0]) if self.summary else "",
return "'%s'%s%s" % (self.json_name, (" - " + self.summary.split(".", 1)[0]) if self.summary else "",
" (DEPRECATED)" if self.deprecated else " (OBSOLETE)" if self.obsolete else "")


Expand Down
2 changes: 1 addition & 1 deletion JsonGenerator/source/rpc_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _EmitRpcCode(root, emit, header_file, source_file, data_emitted):
module_var = "_module_"
impl_var = "_impl_"
struct = "J" + root.json_name
face = "I" + root.json_name
face = root.info["interface"] if "interface" in root.info else ("I" + root.json_name)

has_listeners = any((isinstance(m, JsonNotification) and m.is_status_listener) for m in root.properties)

Expand Down
2 changes: 1 addition & 1 deletion JsonGenerator/source/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __Compare(lhs, rhs):

return obj

return None
return None

def CommonObjects(self):
return SortByDependency(filter(lambda obj: ((obj.RefCount() > 1) or self._IsTopmost(obj)), self.objects))
Expand Down
Loading