本文整理汇总了Python中pypy.module.cpyext.api.generic_cpy_call函数的典型用法代码示例。如果您正苦于以下问题:Python generic_cpy_call函数的具体用法?Python generic_cpy_call怎么用?Python generic_cpy_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generic_cpy_call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _Py_Dealloc
def _Py_Dealloc(space, obj):
from pypy.module.cpyext.api import generic_cpy_call
pto = obj.c_ob_type
#print >>sys.stderr, "Calling dealloc slot", pto.c_tp_dealloc, "of", obj, \
# "'s type which is", rffi.charp2str(pto.c_tp_name)
rawrefcount.mark_deallocating(w_marker_deallocating, obj)
generic_cpy_call(space, pto.c_tp_dealloc, obj)
开发者ID:mozillazg,项目名称:pypy,代码行数:7,代码来源:pyobject.py
示例2: call
def call(self, space, w_self, w_args, w_kw):
# Call the C function
if w_self is None:
w_self = self.w_self
flags = rffi.cast(lltype.Signed, self.ml.c_ml_flags)
flags &= ~(METH_CLASS | METH_STATIC | METH_COEXIST)
if space.is_true(w_kw) and not flags & METH_KEYWORDS:
raise OperationError(space.w_TypeError, space.wrap(self.name + "() takes no keyword arguments"))
func = rffi.cast(PyCFunction, self.ml.c_ml_meth)
length = space.int_w(space.len(w_args))
if flags & METH_KEYWORDS:
func = rffi.cast(PyCFunctionKwArgs, self.ml.c_ml_meth)
return generic_cpy_call(space, func, w_self, w_args, w_kw)
elif flags & METH_NOARGS:
if length == 0:
return generic_cpy_call(space, func, w_self, None)
raise OperationError(space.w_TypeError, space.wrap(self.name + "() takes no arguments"))
elif flags & METH_O:
if length != 1:
raise oefmt(space.w_TypeError, "%s() takes exactly one argument (%d given)", self.name, length)
w_arg = space.getitem(w_args, space.wrap(0))
return generic_cpy_call(space, func, w_self, w_arg)
elif flags & METH_VARARGS:
return generic_cpy_call(space, func, w_self, w_args)
else: # METH_OLDARGS, the really old style
size = length
if size == 1:
w_arg = space.getitem(w_args, space.wrap(0))
elif size == 0:
w_arg = None
else:
w_arg = w_args
return generic_cpy_call(space, func, w_self, w_arg)
开发者ID:cimarieta,项目名称:usp,代码行数:34,代码来源:methodobject.py
示例3: PyObject_AsCharBuffer
def PyObject_AsCharBuffer(space, obj, bufferp, sizep):
"""Returns a pointer to a read-only memory location usable as
character-based input. The obj argument must support the single-segment
character buffer interface. On success, returns 0, sets buffer to the
memory location and size to the buffer length. Returns -1 and sets a
TypeError on error.
"""
pto = obj.c_ob_type
pb = pto.c_tp_as_buffer
if not (pb and pb.c_bf_getbuffer):
raise OperationError(space.w_TypeError, space.wrap(
"expected an object with the buffer interface"))
with lltype.scoped_alloc(Py_buffer) as view:
ret = generic_cpy_call(
space, pb.c_bf_getbuffer,
obj, view, rffi.cast(rffi.INT_real, PyBUF_SIMPLE))
if rffi.cast(lltype.Signed, ret) == -1:
return -1
bufferp[0] = rffi.cast(rffi.CCHARP, view.c_buf)
sizep[0] = view.c_len
if pb.c_bf_releasebuffer:
generic_cpy_call(space, pb.c_bf_releasebuffer,
obj, view)
Py_DecRef(space, view.c_obj)
return 0
开发者ID:Qointum,项目名称:pypy,代码行数:28,代码来源:object.py
示例4: subtype_dealloc
def subtype_dealloc(space, obj):
pto = obj.c_ob_type
base = pto
this_func_ptr = llslot(space, subtype_dealloc)
while base.c_tp_dealloc == this_func_ptr:
base = base.c_tp_base
assert base
dealloc = base.c_tp_dealloc
# XXX call tp_del if necessary
generic_cpy_call(space, dealloc, obj)
开发者ID:mozillazg,项目名称:pypy,代码行数:10,代码来源:typeobject.py
示例5: subtype_dealloc
def subtype_dealloc(space, obj):
pto = obj.c_ob_type
base = pto
this_func_ptr = llhelper(subtype_dealloc.api_func.functype, subtype_dealloc.api_func.get_wrapper(space))
while base.c_tp_dealloc == this_func_ptr:
base = base.c_tp_base
assert base
dealloc = base.c_tp_dealloc
# XXX call tp_del if necessary
generic_cpy_call(space, dealloc, obj)
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:typeobject.py
示例6: wrap_descr_delete
def wrap_descr_delete(space, w_self, w_args, func):
func_target = rffi.cast(descrsetfunc, func)
check_num_args(space, w_args, 1)
w_obj, = space.fixedview(w_args)
res = generic_cpy_call(space, func_target, w_self, w_obj, None)
if rffi.cast(lltype.Signed, res) == -1:
space.fromcache(State).check_and_raise_exception(always=True)
开发者ID:mozillazg,项目名称:pypy,代码行数:7,代码来源:slotdefs.py
示例7: wrap_ssizessizeargfunc
def wrap_ssizessizeargfunc(space, w_self, w_args, func):
func_target = rffi.cast(ssizessizeargfunc, func)
check_num_args(space, w_args, 2)
args_w = space.fixedview(w_args)
start = space.int_w(args_w[0])
end = space.int_w(args_w[1])
return generic_cpy_call(space, func_target, w_self, start, end)
开发者ID:mozillazg,项目名称:pypy,代码行数:7,代码来源:slotdefs.py
示例8: wrap_hashfunc
def wrap_hashfunc(space, w_self, w_args, func):
func_target = rffi.cast(hashfunc, func)
check_num_args(space, w_args, 0)
res = generic_cpy_call(space, func_target, w_self)
if res == -1:
space.fromcache(State).check_and_raise_exception(always=True)
return space.wrap(res)
开发者ID:mozillazg,项目名称:pypy,代码行数:7,代码来源:slotdefs.py
示例9: wrap_getbuffer
def wrap_getbuffer(space, w_self, w_args, func):
func_target = rffi.cast(getbufferproc, func)
with lltype.scoped_alloc(Py_buffer) as pybuf:
_flags = 0
if space.len_w(w_args) > 0:
_flags = space.int_w(space.listview(w_args)[0])
flags = rffi.cast(rffi.INT_real,_flags)
size = generic_cpy_call(space, func_target, w_self, pybuf, flags)
if widen(size) < 0:
space.fromcache(State).check_and_raise_exception(always=True)
ptr = pybuf.c_buf
size = pybuf.c_len
ndim = widen(pybuf.c_ndim)
shape = [pybuf.c_shape[i] for i in range(ndim)]
if pybuf.c_strides:
strides = [pybuf.c_strides[i] for i in range(ndim)]
else:
strides = [1]
if pybuf.c_format:
format = rffi.charp2str(pybuf.c_format)
else:
format = 'B'
return space.newbuffer(CPyBuffer(ptr, size, w_self, format=format,
ndim=ndim, shape=shape, strides=strides,
itemsize=pybuf.c_itemsize,
readonly=widen(pybuf.c_readonly)))
开发者ID:mozillazg,项目名称:pypy,代码行数:26,代码来源:slotdefs.py
示例10: setter
def setter(self, space, w_self, w_value):
assert isinstance(self, W_GetSetPropertyEx)
check_descr(space, w_self, self.w_type)
res = generic_cpy_call(space, self.getset.c_set, w_self, w_value, self.getset.c_closure)
if rffi.cast(lltype.Signed, res) < 0:
state = space.fromcache(State)
state.check_and_raise_exception()
开发者ID:Qointum,项目名称:pypy,代码行数:7,代码来源:typeobject.py
示例11: wrap_getbuffer
def wrap_getbuffer(space, w_self, w_args, func):
func_target = rffi.cast(getbufferproc, func)
with lltype.scoped_alloc(Py_buffer) as view:
flags = rffi.cast(rffi.INT_real, 0)
ret = generic_cpy_call(space, func_target, w_self, view, flags)
if rffi.cast(lltype.Signed, ret) == -1:
space.fromcache(State).check_and_raise_exception(always=True)
return space.newbuffer(CPyBuffer(view.c_buf, view.c_len, w_self))
开发者ID:Qointum,项目名称:pypy,代码行数:8,代码来源:slotdefs.py
示例12: test_string_buffer
def test_string_buffer(self, space, api):
py_str = new_empty_str(space, 10)
c_buf = py_str.c_ob_type.c_tp_as_buffer
assert c_buf
py_obj = rffi.cast(PyObject, py_str)
assert generic_cpy_call(space, c_buf.c_bf_getsegcount,
py_obj, lltype.nullptr(Py_ssize_tP.TO)) == 1
ref = lltype.malloc(Py_ssize_tP.TO, 1, flavor='raw')
assert generic_cpy_call(space, c_buf.c_bf_getsegcount,
py_obj, ref) == 1
assert ref[0] == 10
lltype.free(ref, flavor='raw')
ref = lltype.malloc(rffi.VOIDPP.TO, 1, flavor='raw')
assert generic_cpy_call(space, c_buf.c_bf_getreadbuffer,
py_obj, 0, ref) == 10
lltype.free(ref, flavor='raw')
Py_DecRef(space, py_obj)
开发者ID:mozillazg,项目名称:pypy,代码行数:17,代码来源:test_bytesobject.py
示例13: wrap_delattr
def wrap_delattr(space, w_self, w_args, func):
func_target = rffi.cast(setattrofunc, func)
check_num_args(space, w_args, 1)
w_name, = space.fixedview(w_args)
# XXX "Carlo Verre hack"?
res = generic_cpy_call(space, func_target, w_self, w_name, None)
if rffi.cast(lltype.Signed, res) == -1:
space.fromcache(State).check_and_raise_exception(always=True)
开发者ID:mozillazg,项目名称:pypy,代码行数:8,代码来源:slotdefs.py
示例14: wrap_sq_setitem
def wrap_sq_setitem(space, w_self, w_args, func):
func_target = rffi.cast(ssizeobjargproc, func)
check_num_args(space, w_args, 2)
args_w = space.fixedview(w_args)
index = space.int_w(space.index(args_w[0]))
res = generic_cpy_call(space, func_target, w_self, index, args_w[1])
if rffi.cast(lltype.Signed, res) == -1:
space.fromcache(State).check_and_raise_exception(always=True)
开发者ID:mozillazg,项目名称:pypy,代码行数:8,代码来源:slotdefs.py
示例15: wrap_getwritebuffer
def wrap_getwritebuffer(space, w_self, w_args, func):
func_target = rffi.cast(readbufferproc, func)
with lltype.scoped_alloc(rffi.VOIDPP.TO, 1) as ptr:
index = rffi.cast(Py_ssize_t, 0)
size = generic_cpy_call(space, func_target, w_self, index, ptr)
if size < 0:
space.fromcache(State).check_and_raise_exception(always=True)
return space.newbuffer(CPyBuffer(ptr[0], size, w_self, readonly=False))
开发者ID:mozillazg,项目名称:pypy,代码行数:8,代码来源:slotdefs.py
示例16: wrap_delitem
def wrap_delitem(space, w_self, w_args, func):
func_target = rffi.cast(objobjargproc, func)
check_num_args(space, w_args, 1)
w_key, = space.fixedview(w_args)
res = generic_cpy_call(space, func_target, w_self, w_key, None)
if rffi.cast(lltype.Signed, res) == -1:
space.fromcache(State).check_and_raise_exception(always=True)
return space.w_None
开发者ID:mozillazg,项目名称:pypy,代码行数:8,代码来源:slotdefs.py
示例17: wrap_objobjproc
def wrap_objobjproc(space, w_self, w_args, func):
func_target = rffi.cast(objobjproc, func)
check_num_args(space, w_args, 1)
w_value, = space.fixedview(w_args)
res = generic_cpy_call(space, func_target, w_self, w_value)
res = rffi.cast(lltype.Signed, res)
if res == -1:
space.fromcache(State).check_and_raise_exception(always=True)
return space.wrap(bool(res))
开发者ID:mozillazg,项目名称:pypy,代码行数:9,代码来源:slotdefs.py
示例18: wrap_ternaryfunc
def wrap_ternaryfunc(space, w_self, w_args, func):
# The third argument is optional
func_ternary = rffi.cast(ternaryfunc, func)
check_num_argsv(space, w_args, 1, 2)
args_w = space.fixedview(w_args)
arg3 = space.w_None
if len(args_w) > 1:
arg3 = args_w[1]
return generic_cpy_call(space, func_ternary, w_self, args_w[0], arg3)
开发者ID:mozillazg,项目名称:pypy,代码行数:9,代码来源:slotdefs.py
示例19: wrap_getattr
def wrap_getattr(space, w_self, w_args, func):
func_target = rffi.cast(getattrfunc, func)
check_num_args(space, w_args, 1)
args_w = space.fixedview(w_args)
name_ptr = rffi.str2charp(space.str_w(args_w[0]))
try:
return generic_cpy_call(space, func_target, w_self, name_ptr)
finally:
rffi.free_charp(name_ptr)
开发者ID:mozillazg,项目名称:pypy,代码行数:9,代码来源:slotdefs.py
示例20: wrap_inquirypred
def wrap_inquirypred(space, w_self, w_args, func):
func_inquiry = rffi.cast(inquiry, func)
check_num_args(space, w_args, 0)
args_w = space.fixedview(w_args)
res = generic_cpy_call(space, func_inquiry, w_self)
res = rffi.cast(lltype.Signed, res)
if res == -1:
space.fromcache(State).check_and_raise_exception(always=True)
return space.wrap(bool(res))
开发者ID:mozillazg,项目名称:pypy,代码行数:9,代码来源:slotdefs.py
注:本文中的pypy.module.cpyext.api.generic_cpy_call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论