MCPcopy Create free account
hub / github.com/capstone-engine/capstone / __init__

Method __init__

bindings/python/capstone/__init__.py:914–953  ·  view source on GitHub ↗
(self, arch, mode)

Source from the content-addressed store, hash-verified

912
913class Cs(object):
914 def __init__(self, arch, mode):
915 # verify version compatibility with the core before doing anything
916 (major, minor, _combined) = cs_version()
917 if major != CS_API_MAJOR or minor != CS_API_MINOR:
918 self.csh = None
919 # our binding version is different from the core's API version
920 raise CsError(CS_ERR_VERSION)
921
922 self.arch, self._mode = arch, mode
923 self.csh = ctypes.c_size_t()
924 status = _cs.cs_open(arch, mode, ctypes.byref(self.csh))
925 if status != CS_ERR_OK:
926 self.csh = None
927 raise CsError(status)
928
929 try:
930 from . import ccapstone
931 # rewire disasm to use the faster version
932 setattr(self, "disasm", ccapstone.Cs(self).disasm)
933 except:
934 pass
935
936 if arch == CS_ARCH_X86:
937 # Intel syntax is default for X86
938 self._syntax = CS_OPT_SYNTAX_INTEL
939 else:
940 self._syntax = None
941
942 self._detail = False # by default, do not produce instruction details
943 self._imm_unsigned = False # by default, print immediate operands as signed numbers
944 self._diet = cs_support(CS_SUPPORT_DIET)
945 self._x86reduce = cs_support(CS_SUPPORT_X86_REDUCE)
946
947 # default mnemonic for SKIPDATA
948 self._skipdata_mnem = ".byte"
949 self._skipdata_cb = (None, None)
950 # store reference to option object to avoid it being freed
951 # because C code uses it by reference
952 self._skipdata_opt = _cs_opt_skipdata()
953 self._skipdata = False
954
955
956

Callers

nothing calls this directly

Calls 5

CsErrorClass · 0.85
_cs_opt_skipdataClass · 0.85
cs_openMethod · 0.80
cs_versionFunction · 0.70
cs_supportFunction · 0.70

Tested by

no test coverage detected