From 0952147c943cdc9265bfeab6a5d31b26b790b5b2 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Tue, 4 Apr 2023 12:38:49 +0200 Subject: [PATCH 01/24] [StubGen] Support int24 --- ProxyStubGenerator/CppParser.py | 37 +++++++------- ProxyStubGenerator/StubGenerator.py | 76 ++++++++++++++++------------- 2 files changed, 59 insertions(+), 54 deletions(-) diff --git a/ProxyStubGenerator/CppParser.py b/ProxyStubGenerator/CppParser.py index bc963e5..bea46b0 100755 --- a/ProxyStubGenerator/CppParser.py +++ b/ProxyStubGenerator/CppParser.py @@ -337,27 +337,24 @@ def __init__(self, parent_block, parent, string, valid_specifiers, tags_allowed= raise ParserError("@maxlength tag not allowed here") skip = 1 elif token[1:] == "RESTRICT": - if tags_allowed: - self.meta.range = [] - for s in "".join(string[i + 1]).split(".."): - try: - if '.' not in s: - v = eval(s.lower().replace("k","*1024").replace("m","*1024*1024").replace("g","*1024*1024*1024")) - else: - v = eval(s) - self.meta.range.append(int(v)) - except: - raise ParserError("failed to evaluate range in @restrict: '%s'" % s) - if len(self.meta.range) == 2: - if self.meta.range[0] > self.meta.range[1]: - raise ParserError("invalid range in @restrict: %s > %s" % (self.meta.range[0], self.meta.range[1])) - elif len(self.meta.range) == 1: - self.meta.range.append(self.meta.range[0]) - self.meta.range[0] = 0 - else: - raise ParserError("failed to parse range in @restrict: '%s'" % "".join(string[i + 1])) + self.meta.range = [] + for s in "".join(string[i + 1]).split(".."): + try: + if '.' not in s: + v = eval(s.lower().replace("k","*1024").replace("m","*1024*1024").replace("g","*1024*1024*1024")) + else: + v = eval(s) + self.meta.range.append(int(v)) + except: + raise ParserError("failed to evaluate range in @restrict: '%s'" % s) + if len(self.meta.range) == 2: + if self.meta.range[0] > self.meta.range[1]: + raise ParserError("invalid range in @restrict: %s > %s" % (self.meta.range[0], self.meta.range[1])) + elif len(self.meta.range) == 1: + self.meta.range.append(self.meta.range[0]) + self.meta.range[0] = 0 else: - raise ParserError("@restrict tag not allowed here") + raise ParserError("failed to parse range in @restrict: '%s'" % "".join(string[i + 1])) skip = 1 elif token[1:] == "INTERFACE": self.meta.interface = string[i + 1] diff --git a/ProxyStubGenerator/StubGenerator.py b/ProxyStubGenerator/StubGenerator.py index 70c38cd..9073f70 100755 --- a/ProxyStubGenerator/StubGenerator.py +++ b/ProxyStubGenerator/StubGenerator.py @@ -709,6 +709,7 @@ def _FindLength(length_name, variable_name): name = (override_name or ("_" + self.identifier.name).replace("__unnamed_", "")) self.value = self.identifier.value + self.is_integer = isinstance(self.kind, CppParser.Integer) self.is_string = isinstance(self.kind, CppParser.String) self.is_ccstring = (isinstance(self.kind, CppParser.String) and self.kind.is_cc) @@ -743,7 +744,7 @@ def _FindLength(length_name, variable_name): raise TypenameError(self.identifier, "'%s': can't deduce maximum length of the buffer, use @maxlength" % self.trace_proto) if (self.is_buffer and self.max_length and not self.length): - log.WarnLine(self.identifier, "'%s': actual length of returned buffer is implicit" % self.trace_proto) + log.WarnLine(self.identifier, "'%s': length of returned buffer is not specified" % self.trace_proto) # Is it a hresult? self.is_hresult = self.identifier_type.TypeName().endswith("Core::hresult") \ @@ -873,17 +874,17 @@ def _FindLength(length_name, variable_name): self.restrict_range = self.max_length_of.meta.range if self.restrict_range: - if isinstance(self.kind, CppParser.Integer) and not self.is_buffer: + if self.is_integer and not self.is_buffer: if (self.restrict_range[1] > self.kind.max) or (self.restrict_range[0] < self.kind.min): raise TypenameError(self.identifier, "'%s': restrict range (%s..%s) is invalid for this length integer limits (%s..%s)" % \ (self.trace_proto, self.restrict_range[0], self.restrict_range[1], self.kind.min, self.kind.max)) - if no_length_warnings and (((self.restrict_range[1] < 256) and (self.kind.max > 256)) \ + if not no_length_warnings and (((self.restrict_range[1] < 256) and (self.kind.max > 256)) \ or ((self.restrict_range[1] < (64*1024)) and (self.kind.max > (64*1024))) \ or ((self.restrict_range[1] < (4*1024*1024*1024)) and (self.kind.max > (4*1024*1024*1024)))): log.WarnLine(identifier, "'%s': inefficient use of type (%s) based on restrict range (%s..%s)" % \ (self.trace_proto, self.proto_no_cv, self.restrict_range[0], self.restrict_range[1])) - elif (self.is_buffer or self.is_string): + elif (self.is_buffer or self.is_string or (self.is_integer and self.kind.min == 0)): if self.restrict_range[0] < 0: raise TypenameError(self.identifier, "'%s': negative restrict range (%s..%s) is invalid for this type" % \ (self.trace_proto, self.restrict_range[0], self.restrict_range[1])) @@ -892,28 +893,39 @@ def _FindLength(length_name, variable_name): log.WarnLine(identifier, "'%s': parameters up to %s bytes are recommended for COM-RPC, see range (%s..%s)" \ % (self.trace_proto, PARAMETER_SIZE_WARNING_THRESHOLD, self.restrict_range[0], self.restrict_range[1])) - aux_name = (self.name.replace(".", "_").strip("_") + "PeekedLen") - aux_size = "uint16_t" - if self.restrict_range: - if self.restrict_range[1] >= (16*1024*1024): - aux_size = "uint32_t" - elif self.restrict_range[1] >= (64*1024): - aux_size = "uint24_t" - elif self.restrict_range[1] < 256: - aux_size = "uint8_t" - - if self.is_string: - if self.is_ccstring and not self.restrict_range: - log.WarnLine(identifier, "'%s': parameters up to %s bytes are recommended for COM-RPC" \ - % (self.trace_proto, PARAMETER_SIZE_WARNING_THRESHOLD)) - aux_size = "uint32_t" + if self.is_string or self.is_buffer: + aux_name = (self.name.replace(".", "_").strip("_") + "PeekedLen") + aux_size = "uint16_t" + if self.restrict_range: + if self.restrict_range[1] >= (16*1024*1024): + aux_size = "uint32_t" + elif self.restrict_range[1] >= (64*1024): + aux_size = "Core::Frame::UInt24" + elif self.restrict_range[1] < 256: + aux_size = "uint8_t" + + if self.is_string: + if self.is_ccstring and not self.restrict_range: + log.WarnLine(identifier, "'%s': parameters up to %s bytes are recommended for COM-RPC" \ + % (self.trace_proto, PARAMETER_SIZE_WARNING_THRESHOLD)) + aux_size = "uint32_t" - self.peek_length = AuxIdentifier(CppParser.Integer(aux_size), (CppParser.Ref.VALUE | CppParser.Ref.CONST), aux_name) - elif self.is_buffer: - if not self.restrict_range: - aux_size = (self.length.type_name if self.length else self.max_length.type_name) + self.peek_length = AuxIdentifier(CppParser.Integer(aux_size), (CppParser.Ref.VALUE | CppParser.Ref.CONST), aux_name) + elif self.is_buffer: + if not self.restrict_range: + aux_size = (self.length.type_name if self.length else self.max_length.type_name) + + self.peek_length = AuxIdentifier(CppParser.Integer(aux_size), (CppParser.Ref.VALUE | CppParser.Ref.CONST), aux_name) - self.peek_length = AuxIdentifier(CppParser.Integer(aux_size), (CppParser.Ref.VALUE | CppParser.Ref.CONST), aux_name) + elif self.is_integer: + if self.restrict_range and self.kind.size == "long": + if self.kind.signed: + if (((self.restrict_range[0] < (-32*1024)) and (self.restrict_range[0] >= (-8*1024*1024))) or \ + ((self.restrict_range[1] >= (32*1024)) and (self.restrict_range[1] < (8*1024*1024)))): + self.type_name = "Core::Frame::SInt24" + else: + if ((self.restrict_range[1] >= (64*1024)) and (self.restrict_range[1] < (16*1024*1024))): + self.type_name = "Core::Frame::UInt24" @property def as_rvalue(self): @@ -1009,18 +1021,14 @@ def storage_size(self): if self.proxy_instance or self.return_proxy: return "sizeof(%s)" % INSTANCE_ID elif self.is_buffer: - # Minimum size - if self.length: - return "sizeof(%s)" % self.length.type_name - elif self.max_length: - return "sizeof(%s)" % self.max_length.type_name - else: - Unreachable() + return "Core::Frame::RealSize<%s>()" % self.peek_length.type_name elif self.is_string: - # Minimum size - return "sizeof(%s)" % ("uint32_t" if self.is_ccstring else "uint16_t") + if self.is_ccstring: + return "(sizeof(uint32_t))" + else: + return "Core::Frame::RealSize<%s>()" % self.peek_length.type_name elif isinstance(self.kind, (CppParser.Integer, CppParser.Enum, CppParser.BuiltinInteger)): - return "sizeof(%s)" % self.type_name + return "Core::Frame::RealSize<%s>()" % self.type_name elif isinstance(self.kind, CppParser.Bool): return 1 # always one byte else: From e0ce8179ea1379f4b2437b8e070efb779cd5d91a Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Tue, 4 Apr 2023 17:19:32 +0200 Subject: [PATCH 02/24] Merge pull request #14 from rdkcentral/development/int24 [StubGen] Support int24 From a391e08f36759aaa0c00219939ccdf8550f0ec36 Mon Sep 17 00:00:00 2001 From: sebaszm <45654185+sebaszm@users.noreply.github.com> Date: Fri, 7 Apr 2023 15:56:19 +0200 Subject: [PATCH 03/24] [StubGen] Also consider non-pure-virtual methods for interface dump (#15) * [StubGen] Also consider non-pure-virtual methods for interface dump * Update help --- LuaGenerator/GenerateLua.bat | 13 +++++++------ LuaGenerator/GenerateLua.sh | 12 ++++++------ ProxyStubGenerator/StubGenerator.py | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/LuaGenerator/GenerateLua.bat b/LuaGenerator/GenerateLua.bat index 7da0c7c..4a628db 100755 --- a/LuaGenerator/GenerateLua.bat +++ b/LuaGenerator/GenerateLua.bat @@ -20,7 +20,8 @@ @rem @rem Typical usage: @rem GenerateLua.bat [ ] -@rem GenerateLua.bat ..\..\..\Thunder ..\..\..\ThunderInterfaces ..\..\..\ThunderClientLibraries +@rem GenerateLua.bat +@rem GenerateLua.bat ..\..\Thunder ..\..\ThunderInterfaces ..\..\ThunderClientLibraries @rem @echo off @@ -30,12 +31,12 @@ if not exist ..\ProxyStubGenerator\StubGenerator.py ( exit /b 0 ) -set THUNDER_DIR=..\..\..\Thunder -set INTERFACES_DIR=..\..\..\ThunderInterfaces -set CLIENTLIBRARIES_DIR=..\..\..\ThunderClientLibraries +set THUNDER_DIR=..\..\Thunder +set INTERFACES_DIR=..\..\ThunderInterfaces +set CLIENTLIBRARIES_DIR=..\..\ThunderClientLibraries -set files=%THUNDER_DIR%\Source\com\ICOM.h %THUNDER_DIR%\Source\com\ITrace.h -set files=%files% %THUNDER_DIR%\Source\plugins\IPlugin.h %THUNDER_DIR%\Source\plugins\IShell.h %THUNDER_DIR%\Source\plugins\IStateControl.h %THUNDER_DIR%\Source\plugins\ISubSystem.h +set files=%THUNDER_DIR%\Source\com\ICOM.h +set files=%files% %THUNDER_DIR%\Source\plugins\IController.h %THUNDER_DIR%\Source\plugins\IPlugin.h %THUNDER_DIR%\Source\plugins\IShell.h %THUNDER_DIR%\Source\plugins\IStateControl.h %THUNDER_DIR%\Source\plugins\ISubSystem.h set files=%files% %INTERFACES_DIR%\interfaces\I*.h set files=%files% %CLIENTLIBRARIES_DIR%\Source\cryptography\I*.h rem add more interface files if needed.. diff --git a/LuaGenerator/GenerateLua.sh b/LuaGenerator/GenerateLua.sh index 0dfb645..0ec207c 100755 --- a/LuaGenerator/GenerateLua.sh +++ b/LuaGenerator/GenerateLua.sh @@ -23,18 +23,18 @@ # Typical usage: # ./GenerateLua.sh [ ] # ./GenerateLua.sh -# ./GenerateLua.sh ../../../Thunder ../../../ThunderInterfaces ../../../ThunderClientLibraries +# ./GenerateLua.sh ../../Thunder ../../ThunderInterfaces ../../ThunderClientLibraries # ./GenerateLua.sh ~/work/Thunder ~/work/ThunderInterfaces ~/work/ThunderClientLibraries # command -v ../ProxyStubGenerator/StubGenerator.py >/dev/null 2>&1 || { echo >&2 "StubGenerator.py is not available. Aborting."; exit 1; } -THUNDER_DIR="${1:-../../../Thunder}" -INTERFACES_DIR="${2:-../../../ThunderInterfaces}" -CLIENTLIBRARIES_DIR="${3:-../../../ThunderClientLibraries}" +THUNDER_DIR="${1:-../../Thunder}" +INTERFACES_DIR="${2:-../../ThunderInterfaces}" +CLIENTLIBRARIES_DIR="${3:-../../ThunderClientLibraries}" -files="$THUNDER_DIR/Source/com/ICOM.h $THUNDER_DIR/Source/com/ITrace.h" -files="$files $THUNDER_DIR/Source/plugins/IPlugin.h $THUNDER_DIR/Source/plugins/IShell.h $THUNDER_DIR/Source/plugins/IStateControl.h $THUNDER_DIR/Source/plugins/ISubSystem.h" +files="$THUNDER_DIR/Source/com/ICOM.h" +files="$files $THUNDER_DIR/Source/plugins/IController.h $THUNDER_DIR/Source/plugins/IPlugin.h $THUNDER_DIR/Source/plugins/IShell.h $THUNDER_DIR/Source/plugins/IStateControl.h $THUNDER_DIR/Source/plugins/ISubSystem.h" files="$files $INTERFACES_DIR/interfaces/I*.h" files="$files $CLIENTLIBRARIES_DIR/Source/cryptography/I*.h" # add more interface files if needed.. diff --git a/ProxyStubGenerator/StubGenerator.py b/ProxyStubGenerator/StubGenerator.py index 9073f70..2310604 100755 --- a/ProxyStubGenerator/StubGenerator.py +++ b/ProxyStubGenerator/StubGenerator.py @@ -272,7 +272,7 @@ def GenerateLuaData(emit, interfaces_list, enums_list, source_file, includePaths emit.Line("%s[%s] = \"%s\"" % (interfaces_var_name, id_value, iface_name)) emit.Line("%s[%s] = {" % (methods_var_name, id_value)) emit.IndentInc() - emit_methods = [m for m in iface.obj.methods if m.IsPureVirtual()] + emit_methods = [m for m in iface.obj.methods if m.IsVirtual() and not m.IsDestructor() and not m.omit] for idx, m in enumerate(emit_methods): name = "name = \"%s\"" % m.name From 36b7a701d5842dd02924e5591727cef344fc8b4c Mon Sep 17 00:00:00 2001 From: sebaszm Date: Fri, 7 Apr 2023 15:53:49 +0200 Subject: [PATCH 04/24] [JsonGen] Restore event listener functionality --- JsonGenerator/source/rpc_emitter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/JsonGenerator/source/rpc_emitter.py b/JsonGenerator/source/rpc_emitter.py index a450fca..dd3d408 100644 --- a/JsonGenerator/source/rpc_emitter.py +++ b/JsonGenerator/source/rpc_emitter.py @@ -134,7 +134,7 @@ def EmitEvent(emit, root, event, params_type, legacy = False): if isinstance(event.sendif_type, JsonInteger): conv_index_var = "_designatorIdAsInt" - emit.Line("%s %s{};" % (sendif_type.cpp_native_type, conv_index_var)) + emit.Line("%s %s{};" % (event.sendif_type.cpp_native_type, conv_index_var)) emit.Line("return ((Core::FromString(%s, %s) == true) && (%s == %s));" % (designator_var, index_var, filter_var, conv_index_var)) elif isinstance(event.sendif_type, JsonEnum): @@ -741,8 +741,7 @@ def _Invoke(params, response, use_prefix = True, const_cast = False, parent = "" emit.Indent() emit.Line("[&%s](const string& client, const JSONRPC::Status status) {" % (impl_var)) emit.Indent() - emit.Line("const string id = client.substr(0, client.find('.'));") - emit.Line("%s.On%sEventRegistration(id, status);" % (impl_var, event.function_name)) + emit.Line("%s.On%sEventRegistration(client, status);" % (impl_var, event.function_name)) emit.Unindent() emit.Line("});") emit.Unindent() From e57de7c84435ff3549afcc79bfca8822962a12a8 Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Fri, 14 Apr 2023 08:42:23 +0200 Subject: [PATCH 05/24] Merge pull request #16 from rdkcentral/development/restore-event-listener [JsonGen] Restore status event listener From d8f1a5ac54f02087bf789c12ee037882e99ff65e Mon Sep 17 00:00:00 2001 From: sebaszm Date: Thu, 27 Apr 2023 13:30:51 +0200 Subject: [PATCH 06/24] [Stubgen] Allow controlling of security options globally --- CMakeLists.txt | 3 +++ cmake/FindProxyStubGenerator.cmake.in | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0695de9..359da9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,9 @@ project(Generators) set(GENERATOR_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/sbin") +option(PROXYSTUB_GENERATOR_ENABLE_SECURITY "Globally enable security checks in proxystubs" OFF) +option(PROXYSTUB_GENERATOR_ENABLE_COHERENCY "Globally enable frame coherency checks in proxystubs" OFF) + if(NOT DEFINED GENERIC_CMAKE_MODULE_PATH) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../src/bridge") set(NAMESPACE bridge) diff --git a/cmake/FindProxyStubGenerator.cmake.in b/cmake/FindProxyStubGenerator.cmake.in index cf0d301..00f988d 100644 --- a/cmake/FindProxyStubGenerator.cmake.in +++ b/cmake/FindProxyStubGenerator.cmake.in @@ -44,11 +44,11 @@ function(ProxyStubGenerator) set(_execute_command ${PROXYSTUB_GENERATOR}) - if(Argument_SECURE) + if(Argument_SECURE OR @PROXYSTUB_GENERATOR_ENABLE_SECURITY@) list(APPEND _execute_command "--secure") endif() - if(Argument_COHERENT) + if(Argument_COHERENT OR @PROXYSTUB_GENERATOR_ENABLE_COHERENCY@) list(APPEND _execute_command "--coherent") endif() From 721a6c008771e8e7790990984186a57cb37b5efb Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Fri, 28 Apr 2023 08:33:42 +0200 Subject: [PATCH 07/24] Merge pull request #17 from rdkcentral/development/add-security-opt-to-cmake From a718680ab82c606c504d898c1ffe1b347c1b4ebe Mon Sep 17 00:00:00 2001 From: sebaszm <45654185+sebaszm@users.noreply.github.com> Date: Tue, 9 May 2023 08:15:34 +0200 Subject: [PATCH 08/24] [StubGen] Fix @stubgen:skip when placed in an included file (#18) --- ProxyStubGenerator/CppParser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ProxyStubGenerator/CppParser.py b/ProxyStubGenerator/CppParser.py index bea46b0..26c412f 100755 --- a/ProxyStubGenerator/CppParser.py +++ b/ProxyStubGenerator/CppParser.py @@ -1802,9 +1802,11 @@ def Parse(contents,log = None): next_block = None last_template_def = [] min_index = 0 + omit_mode = False omit_next = False stub_next = False json_next = False + json_version = "" event_next = False extended_next = False collapsed_next = False From a9a2ca163f38935347ea77e4f672cb45c8ff026f Mon Sep 17 00:00:00 2001 From: sebaszm <45654185+sebaszm@users.noreply.github.com> Date: Tue, 9 May 2023 11:43:24 +0200 Subject: [PATCH 09/24] [JsonGen] Do not attempt emitting RPC code for destructors (#19) --- JsonGenerator/source/header_loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index ea6b16a..8e44bfd 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -536,7 +536,7 @@ def BuildResult(vars, is_property=False): else: raise CppParseError(method, "property method must have one parameter") - elif method.IsVirtual() and not event_params: + elif method.IsVirtual() and not method.IsDestructor() and not event_params: var_type = ResolveTypedef(method.retval.type) if var_type and ((isinstance(var_type.Type(), CppParser.Integer) and (var_type.Type().size == "long")) or not verify): @@ -591,7 +591,7 @@ def BuildResult(vars, is_property=False): for method in f.obj.methods: EventParameters(method.vars) # just to check for undefined types... - if method.IsVirtual() and method.is_excluded == False: + if method.IsVirtual() and not method.IsDestructor() and not method.is_excluded: obj = OrderedDict() obj["@originalname"] = method.name varsidx = 0 From dcb9c159da0c8e3dffe079be85ea4244bcd70232 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Tue, 9 May 2023 11:45:13 +0200 Subject: [PATCH 10/24] [JsonGen] Add --no-versioning and --no-push-warning options --- JsonGenerator/source/code_generator.py | 2 +- JsonGenerator/source/config.py | 19 ++++++++++++++++++- JsonGenerator/source/rpc_emitter.py | 12 ++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/JsonGenerator/source/code_generator.py b/JsonGenerator/source/code_generator.py index df56136..9ec2409 100644 --- a/JsonGenerator/source/code_generator.py +++ b/JsonGenerator/source/code_generator.py @@ -101,7 +101,7 @@ def _ParseJsonRpcSchema(schema): pass # Also emit version if source was json meta file in manual mode - if (rpcObj.schema.get("mode") != "auto"): + if (rpcObj.schema.get("mode") != "auto") and not config.NO_VERSIONING: output_filename = os.path.join(directory, "J" + filename + ".h") if not config.FORCE and (os.path.exists(output_filename) and (os.path.getmtime(source_file) < os.path.getmtime(output_filename))): diff --git a/JsonGenerator/source/config.py b/JsonGenerator/source/config.py index 1269751..3bda1c8 100644 --- a/JsonGenerator/source/config.py +++ b/JsonGenerator/source/config.py @@ -42,6 +42,8 @@ INTERFACE_SOURCE_LOCATION = None INTERFACE_SOURCE_REVISION = None NO_INCLUDES = False +NO_VERSIONING = False +NO_PUSH_WARNING = False DEFAULT_INTERFACE_SOURCE_REVISION = "main" GLOBAL_DEFINITIONS = ".." + os.sep + "global.json" INDENT_SIZE = 4 @@ -67,6 +69,8 @@ def Parse(cmdline): global INTERFACE_NAMESPACE global JSON_INTERFACE_PATH global NO_INCLUDES + global NO_VERSIONING + global NO_PUSH_WARNING global DEFAULT_INT_SIZE global INDENT_SIZE global DOC_ISSUES @@ -194,6 +198,18 @@ def Parse(cmdline): action="store_true", default=False, help="do not emit #includes (default: include data and interface headers)") + data_group.add_argument( + "--no-versioning", + dest="no_versioning", + action="store_true", + default=False, + help= "do not emit versioning information for non-auto JSON interfaces (default: emit versioning header)") + data_group.add_argument( + "--no-push-warning", + dest="no_push_warning", + action="store_true", + default=False, + help= "do not use PUSH/POP_WARNING macros in generated code (default: use macros)") data_group.add_argument("--copy-ctor", dest="copy_ctor", action="store_true", @@ -286,12 +302,13 @@ def Parse(cmdline): RPC_FORMAT_FORCED = True NO_INCLUDES = args.no_includes + NO_VERSIONING = args.no_versioning + NO_PUSH_WARNING = args.no_push_warning if args.if_path and args.if_path != ".": JSON_INTERFACE_PATH = args.if_path JSON_INTERFACE_PATH = posixpath.normpath(JSON_INTERFACE_PATH) + os.sep - if args.if_dir: args.if_dir = os.path.abspath(os.path.normpath(args.if_dir)) if args.cppif_dir: diff --git a/JsonGenerator/source/rpc_emitter.py b/JsonGenerator/source/rpc_emitter.py index dd3d408..3c6de0d 100644 --- a/JsonGenerator/source/rpc_emitter.py +++ b/JsonGenerator/source/rpc_emitter.py @@ -786,8 +786,10 @@ def _Invoke(params, response, use_prefix = True, const_cast = False, parent = "" emit.Line("namespace Event {") emit.Indent() emit.Line() - emit.Line("PUSH_WARNING(DISABLE_WARNING_UNUSED_FUNCTIONS)") - emit.Line() + + if not config.NO_PUSH_WARNING: + emit.Line("PUSH_WARNING(DISABLE_WARNING_UNUSED_FUNCTIONS)") + emit.Line() for event in events: EmitEvent(emit, root, event, "object") @@ -798,8 +800,10 @@ def _Invoke(params, response, use_prefix = True, const_cast = False, parent = "" EmitEvent(emit, root, event, "native") - emit.Line("POP_WARNING()") - emit.Line() + if not config.NO_PUSH_WARNING: + emit.Line("POP_WARNING()") + emit.Line() + emit.Unindent() emit.Line("} // namespace Event") emit.Line() From b7e6fca9a0703c62ee763c5fd1f84119ebf4051d Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Tue, 9 May 2023 14:34:40 +0200 Subject: [PATCH 11/24] Merge pull request #20 from rdkcentral/development/json-gen-add-bc-options [JsonGen] Add --no-versioning and --no-push-warning options From 65649a5944a9f3abc01943c4a73715c8e57ba16e Mon Sep 17 00:00:00 2001 From: sebaszm Date: Fri, 12 May 2023 09:21:02 +0200 Subject: [PATCH 12/24] [JsonGen] On no-push-warnings use plain gcc pragma instead --- JsonGenerator/source/rpc_emitter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/JsonGenerator/source/rpc_emitter.py b/JsonGenerator/source/rpc_emitter.py index 3c6de0d..e1ff2c2 100644 --- a/JsonGenerator/source/rpc_emitter.py +++ b/JsonGenerator/source/rpc_emitter.py @@ -790,6 +790,11 @@ def _Invoke(params, response, use_prefix = True, const_cast = False, parent = "" if not config.NO_PUSH_WARNING: emit.Line("PUSH_WARNING(DISABLE_WARNING_UNUSED_FUNCTIONS)") emit.Line() + else: + emit.Line("#if defined(__GNUC__) || defined(__clang__)") + emit.Line('#pragma GCC diagnostic ignored "-Wunused-function"') + emit.Line("#endif") + emit.Line() for event in events: EmitEvent(emit, root, event, "object") From ec6376d59ee6d4123f08fb0e5917e2f31177ee1a Mon Sep 17 00:00:00 2001 From: MFransen69 <39826971+MFransen69@users.noreply.github.com> Date: Fri, 12 May 2023 10:57:54 +0200 Subject: [PATCH 13/24] Merge pull request #21 from rdkcentral/development/use-pragma-instead [JsonGen] On no-push-warnings use plain gcc pragma instead From 3936d9991916f51f6497efc34b133dfe7cee6f07 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Sun, 21 May 2023 23:18:38 -0700 Subject: [PATCH 14/24] Change Json generation not identical case to Warn --- ConfigGenerator/config_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigGenerator/config_compare.py b/ConfigGenerator/config_compare.py index 586227b..0624b5f 100644 --- a/ConfigGenerator/config_compare.py +++ b/ConfigGenerator/config_compare.py @@ -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) From dd8aeb00a34652782110ed1b143505cb234f907a Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Tue, 23 May 2023 10:37:30 +0200 Subject: [PATCH 15/24] Merge pull request #23 from rdkcentral/development/METROL-761 Change Json generation not identical case to Warn From 383c045cc1eaacc83dc972bac6db90526a60ed4c Mon Sep 17 00:00:00 2001 From: sebaszm <45654185+sebaszm@users.noreply.github.com> Date: Tue, 23 May 2023 20:31:30 +0200 Subject: [PATCH 16/24] [JsonGen] Don't emit enum registration tables for aliases (#22) Co-authored-by: Pierre Wielders --- JsonGenerator/source/class_emitter.py | 2 +- JsonGenerator/source/header_loader.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/JsonGenerator/source/class_emitter.py b/JsonGenerator/source/class_emitter.py index a567719..9b4b9b8 100644 --- a/JsonGenerator/source/class_emitter.py +++ b/JsonGenerator/source/class_emitter.py @@ -51,7 +51,7 @@ 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) count += 1 diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index 8e44bfd..38bbf78 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -201,7 +201,7 @@ def ConvertType(var): if enum_values[i - 1] != enum_values[i]: 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 @@ -215,26 +215,35 @@ 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) From 5aef2f9b6f03097d471cf1ad347716c20ae7d24e Mon Sep 17 00:00:00 2001 From: sebaszm Date: Fri, 2 Jun 2023 17:14:28 +0200 Subject: [PATCH 17/24] [JsonGen] Fix alt and text tags for properties, detect name clashes --- JsonGenerator/source/header_loader.py | 21 +++++++++++++++------ ProxyStubGenerator/CppParser.py | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index 38bbf78..27f74c3 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -195,11 +195,9 @@ 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["ids"] = [e.name for e in cppType.items] @@ -414,7 +412,7 @@ 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 @@ -422,6 +420,12 @@ def BuildResult(vars, is_property=False): 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) @@ -542,6 +546,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") diff --git a/ProxyStubGenerator/CppParser.py b/ProxyStubGenerator/CppParser.py index 26c412f..45387b4 100755 --- a/ProxyStubGenerator/CppParser.py +++ b/ProxyStubGenerator/CppParser.py @@ -1033,13 +1033,22 @@ def __init__(self, parent_block, name, ret_type, valid_specifiers=["static", "ex self.omit = False self.stub = False self.is_excluded = False - self.parent.methods.append(self) + for method in self.parent.methods: if method.name == self.name: - if method.retval.meta.is_property: - self.retval.meta.is_property = True + 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) + break + self.parent.methods.append(self) + def Proto(self): _str = "static " if self.IsStatic() else "" _str += TypeStr(self.retval.type) if self.retval.type else "" From 83014d7ddadadad8325c57838ea66948f5cc42b6 Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Mon, 5 Jun 2023 11:01:35 +0200 Subject: [PATCH 18/24] Merge pull request #24 from rdkcentral/development/fix-alt-text-for-properties [JsonGen] Fix alt and text tags for properties, detect name clashes From 861344fa40dfc8482941546e5bc86a638a743866 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Wed, 21 Jun 2023 13:42:15 +0200 Subject: [PATCH 19/24] [JsonGen] Add support for prefix tag --- JsonGenerator/JsonGenerator.py | 4 +++ JsonGenerator/source/class_emitter.py | 1 + JsonGenerator/source/code_generator.py | 3 -- .../source/documentation_generator.py | 2 +- JsonGenerator/source/emitter.py | 4 +-- JsonGenerator/source/header_loader.py | 30 +++++++++------- JsonGenerator/source/json_loader.py | 4 +-- JsonGenerator/source/rpc_emitter.py | 2 +- JsonGenerator/source/trackers.py | 2 +- ProxyStubGenerator/CppParser.py | 35 ++++++++++++++++--- 10 files changed, 61 insertions(+), 26 deletions(-) diff --git a/JsonGenerator/JsonGenerator.py b/JsonGenerator/JsonGenerator.py index 15e5e83..91cdcd4 100755 --- a/JsonGenerator/JsonGenerator.py +++ b/JsonGenerator/JsonGenerator.py @@ -60,6 +60,10 @@ files.append(p) for path in files: + + trackers.object_tracker.Reset() + trackers.enum_tracker.Reset() + try: log.Header(path) diff --git a/JsonGenerator/source/class_emitter.py b/JsonGenerator/source/class_emitter.py index 9b4b9b8..5686870 100644 --- a/JsonGenerator/source/class_emitter.py +++ b/JsonGenerator/source/class_emitter.py @@ -54,6 +54,7 @@ def _EmitEnumRegistration(root, enum): 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() diff --git a/JsonGenerator/source/code_generator.py b/JsonGenerator/source/code_generator.py index 9ec2409..e61f13a 100644 --- a/JsonGenerator/source/code_generator.py +++ b/JsonGenerator/source/code_generator.py @@ -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 "" diff --git a/JsonGenerator/source/documentation_generator.py b/JsonGenerator/source/documentation_generator.py index 134b9b0..57dd262 100644 --- a/JsonGenerator/source/documentation_generator.py +++ b/JsonGenerator/source/documentation_generator.py @@ -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 diff --git a/JsonGenerator/source/emitter.py b/JsonGenerator/source/emitter.py index bfe0290..cafce1c 100644 --- a/JsonGenerator/source/emitter.py +++ b/JsonGenerator/source/emitter.py @@ -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): diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index 27f74c3..05bc3be 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -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) @@ -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[1:] 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: @@ -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() @@ -214,6 +213,7 @@ def ConvertType(var): else: result = ["string", enum_spec] + if isinstance(var.type.Type(), CppParser.Typedef): result[1]["@register"] = False @@ -416,7 +416,13 @@ def BuildResult(vars, is_property=False): 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() diff --git a/JsonGenerator/source/json_loader.py b/JsonGenerator/source/json_loader.py index 906b4ad..9048a9a 100644 --- a/JsonGenerator/source/json_loader.py +++ b/JsonGenerator/source/json_loader.py @@ -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) @@ -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 "") diff --git a/JsonGenerator/source/rpc_emitter.py b/JsonGenerator/source/rpc_emitter.py index e1ff2c2..cc9df5d 100644 --- a/JsonGenerator/source/rpc_emitter.py +++ b/JsonGenerator/source/rpc_emitter.py @@ -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) diff --git a/JsonGenerator/source/trackers.py b/JsonGenerator/source/trackers.py index 82bfe77..3647633 100644 --- a/JsonGenerator/source/trackers.py +++ b/JsonGenerator/source/trackers.py @@ -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)) diff --git a/ProxyStubGenerator/CppParser.py b/ProxyStubGenerator/CppParser.py index 45387b4..2baca7f 100755 --- a/ProxyStubGenerator/CppParser.py +++ b/ProxyStubGenerator/CppParser.py @@ -25,6 +25,10 @@ from collections import OrderedDict from enum import IntEnum + +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir + os.sep)) +import ProxyStubGenerator.Log as Log + class ParserError(RuntimeError): def __init__(self, msg): msg = "%s(%s): parse error: %s" % (CurrentFile(), CurrentLine(), msg) @@ -938,6 +942,7 @@ def __init__(self, parent_block, name): self.stub = False self.is_json = False self.json_version = "" + self.json_prefix = "" self.is_event = False self.is_extended = False self.is_collapsed = False @@ -1288,8 +1293,9 @@ def Proto(self): def __str__(self): s = [] for i, _ in enumerate(self.params): - s.append(self.params[i].name + " = " + str(self.args[i])) - _str = "/* instantiated */ template class %s<%s>" % (self.baseName.full_name, ", ".join([str(p) for p in self.params])) + rhs = ("".join(self.resolvedArgs[i].type) if isinstance(self.resolvedArgs[i].type, list) else self.resolvedArgs[i].type.Proto()) + s.append(self.params[i].name + " = " + rhs) + _str = "class %s<%s>" % (self.baseName.full_name, ", ".join([str(p) for p in self.params])) _str += " [with %s]" % (", ".join(s)) return _str @@ -1346,6 +1352,7 @@ def _Substitute(identifier): instance.specifiers = self.specifiers instance.is_json = self.is_json instance.json_version = self.json_version + instance.json_prefix = self.json_prefix instance.is_extended = self.is_extended instance.is_collapsed = self.is_collapsed instance.is_compliant = self.is_compliant @@ -1569,6 +1576,8 @@ def _find(word, string): tagtokens.append(__ParseParameterValue(token, "@json", False)) if _find("@event", token): tagtokens.append("@EVENT") + if _find("@prefix", token): + tagtokens.append(__ParseParameterValue(token, "@prefix", False)) if _find("@extended", token): tagtokens.append("@EXTENDED") log.Warn("@extended keyword is deprecated, use @uncompliant:extended instead", ("%s(%i)" % (CurrentFile(), CurrentLine()))) @@ -1739,6 +1748,8 @@ def Parse(contents,log = None): stub_next = False json_next = False json_version = "" + prefix_next = False + prefix_string = "" exclude_next = False event_next = False extended_next = False @@ -1776,11 +1787,18 @@ def Parse(contents,log = None): json_next = True json_version = " ".join(tokens[i+1]) tokens[i] = ";" + tokens[i+1] = ";" + i += 2 + elif tokens[i] == "@PREFIX": + prefix_next = True + prefix_string = " ".join(tokens[i+1]) + tokens[i] = ";" + tokens[i+1] = ";" i += 2 elif tokens[i] == "@JSON_OMIT": exclude_next = True json_next = False - tokens[i] = ';' + tokens[i] = ";" i += 1 elif tokens[i] == "@EVENT": event_next = True @@ -1801,6 +1819,8 @@ def Parse(contents,log = None): i += 1 elif tokens[i] == "@SOURCELOCATION": sourcelocation_next = tokens[i + 1][0] + tokens[i] = ";" + tokens[i+1] = ";" i += 2 elif tokens[i] == "@ITERATOR": iterator_next = True @@ -1816,6 +1836,8 @@ def Parse(contents,log = None): stub_next = False json_next = False json_version = "" + prefix_next = False + prefix_string = "" event_next = False extended_next = False collapsed_next = False @@ -1944,6 +1966,8 @@ def Parse(contents,log = None): if json_next: new_class.is_json = True new_class.json_version = json_version + if prefix_next: + new_class.json_prefix = prefix_string if event_next: new_class.is_event = True if iterator_next: @@ -1965,6 +1989,9 @@ def Parse(contents,log = None): raise ParserError("@compliant and @uncompliant used together") json_next = False + json_version = "" + prefix_next = False + prefix_string = "" event_next = False iterator_next = False extended_next = False @@ -2381,7 +2408,7 @@ def DumpTree(tree, ind=0): # entry point if __name__ == "__main__": - tree = ParseFiles(["default.h", sys.argv[1]], sys.argv[2:]) + tree = ParseFiles([os.path.join(os.path.dirname(__file__), "default.h"), sys.argv[1]], sys.argv[2:], Log.Log("debug", True, True)) if isinstance(tree, Namespace): DumpTree(tree) else: From 06c1580c1bc9aa5d66f7a9d356a819dc424ca50b Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Thu, 22 Jun 2023 14:21:32 +0200 Subject: [PATCH 20/24] Merge pull request #25 from rdkcentral/developement/jsongen-prefix [JsonGen] Add support for prefix tag From aceb7cc9c03cb144587ccff78ab16544afe335d9 Mon Sep 17 00:00:00 2001 From: Bram Oosterhuis Date: Sat, 24 Jun 2023 13:22:42 +0200 Subject: [PATCH 21/24] ConfigGenerator: add missing parameters for Plugin::Config --- ConfigGenerator/params.config | 12 +++++++--- cmake/FindConfigGenerator.cmake.in | 35 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ConfigGenerator/params.config b/ConfigGenerator/params.config index 7b38901..52cd0fc 100644 --- a/ConfigGenerator/params.config +++ b/ConfigGenerator/params.config @@ -1,7 +1,13 @@ autostart +callsign +communicator +configuration +persistentpathpostfix precondition resumed +startmode +startuporder +systemrootpath terminations -callsign -persistentpathpostfix -configuration +volatilepathpostfix +webui \ No newline at end of file diff --git a/cmake/FindConfigGenerator.cmake.in b/cmake/FindConfigGenerator.cmake.in index 646c1d6..3ab46a7 100644 --- a/cmake/FindConfigGenerator.cmake.in +++ b/cmake/FindConfigGenerator.cmake.in @@ -247,6 +247,41 @@ if(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR) unset(persistentpathpostfix) endif() + if (NOT ${webui} STREQUAL "") + map_append(${plugin_config} webui ${webui}) + unset(webui) + endif() + + if (NOT ${systemrootpath} STREQUAL "") + map_append(${plugin_config} systemrootpath ${systemrootpath}) + unset(systemrootpath) + endif() + + if (NOT ${resumed} STREQUAL "") + map_append(${plugin_config} resumed ${resumed}) + unset(resumed) + endif() + + if (NOT ${volatilepathpostfix} STREQUAL "") + map_append(${plugin_config} volatilepathpostfix ${volatilepathpostfix}) + unset(volatilepathpostfix) + endif() + + if (NOT ${startuporder} STREQUAL "") + map_append(${plugin_config} startuporder ${startuporder}) + unset(startuporder) + endif() + + if (NOT ${startmode} STREQUAL "") + map_append(${plugin_config} startmode ${startmode}) + unset(startmode) + endif() + + if (NOT ${communicator} STREQUAL "") + map_append(${plugin_config} communicator ${communicator}) + unset(communicator) + endif() + if (NOT ${configuration} STREQUAL "") map_append(${plugin_config} configuration ${configuration}) endif() From ec35b9fa06487ee7b1ff67bb725dcffcba49dd24 Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Sun, 25 Jun 2023 13:05:56 +0200 Subject: [PATCH 22/24] Merge pull request #26 from rdkcentral/development/add-missing-config-parameters From 2502d51466fcc561e2845831ed2ef688ae14c25c Mon Sep 17 00:00:00 2001 From: sebaszm Date: Tue, 27 Jun 2023 12:33:31 +0200 Subject: [PATCH 23/24] [JsonGen] Fix interfaces in namespaces --- JsonGenerator/source/header_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index 05bc3be..f1166e3 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -96,7 +96,7 @@ 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[1:] if (face.obj.parent.name[0] == "I" and face.obj.parent.name[1].isupper()) else face.obj.parent.name[1:] + 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:] From 790c7f0e80fbbe877c86c52c0f1784fffca16dfc Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Tue, 27 Jun 2023 12:48:30 +0200 Subject: [PATCH 24/24] Merge pull request #27 from rdkcentral/development/fix-interfaces-in-namespaces [JsonGen] Fix interfaces in namespaces