Skip to content

Commit 39cc8da

Browse files
committed
[Python] Update function signatures of some type library APIs
1 parent 5d6da80 commit 39cc8da

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

python/typelibrary.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def type_container(self) -> 'typecontainer.TypeContainer':
359359
"""
360360
return typecontainer.TypeContainer(core.BNGetTypeLibraryTypeContainer(self.handle))
361361

362-
def add_named_object(self, name: 'types.QualifiedName', type: 'types.Type') -> None:
362+
def add_named_object(self, name: Union[types.QualifiedName, str], type: 'types.Type') -> None:
363363
"""
364364
`add_named_object` directly inserts a named object into the type library's object store.
365365
This is not done recursively, so care should be taken that types referring to other types
@@ -380,14 +380,16 @@ def add_named_object(self, name: 'types.QualifiedName', type: 'types.Type') -> N
380380
raise ValueError("type must be a Type")
381381
core.BNAddTypeLibraryNamedObject(self.handle, name._to_core_struct(), type.handle)
382382

383-
def remove_named_object(self, name: 'types.QualifiedName') -> None:
383+
def remove_named_object(self, name: Union[types.QualifiedName, str]) -> None:
384384
"""
385385
`remove_named_object` removes a named object from the type library's object store.
386386
This does not remove any types that are referenced by the object, only the object itself.
387387
388388
:param QualifiedName name:
389389
:rtype: None
390390
"""
391+
if not isinstance(name, types.QualifiedName):
392+
name = types.QualifiedName(name)
391393
core.BNRemoveTypeLibraryNamedObject(self.handle, name._to_core_struct())
392394

393395
def add_named_type(self, name: 'types.QualifiedNameType', type: 'types.Type') -> None:
@@ -411,20 +413,24 @@ def add_named_type(self, name: 'types.QualifiedNameType', type: 'types.Type') ->
411413
raise ValueError("parameter type must be a Type")
412414
core.BNAddTypeLibraryNamedType(self.handle, name._to_core_struct(), type.handle)
413415

414-
def remove_named_type(self, name: 'types.QualifiedName') -> None:
416+
def remove_named_type(self, name: Union[types.QualifiedName, str]) -> None:
415417
"""
416418
`remove_named_type` removes a named type from the type library's type store.
417419
This does not remove any objects that reference the type, only the type itself.
418420
"""
421+
if not isinstance(name, types.QualifiedName):
422+
name = types.QualifiedName(name)
419423
core.BNRemoveTypeLibraryNamedType(self.handle, name._to_core_struct())
420424

421-
def add_type_source(self, name: types.QualifiedName, source: str) -> None:
425+
def add_type_source(self, name: Union[types.QualifiedName, str], source: str) -> None:
422426
"""
423427
Manually flag NamedTypeReferences to the given QualifiedName as originating from another source
424428
TypeLibrary with the given dependency name.
425429
426430
.. warning:: Use this api with extreme caution.
427431
"""
432+
if not isinstance(name, types.QualifiedName):
433+
name = types.QualifiedName(name)
428434
core.BNAddTypeLibraryNamedTypeSource(self.handle, types.QualifiedName(name)._to_core_struct(), source)
429435

430436
def get_named_object(self, name: Union[types.QualifiedName, str]) -> Optional[types.Type]:

0 commit comments

Comments
 (0)