File: withunicode.py

package info (click to toggle)
python-cffi 2.0.0~b1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,796 kB
  • sloc: python: 28,456; ansic: 15,272; asm: 116; makefile: 97; sh: 14
file content (26 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys, cffi
if sys.version_info < (3,):
    u_prefix = "u"
else:
    u_prefix = ""
    unichr = chr


ffi = cffi.FFI()

ffi.embedding_api(u"""
    int add1(int, int);
""")

ffi.embedding_init_code(("""
    import sys, time
    for c in %s'""" + unichr(0x00ff) + unichr(0x1234) + unichr(0xfedc) + """':
        sys.stdout.write(str(ord(c)) + '\\n')
    sys.stdout.flush()
""") % u_prefix)

ffi.set_source("_withunicode_cffi", """
""")

fn = ffi.compile(verbose=True)
print('FILENAME: %s' % (fn,))