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

[Stubgen] omit tag supresses no interface warning #74

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Changes from all commits
Commits
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
35 changes: 23 additions & 12 deletions ProxyStubGenerator/StubGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,16 @@ def __init__(self, obj, iid, file):
# Looks for interface classes (ie. classes inheriting from Core::Unknown and specifying ID enum).
def FindInterfaceClasses(tree, namespace):
interfaces = []
omit_interface_used = False

def __Traverse(tree, interface_namespace, faces):
nonlocal omit_interface_used

if isinstance(tree, CppParser.Namespace) or isinstance(tree, CppParser.Class):
for c in tree.classes:
if c.omit:
omit_interface_used = True

if not isinstance(c, CppParser.TemplateClass):
if (c.full_name.startswith(interface_namespace + "::")):
inherits_iunknown = False
Expand All @@ -148,7 +154,7 @@ def __Traverse(tree, interface_namespace, faces):
has_id = True
break

if not has_id and not c.omit:
if not has_id:
log.Warn("class %s does not have an ID enumerator" % c.full_name, source_file)

__Traverse(c, interface_namespace, faces)
Expand All @@ -159,7 +165,7 @@ def __Traverse(tree, interface_namespace, faces):

__Traverse(tree, namespace, interfaces)

return interfaces
return interfaces, omit_interface_used


# Cut out scope resolution operators from all identifiers found in a string
Expand Down Expand Up @@ -212,7 +218,7 @@ def GenerateLuaData(emit, interfaces_list, enums_list, source_file=None, tree=No

return

interfaces = FindInterfaceClasses(tree, ns)
interfaces, _ = FindInterfaceClasses(tree, ns)
if not interfaces:
return []

Expand Down Expand Up @@ -535,12 +541,12 @@ def GenerateStubs2(output_file, source_file, tree, ns, scan_only=False):
if not FORCE and (os.path.exists(output_file) and (os.path.getmtime(source_file) < os.path.getmtime(output_file))):
raise NotModifiedException(output_file)

interfaces = FindInterfaceClasses(tree, ns)
interfaces, omit_interface_used = FindInterfaceClasses(tree, ns)
if not interfaces:
return []
return [], omit_interface_used

if scan_only:
return interfaces
return interfaces, omit_interface_used

interface_header_name = os.path.basename(source_file)

Expand Down Expand Up @@ -1176,6 +1182,7 @@ def PrepareParams(method, interface):
if not obj.full_name.startswith(ns + "::"):
log.Info("class %s not in requested namespace (%s)" % (obj.full_name, ns))
elif obj.omit:
omit_interface_used = True
log.Info("omitting class %s" % interface_name)
else:
# Of course consider only virtual methods
Expand Down Expand Up @@ -1953,7 +1960,7 @@ def EmitProxy(interface_name, methods, proxy_name, interface, prepared_params):
emit.Line()
emit.Line("}") # // namespace %s" % STUB_NAMESPACE.split("::")[-1])

return interfaces
return interfaces, omit_interface_used

def GenerateIdentification(name):
if not os.path.exists(name):
Expand Down Expand Up @@ -2228,18 +2235,22 @@ def GenerateIdentification(name):
os.makedirs(out_dir)

new_faces = []
some_omitted = False

for ns in INTERFACE_NAMESPACES:
output = GenerateStubs2(output_file, source_file, tree, ns, scan_only)
output, some_omitted = GenerateStubs2(output_file, source_file, tree, ns, scan_only)

new_faces += output

if not new_faces:
raise NoInterfaceError

faces += new_faces
if not some_omitted:
raise NoInterfaceError
else:
log.Info("no interface classes found")

log.Print("created file %s" % os.path.basename(output_file))
else:
faces += new_faces
log.Print("created file %s" % os.path.basename(output_file))

# dump interfaces if only scanning
if scan_only:
Expand Down