Skip to content

Commit

Permalink
allow json tag on the lookedup interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaszm committed May 8, 2024
1 parent fa83856 commit b7ab136
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions JsonGenerator/source/header_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ def BuildResult(vars, is_property=False):

if isinstance(var_type.Type(), CppParser.Class):
faces.append(([StripFrameworkNamespace(var_type.type.full_name), method.name, method.vars[0].name], _prefix, var_type.Type().methods))

if "@lookups" not in schema:
schema["@lookups"] = []

schema["@lookups"].append(faces[-1][0][0])
else:
raise CppParseError(method, "lookup method for an unknown class")

Expand Down Expand Up @@ -873,11 +878,6 @@ def BuildResult(vars, is_property=False):
if events:
schema["events"] = events

if config.DUMP_JSON:
print("\n// JSON interface for {} -----------".format(face.obj.name))
print(json.dumps(schema, indent=2))
print("// ----------------\n")

return schema

schemas = []
Expand All @@ -888,6 +888,15 @@ def BuildResult(vars, is_property=False):
if schema:
schemas.append(schema)

for s in schemas:
lookups = s["@lookups"] if "@lookups" in s else []
for l in lookups:
for s2 in schemas:
if StripFrameworkNamespace(s2["@fullname"]) == l:
del s2["@generated"]

schemas = [s for s in schemas if "@generated" in s]

return schemas, []

def LoadInterface(file, log, all = False, include_paths = []):
Expand All @@ -911,6 +920,13 @@ def LoadInterface(file, log, all = False, include_paths = []):
if not schemas:
log.Info("No interfaces found")

else:
if config.DUMP_JSON:
for s in schemas:
print("\n// JSON interface for %s -----------" % s["@fullname"])
print(json.dumps(s, indent=2))
print("// ----------------\n")

return schemas, includes

except CppParser.ParserError as ex:
Expand Down

0 comments on commit b7ab136

Please sign in to comment.