Fix skipdata setup (#1320)
* Fix skipdata_setup for when _cb is None
ctypes prototype does not accept None value,
so if we want to get a NULL function pointer
then we should either call it with no arguments
or pass zero as an argument.
Fixes #1316
* Do store and return skipdata_setup data
* Add convenience wrappers for skipdata_setup
* Uncomment skipdata_setup tests
* Add alternate usage variants to test_skipdata.py
* document getter
diff --git a/bindings/python/test_skipdata.py b/bindings/python/test_skipdata.py
index eae9c62..4817f9a 100755
--- a/bindings/python/test_skipdata.py
+++ b/bindings/python/test_skipdata.py
@@ -39,13 +39,21 @@
md.skipdata = True
- # Default "data" instruction's name is ".byte". To rename it to "db", just uncomment
+ # Default "data" instruction's name is ".byte". To rename it to "db", just use
# the code below.
- # md.skipdata_setup = ("db", None, None)
+ md.skipdata_setup = ("db", None, None)
# NOTE: This example ignores SKIPDATA's callback (first None) & user_data (second None)
+ # Can also use dedicated setter
+ md.skipdata_mnem = 'db'
- # To customize the SKIPDATA callback, uncomment the line below.
- # md.skipdata_setup = (".db", testcb, None)
+ # To customize the SKIPDATA callback, use the line below.
+ md.skipdata_setup = (".db", testcb, None)
+ # Or use dedicated setter with custom parameter
+ md.skipdata_cb = (testcb, 42)
+ # Or provide just a function
+ md.skipdata_cb = testcb
+ # Note that reading this property will always return a tuple
+ assert md.skipdata_cb == (testcb, None), md.skipdata_cb
for insn in md.disasm(code, 0x1000):
#bytes = binascii.hexlify(insn.bytes)