annotate python/pydc/examples/atoi.py @ 5:bf5625bb6f05

- brought python binding up to dc v0.9
author cslag
date Tue, 22 Mar 2016 01:49:34 +0100
parents 0cfcc391201f
children edbbd467f50a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 from pydc import *
5
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
2 import sys
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
3 import platform
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4
5
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
5 if sys.platform == "win32":
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 libc = load("msvcrt")
5
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
7 elif sys.platform == "darwin":
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 libc = load("/usr/lib/libc.dylib")
5
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
9 elif "bsd" in sys.platform:
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
10 libc = load("/usr/lib/libc.so")
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
11 elif platform.architecture()[0] == "64bit":
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
12 libc = load("/lib64/libc.so.6")
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 else:
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 libc = load("/lib/libc.so.6")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 fp_atoi = find(libc,"atoi")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 fp_atof = find(libc,"atof")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18
5
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
19
bf5625bb6f05 - brought python binding up to dc v0.9
cslag
parents: 0
diff changeset
20
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 def atoi(s): return call(fp_atoi,"p)i",s)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 def atod(s): return call(fp_atof,"p)d",s)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 print atoi( "3".join(["12","45"]) )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25 print atod( "3".join(["12","45"]) )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26