Mercurial > pub > dyncall > bindings
view python/pydc/examples/atoi.py @ 37:8c8f848131c6
- version bump
- better doc
- made calling convention mode reset by default, as only way to specify convention used is via signature string
author | Tassilo Philipp |
---|---|
date | Mon, 13 Apr 2020 20:08:54 +0200 |
parents | edbbd467f50a |
children | a2125195b052 |
line wrap: on
line source
from pydc import * import sys import platform if sys.platform == "win32": libc = load("msvcrt") elif sys.platform == "darwin": libc = load("/usr/lib/libc.dylib") elif "bsd" in sys.platform: #libc = load("/usr/lib/libc.so") libc = load("/lib/libc.so.7") elif platform.architecture()[0] == "64bit": libc = load("/lib64/libc.so.6") else: libc = load("/lib/libc.so.6") fp_atoi = find(libc,"atoi") fp_atof = find(libc,"atof") def atoi(s): return call(fp_atoi,"Z)i",s) def atod(s): return call(fp_atof,"Z)d",s) print(atoi("3".join(["12","45"]))) print(atod("3".join(["12","45"])))