9
9
import functools
10
10
import weakref
11
11
import warnings
12
-
13
12
from unicorn import unicorn_const as uc
14
13
from .arch .types import uc_err , uc_engine , uc_context , uc_hook_h , UcReg , VT
15
14
16
- # __version__ = f'{uc.UC_VERSION_MAJOR}.{uc.UC_VERSION_MINOR}.{uc.UC_VERSION_PATCH}'
17
15
18
16
MemRegionStruct = Tuple [int , int , int ]
19
17
TBStruct = Tuple [int , int , int ]
@@ -632,25 +630,6 @@ class Uc(RegStateManager):
632
630
"""Unicorn Engine class.
633
631
"""
634
632
635
- # Code snippet modified from:
636
- # https://stackoverflow.com/questions/2536307/decorators-in-the-python-standard-lib-deprecated-specifically
637
- @staticmethod
638
- def __deprecated (msg : str ):
639
- def __deprecated_inner (func : Callable ) -> Callable :
640
- """Use this decorator to mark functions as deprecated.
641
- Every time the decorated function runs, it will emit
642
- a "deprecation" warning."""
643
- @functools .wraps (func )
644
- def new_func (* args , ** kwargs ):
645
- warnings .simplefilter ('always' , DeprecationWarning ) # turn off filter
646
- warnings .warn ("Call to a deprecated function {}. {}" .format (func .__name__ , msg ),
647
- category = DeprecationWarning ,
648
- stacklevel = 2 )
649
- warnings .simplefilter ('default' , DeprecationWarning ) # reset filter
650
- return func (* args , ** kwargs )
651
- return new_func
652
- return __deprecated_inner
653
-
654
633
@staticmethod
655
634
def __is_compliant () -> bool :
656
635
"""Checks whether Unicorn binding version complies with Unicorn library.
@@ -1455,15 +1434,6 @@ def ctl_flush_tb(self) -> None:
1455
1434
1456
1435
self .__ctl_w (uc .UC_CTL_TB_FLUSH )
1457
1436
1458
- @__deprecated ("You should use ctl_set_tlb_mode instead." )
1459
- def ctl_tlb_mode (self , mode : int ) -> None :
1460
- """Deprecated, please use ctl_set_tlb_mode instead.
1461
-
1462
- Args:
1463
- mode: tlb mode to use (see UC_TLB_* constants)
1464
- """
1465
- self .ctl_set_tlb_mode (mode )
1466
-
1467
1437
def ctl_set_tlb_mode (self , mode : int ) -> None :
1468
1438
"""Set TLB mode.
1469
1439
@@ -1475,6 +1445,16 @@ def ctl_set_tlb_mode(self, mode: int) -> None:
1475
1445
(ctypes .c_uint , mode )
1476
1446
)
1477
1447
1448
+ # For backward compatibility...
1449
+ def ctl_tlb_mode (self , mode : int ) -> None :
1450
+ """Deprecated, please use ctl_set_tlb_mode instead.
1451
+
1452
+ Args:
1453
+ mode: tlb mode to use (see UC_TLB_* constants)
1454
+ """
1455
+ warnings .warn ('Deprecated method, use ctl_set_tlb_mode' , DeprecationWarning )
1456
+ self .ctl_set_tlb_mode (mode )
1457
+
1478
1458
def ctl_get_tcg_buffer_size (self ) -> int :
1479
1459
"""Retrieve TCG buffer size.
1480
1460
0 commit comments