Skip to content

Commit

Permalink
Fix TypeContainer's instantiation of Type objects
Browse files Browse the repository at this point in the history
  • Loading branch information
plafosse committed Dec 13, 2023
1 parent 2524623 commit 70062be
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/typecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def get_type_by_id(self, type_id: str) -> Optional['ty_.Type']:
result = ctypes.POINTER(core.BNType)()
if not core.BNTypeContainerGetTypeById(self.handle, type_id, result):
return None
return ty_.Type(handle=result)
return ty_.Type.create(handle=result)

@property
def types(self) -> Optional[Mapping[str, Tuple['ty_.QualifiedName', 'ty_.Type']]]:
Expand All @@ -218,7 +218,9 @@ def types(self) -> Optional[Mapping[str, Tuple['ty_.QualifiedName', 'ty_.Type']]
for i in range(result_count.value):
name = ty_.QualifiedName._from_core_struct(result_names[i])
id = core.pyNativeStr(result_ids[i])
type = ty_.Type(handle=core.BNNewTypeReference(result_types[i]))
ref_handle = core.BNNewTypeReference(result_types[i])
assert ref_handle is not None
type = ty_.Type.create(handle=ref_handle)
result[id] = (name, type)

core.BNFreeTypeNameList(result_names, result_count.value)
Expand All @@ -236,7 +238,7 @@ def get_type_by_name(self, type_name: 'ty_.QualifiedNameType') -> Optional['ty_.
result = ctypes.POINTER(core.BNType)()
if not core.BNTypeContainerGetTypeByName(self.handle, ty_.QualifiedName(type_name)._to_core_struct(), result):
return None
return ty_.Type(handle=result)
return ty_.Type.create(handle=result)

@property
def type_ids(self) -> Optional[List[str]]:
Expand Down

0 comments on commit 70062be

Please sign in to comment.