2
Support to turn GetSetProperty objects into W_Objects containing a
3
property object of CPython.
6
from pypy.interpreter.baseobjspace import SpaceCache
7
from pypy.interpreter.gateway import ObjSpace, W_Root, interp2app
8
from pypy.interpreter.function import BuiltinFunction
9
from pypy.objspace.cpy.objspace import W_Object
12
class PropertyCache(SpaceCache):
13
def build(cache, prop):
17
for f, arity in [(prop.fget, 1),
23
unwrap_spec = [ObjSpace] + [W_Root]*arity
24
func = interp2app(f, unwrap_spec=unwrap_spec)
25
func = func.__spacebind__(space)
26
bltin = BuiltinFunction(func)
27
res = space.wrap(bltin).value
30
# make a CPython property
31
p = property(reslist[0], reslist[1], reslist[2], prop.doc)
33
w_result = W_Object(p)
34
space.wrap_cache[id(w_result)] = w_result, p, follow_annotations
38
def follow_annotations(bookkeeper, w_property):
39
from pypy.annotation import model as annmodel
41
for f, arity, key in [(p.fget, 1, 'get'),
45
s_func = bookkeeper.immutablevalue(f)
46
args_s = [annmodel.SomeObject()] * arity
48
bookkeeper.emulate_pbc_call(uniquekey, s_func, args_s)