Debian Codegraph @

extra_tests/cffi_tests/cffi0/test_cdata.py

raw symbols SCIP
1 # Generated by pypy/tool/import_cffi.py
2 from cffi import FFI
3
4 class FakeBackend(object):
5
6 def nonstandard_integer_types(self):
7 return {}
8
9 def sizeof(self, name):
10 return 1
11
12 def load_library(self, path):
13 return "fake library"
14
15 def new_primitive_type(self, name):
16 return FakeType("primitive " + name)
17
18 def new_void_type(self):
19 return FakeType("void")
20 def new_pointer_type(self, x):
21 return FakeType('ptr-to-%r' % (x,))
22 def new_array_type(self, x, y):
23 return FakeType('array-from-%r-len-%r' % (x, y))
24 def cast(self, x, y):
25 return 'casted!'
26 def _get_types(self):
27 return "CData", "CType"
28
29 buffer = "buffer type"
30
31
32 class FakeType(object):
33 def __init__(self, cdecl):
34 self.cdecl = cdecl
35
36
37 def test_typeof():
38 ffi = FFI(backend=FakeBackend())
39 clong = ffi.typeof("signed long int")
40 assert isinstance(clong, FakeType)
41 assert clong.cdecl == 'primitive long'