From 4854ee05d230866138201a6018cda52a5c7b42ef Mon Sep 17 00:00:00 2001 From: sebaszm Date: Thu, 16 Jul 2026 14:23:40 +0200 Subject: [PATCH 1/5] [JsonGen] Use same includes as StubGen --- JsonGenerator/source/header_loader.py | 14 +++++++++----- JsonGenerator/source/json_loader.py | 12 +++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index f4cee0d6..275da305 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -321,7 +321,7 @@ def Find(tree): return [], [] -def LoadInterfaceInternal(file, tree, ns, log, scanned, all = False, include_paths = []): +def LoadInterfaceInternal(file, tree, ns, log, scanned, all, include_paths): def StripInterfaceNamespace(identifier): return str(identifier).replace(ns + "::", "") @@ -1606,15 +1606,19 @@ def MaybeWarning(): return schemas, [] -def LoadInterface(file, log, all = False, include_paths = []): - +def LoadInterface(file, log, all, include_paths): try: schemas = [] includes = [] scanned = [] - tree = CppParser.ParseFiles([os.path.join(os.path.dirname(os.path.realpath(__file__)), - posixpath.normpath(config.DEFAULT_DEFINITIONS_FILE)), file], config.FRAMEWORK_NAMESPACE, include_paths, log) + files = [] + files.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), posixpath.normpath(config.DEFAULT_DEFINITIONS_FILE))) + files.append(os.path.join("@" + os.path.dirname(file), "Module.h")) + files.append(os.path.join("@" + os.path.dirname(file), "Ids.h")) + files.append(file) + + tree = CppParser.ParseFiles(files, config.FRAMEWORK_NAMESPACE, include_paths, log) for ns in config.INTERFACE_NAMESPACES: their_schemas, their_includes = LoadInterfaceInternal(file, tree, ns, log, scanned, all, include_paths) diff --git a/JsonGenerator/source/json_loader.py b/JsonGenerator/source/json_loader.py index 928f4450..200dd591 100644 --- a/JsonGenerator/source/json_loader.py +++ b/JsonGenerator/source/json_loader.py @@ -1429,7 +1429,17 @@ def Scan(pairs): return [], [], temp_files -def Load(log, path, if_dirs = [], cpp_if_dirs = [], include_paths = []): +def Load(log, path, if_dirs=None, cpp_if_dirs=None, include_paths=None): + + if if_dirs == None: + if_dirs = [] + + if cpp_if_dirs == None: + cpp_if_dirs = [] + + if include_paths == None: + include_paths = [] + temp_files = [] if path.endswith(".h"): From c9efc30f83a9a432d0389afcb5d135ded736ecbd Mon Sep 17 00:00:00 2001 From: sebaszm Date: Thu, 16 Jul 2026 14:45:39 +0200 Subject: [PATCH 2/5] address review comments --- JsonGenerator/source/header_loader.py | 9 +++++++-- JsonGenerator/source/json_loader.py | 6 +++--- ProxyStubGenerator/StubGenerator.py | 20 ++++++++++++++------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index 275da305..3ebc864f 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -31,6 +31,9 @@ import ProxyStubGenerator.CppParser as CppParser import ProxyStubGenerator.Interface as CppInterface +MODULE_FILE = "Module.h" +IDS_FILE = "Ids.h" + class CaseConverter: OBJECTS = 0 @@ -1612,10 +1615,12 @@ def LoadInterface(file, log, all, include_paths): includes = [] scanned = [] + source_path = os.path.dirname(file) + files = [] files.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), posixpath.normpath(config.DEFAULT_DEFINITIONS_FILE))) - files.append(os.path.join("@" + os.path.dirname(file), "Module.h")) - files.append(os.path.join("@" + os.path.dirname(file), "Ids.h")) + files.append(os.path.join(source_path, MODULE_FILE)) + files.append(os.path.join(source_path, IDS_FILE)) files.append(file) tree = CppParser.ParseFiles(files, config.FRAMEWORK_NAMESPACE, include_paths, log) diff --git a/JsonGenerator/source/json_loader.py b/JsonGenerator/source/json_loader.py index 200dd591..e4d264f0 100644 --- a/JsonGenerator/source/json_loader.py +++ b/JsonGenerator/source/json_loader.py @@ -1431,13 +1431,13 @@ def Scan(pairs): def Load(log, path, if_dirs=None, cpp_if_dirs=None, include_paths=None): - if if_dirs == None: + if if_dirs is None: if_dirs = [] - if cpp_if_dirs == None: + if cpp_if_dirs is None: cpp_if_dirs = [] - if include_paths == None: + if include_paths is None: include_paths = [] temp_files = [] diff --git a/ProxyStubGenerator/StubGenerator.py b/ProxyStubGenerator/StubGenerator.py index 01f48ade..a40679ea 100755 --- a/ProxyStubGenerator/StubGenerator.py +++ b/ProxyStubGenerator/StubGenerator.py @@ -63,6 +63,7 @@ DEFAULT_DEFINITIONS_FILE = "default.h" MODULE_FILE = "Module.h" +IDS_FILE = "Ids.h" log = Log.Log(NAME, BE_VERBOSE, SHOW_WARNINGS) @@ -2839,6 +2840,11 @@ def EmitRegistration(announce_list): help="include an additional C++ header file, can be used multiple times (default: include 'Module.h')") argparser.add_argument('-I', dest="includePaths", metavar="INCLUDE_DIR", action='append', default=[], type=str, help='add an include search path, can be used multiple times') + argparser.add_argument("--dump", + dest="dump", + action="store_true", + default=False, + help="Dump C++ parse tree") args = argparser.parse_args(sys.argv[1:]) SHOW_WARNINGS = not args.no_warnings @@ -2984,14 +2990,16 @@ def EmitRegistration(announce_list): for source_file in interface_files: try: - _extra_includes = [ os.path.join("@" + os.path.dirname(source_file), MODULE_FILE), - os.path.join("@" + os.path.dirname(source_file), "Ids.h") ] + source_path = os.path.dirname(source_file) + + extra_includes = [] + extra_includes.append("@" + os.path.join(source_path, MODULE_FILE)) + extra_includes.append("@" + os.path.join(source_path, IDS_FILE)) + extra_includes.extend(args.extra_includes) - _extra_includes.extend(args.extra_includes) + definition_file = "@" + os.path.join(os.path.dirname(os.path.realpath(__file__)), DEFAULT_DEFINITIONS_FILE) - tree = Parse(source_file, FRAMEWORK_NAMESPACE, args.includePaths, - os.path.join("@" + os.path.dirname(os.path.realpath(__file__)), DEFAULT_DEFINITIONS_FILE), - _extra_includes) + tree = Parse(source_file, FRAMEWORK_NAMESPACE, args.includePaths, definition_file, extra_includes) if args.code: log.Header(source_file) From 7dacb225251ff7680f93e211984bc59d288c3f55 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Thu, 16 Jul 2026 14:48:42 +0200 Subject: [PATCH 3/5] optionally include Module/Ids --- 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 3ebc864f..bc5f4288 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -1619,8 +1619,8 @@ def LoadInterface(file, log, all, include_paths): files = [] files.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), posixpath.normpath(config.DEFAULT_DEFINITIONS_FILE))) - files.append(os.path.join(source_path, MODULE_FILE)) - files.append(os.path.join(source_path, IDS_FILE)) + files.append("@" + os.path.join(source_path, MODULE_FILE)) + files.append("@" + os.path.join(source_path, IDS_FILE)) files.append(file) tree = CppParser.ParseFiles(files, config.FRAMEWORK_NAMESPACE, include_paths, log) From 164aa051b0f14fd49a60ce720edc6f9a4f4e0586 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Thu, 16 Jul 2026 14:55:08 +0200 Subject: [PATCH 4/5] remove debug --- ProxyStubGenerator/StubGenerator.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ProxyStubGenerator/StubGenerator.py b/ProxyStubGenerator/StubGenerator.py index a40679ea..dfbfa8eb 100755 --- a/ProxyStubGenerator/StubGenerator.py +++ b/ProxyStubGenerator/StubGenerator.py @@ -2840,11 +2840,6 @@ def EmitRegistration(announce_list): help="include an additional C++ header file, can be used multiple times (default: include 'Module.h')") argparser.add_argument('-I', dest="includePaths", metavar="INCLUDE_DIR", action='append', default=[], type=str, help='add an include search path, can be used multiple times') - argparser.add_argument("--dump", - dest="dump", - action="store_true", - default=False, - help="Dump C++ parse tree") args = argparser.parse_args(sys.argv[1:]) SHOW_WARNINGS = not args.no_warnings From 5e3997eef79eaf537265fdb0a9c4659a56c46c51 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Thu, 16 Jul 2026 15:02:30 +0200 Subject: [PATCH 5/5] sort out extra includes option --- ProxyStubGenerator/StubGenerator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ProxyStubGenerator/StubGenerator.py b/ProxyStubGenerator/StubGenerator.py index dfbfa8eb..7eaf8394 100755 --- a/ProxyStubGenerator/StubGenerator.py +++ b/ProxyStubGenerator/StubGenerator.py @@ -2836,8 +2836,7 @@ def EmitRegistration(announce_list): metavar="FILE", action='append', default=[], - nargs="*", - help="include an additional C++ header file, can be used multiple times (default: include 'Module.h')") + help="include an additional C++ header file, can be used multiple times") argparser.add_argument('-I', dest="includePaths", metavar="INCLUDE_DIR", action='append', default=[], type=str, help='add an include search path, can be used multiple times')