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

Dimbleby multiple bases #331

Closed
wants to merge 1 commit into from
Closed
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
53 changes: 26 additions & 27 deletions pyangbind/helpers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def build_store_from_definitions(self, ctx, defnd):
this_id = unresolved_identities.pop(0)
iddef = defnd[this_id]

base = iddef.search_one("base")
try:
mainmod = iddef.main_module()
except AttributeError:
Expand All @@ -89,22 +88,18 @@ def build_store_from_definitions(self, ctx, defnd):
defmod = mainmod

defining_module = defmod.arg

# Check we don't already have this identity defined
if self.find_identity_by_source_name(defining_module, iddef.arg) is not None:
continue

namespace = defmod.search_one("namespace").arg
prefix = defmod.search_one("prefix").arg

if base is None:
# Add a new identity which can be a base
tid = Identity(iddef.arg)
tid.source_module = defining_module
tid.source_namespace = namespace
tid.add_prefix(prefix)
self.add_identity(tid)
base_ids = []
bases = iddef.search("base")

if defining_module in mod_ref_prefixes:
for i in mod_ref_prefixes[defining_module]:
tid.add_prefix(i)

else:
for base in bases:
# Determine what the name of the base and the prefix for
# the base should be
if ":" in base.arg:
Expand All @@ -121,26 +116,30 @@ def build_store_from_definitions(self, ctx, defnd):
# and if not, then push this identity back onto the stack
unresolved_identities.append(this_id)
unresolved_identity_count[this_id] += 1
break
# FIXME(Joey Wilhelm): `unresolved_idc` and `ident` are both undefined. What is the intent of this code?
# if unresolved_identity_count[this_id] > 1000:
# if unresolved_idc[ident] > 1000:
# sys.stderr.write("could not find a match for %s base: %s\n" %
# (iddef.arg, base_name))
# error_ids.append(ident)
else:
# Check we don't already have this identity defined
if self.find_identity_by_source_name(defining_module, iddef.arg) is None:
# otherwise, create a new identity that reflects this one
tid = Identity(iddef.arg)
tid.source_module = defining_module
tid.source_namespace = namespace
tid.add_prefix(prefix)
base_id.add_child(tid)
self.add_identity(tid)

if defining_module in mod_ref_prefixes:
for i in mod_ref_prefixes[defining_module]:
tid.add_prefix(i)

base_ids.append(base_id)

else:
# We found all the bases (of which there may be none).
# Create a new identity that reflects this one.
tid = Identity(iddef.arg)
tid.source_module = defining_module
tid.source_namespace = namespace
tid.add_prefix(prefix)
self.add_identity(tid)
for base_id in base_ids:
base_id.add_child(tid)

if defining_module in mod_ref_prefixes:
for i in mod_ref_prefixes[defining_module]:
tid.add_prefix(i)

if error_ids:
raise TypeError("could not resolve identities %s" % error_ids)
Expand Down