Skip to content

Commit

Permalink
base/database: updated the types namespace to use `internal.interfa…
Browse files Browse the repository at this point in the history
…ce.tinfo.get_numbered_type` when fetching types by ordinal.
  • Loading branch information
arizvisa committed Dec 2, 2023
1 parent 3cc887e commit f0f729a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions base/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5443,11 +5443,11 @@ def __iterate__(cls, library):
'''Iterate through the types within the specified type `library`.'''
count, errors = idaapi.get_ordinal_qty(library), {getattr(idaapi, name) : name for name in dir(idaapi) if name.startswith('sc_')}
for ordinal in builtins.range(1, count):
name, serialized = idaapi.get_numbered_type_name(library, ordinal), idaapi.get_numbered_type(library, ordinal)
name, serialized = idaapi.get_numbered_type_name(library, ordinal), interface.tinfo.get_numbered_type(library, ordinal)

# if we didn't get any information returned, then this ordinal was deleted.
if serialized is None:
logging.warning(u"{:s}.__iterate__({:s}) : Skipping the type at the current ordinal ({:d}) due to it having been deleted.".format('.'.join([__name__, cls.__name__]), cls.__formatter__(library), ordinal))
logging.info(u"{:s}.__iterate__({:s}) : Skipping the type at the current ordinal ({:d}) due to it having been deleted.".format('.'.join([__name__, cls.__name__]), cls.__formatter__(library), ordinal))
continue

# try and create a new type from the serialized information. if we
Expand All @@ -5459,7 +5459,7 @@ def __iterate__(cls, library):

# if the type is empty, then we can just issue a warning and skip it.
elif ti.empty():
logging.warning(u"{:s}.__iterate__({:s}) : Skipping the type at the current ordinal ({:d}) due to it being empty.".format('.'.join([__name__, cls.__name__]), cls.__formatter__(library), ordinal))
logging.info(u"{:s}.__iterate__({:s}) : Skipping the type at the current ordinal ({:d}) due to it being empty.".format('.'.join([__name__, cls.__name__]), cls.__formatter__(library), ordinal))
continue

yield ordinal, utils.string.of(name or ''), ti
Expand Down Expand Up @@ -5674,7 +5674,7 @@ def has(cls, name):
@classmethod
def has(cls, ordinal, library):
'''Return whether the provided type `library` has a type at the given `ordinal`.'''
serialized = idaapi.get_numbered_type(library, ordinal)
serialized = interface.tinfo.get_numbered_type(library, ordinal)
return True if serialized else False
@utils.multicase(name=internal.types.string, library=idaapi.til_t)
@classmethod
Expand Down Expand Up @@ -5796,7 +5796,7 @@ def get(cls, name):
def get(cls, ordinal, library):
'''Get the type information at the given `ordinal` of the specified type `library` and return it.'''
if 0 < ordinal < idaapi.get_ordinal_qty(library):
serialized = idaapi.get_numbered_type(library, ordinal)
serialized = interface.tinfo.get_numbered_type(library, ordinal)
return interface.tinfo.get(library, *serialized)
raise E.ItemNotFoundError(u"{:s}.get({:d}, {:s}) : No type information was found for the specified ordinal ({:d}) in the type library.".format('.'.join([__name__, cls.__name__]), ordinal, cls.__formatter__(library), ordinal))
@utils.multicase(name=internal.types.string, library=idaapi.til_t)
Expand Down

0 comments on commit f0f729a

Please sign in to comment.