mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
python bindings: add core functions with _bytes suffix that do not decode strings
This commit is contained in:
parent
591abead4b
commit
c2cb2c9fad
|
@ -338,26 +338,33 @@ def Z3_set_error_handler(ctx, hndlr, _elems=Elementaries(_lib.Z3_set_error_handl
|
||||||
""")
|
""")
|
||||||
|
|
||||||
for sig in _API2PY:
|
for sig in _API2PY:
|
||||||
name = sig[0]
|
mk_py_wrapper_single(sig)
|
||||||
result = sig[1]
|
if sig[1] == STRING:
|
||||||
params = sig[2]
|
mk_py_wrapper_single(sig, decode_string=False)
|
||||||
num = len(params)
|
|
||||||
core_py.write("def %s(" % name)
|
def mk_py_wrapper_single(sig, decode_string=True):
|
||||||
display_args(num)
|
name = sig[0]
|
||||||
comma = ", " if num != 0 else ""
|
result = sig[1]
|
||||||
core_py.write("%s_elems=Elementaries(_lib.%s)):\n" % (comma, name))
|
params = sig[2]
|
||||||
lval = "r = " if result != VOID else ""
|
num = len(params)
|
||||||
core_py.write(" %s_elems.f(" % lval)
|
def_name = name
|
||||||
display_args_to_z3(params)
|
if not decode_string:
|
||||||
core_py.write(")\n")
|
def_name += '_bytes'
|
||||||
if len(params) > 0 and param_type(params[0]) == CONTEXT and not name in Unwrapped:
|
core_py.write("def %s(" % def_name)
|
||||||
core_py.write(" _elems.Check(a0)\n")
|
display_args(num)
|
||||||
if result == STRING:
|
comma = ", " if num != 0 else ""
|
||||||
core_py.write(" return _to_pystr(r)\n")
|
core_py.write("%s_elems=Elementaries(_lib.%s)):\n" % (comma, name))
|
||||||
elif result != VOID:
|
lval = "r = " if result != VOID else ""
|
||||||
core_py.write(" return r\n")
|
core_py.write(" %s_elems.f(" % lval)
|
||||||
core_py.write("\n")
|
display_args_to_z3(params)
|
||||||
core_py
|
core_py.write(")\n")
|
||||||
|
if len(params) > 0 and param_type(params[0]) == CONTEXT and not name in Unwrapped:
|
||||||
|
core_py.write(" _elems.Check(a0)\n")
|
||||||
|
if result == STRING and decode_string:
|
||||||
|
core_py.write(" return _to_pystr(r)\n")
|
||||||
|
elif result != VOID:
|
||||||
|
core_py.write(" return r\n")
|
||||||
|
core_py.write("\n")
|
||||||
|
|
||||||
|
|
||||||
## .NET API native interface
|
## .NET API native interface
|
||||||
|
|
Loading…
Reference in a new issue