[pypy-svn] r79226 - pypy/branch/reflex-support/pypy/module/cppyy
wlav at codespeak.net
wlav at codespeak.net
Thu Nov 18 03:10:32 CET 2010
Author: wlav
Date: Thu Nov 18 03:10:29 2010
New Revision: 79226
Modified:
pypy/branch/reflex-support/pypy/module/cppyy/converter.py
pypy/branch/reflex-support/pypy/module/cppyy/executor.py
pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
Log:
rpython and comment fixes
Modified: pypy/branch/reflex-support/pypy/module/cppyy/converter.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/converter.py (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/converter.py Thu Nov 18 03:10:29 2010
@@ -90,7 +90,7 @@
if len(value) != 1:
raise OperationError(space.w_TypeError,
- space.wrap("char expecter, got string of size %d" % len(value)))
+ space.wrap("char expected, got string of size %d" % len(value)))
return value[0] # turn it into a "char" to the annotator
def convert_argument(self, space, w_obj):
@@ -189,9 +189,9 @@
def from_memory(self, space, w_obj, offset):
# read access, so no copy needed
fieldptr = self._get_fieldptr(space, w_obj, offset)
- shortptr = rffi.cast(rffi.SHORTP, fieldptr)
+ ptrval = rffi.cast(rffi.UINT, fieldptr)
w_array = unpack_simple_shape(space, space.wrap('h'))
- return w_array.fromaddress(space, shortptr, self.size)
+ return w_array.fromaddress(space, ptrval, self.size)
def to_memory(self, space, w_obj, w_value, offset):
# copy only the pointer value
@@ -205,6 +205,7 @@
# copy the full array (uses byte copy for now)
fieldptr = self._get_fieldptr(space, w_obj, offset)
value = w_value.getslotvalue(2)
+ # TODO: get sizeof(short) from system
for i in range(min(self.size*2, value.getlength())):
fieldptr[i] = value.getitem(i)
@@ -219,9 +220,9 @@
def from_memory(self, space, w_obj, offset):
# read access, so no copy needed
fieldptr = self._get_fieldptr(space, w_obj, offset)
- longptr = rffi.cast(rffi.LONGP, fieldptr)
+ ptrval = rffi.cast(rffi.UINT, fieldptr)
w_array = unpack_simple_shape(space, space.wrap('l'))
- return w_array.fromaddress(space, longptr, self.size)
+ return w_array.fromaddress(space, ptrval, self.size)
def to_memory(self, space, w_obj, w_value, offset):
# copy only the pointer value
@@ -235,6 +236,7 @@
# copy the full array (uses byte copy for now)
fieldptr = self._get_fieldptr(space, w_obj, offset)
value = w_value.getslotvalue(2)
+ # TODO: get sizeof(long) from system
for i in range(min(self.size*4, value.getlength())):
fieldptr[i] = value.getitem(i)
Modified: pypy/branch/reflex-support/pypy/module/cppyy/executor.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/executor.py (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/executor.py Thu Nov 18 03:10:29 2010
@@ -63,7 +63,7 @@
from pypy.module.cppyy import interp_cppyy
long_result = capi.c_call_l(func.cpptype.handle, func.method_index, cppthis, num_args, args)
ptr_result = rffi.cast(rffi.VOIDP, long_result)
- return interp_cppyy.W_CPPInstance(self.cpptype, ptr_result)
+ return interp_cppyy.W_CPPInstance(space, self.cpptype, ptr_result)
def get_executor(space, name):
Modified: pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py Thu Nov 18 03:10:29 2010
@@ -144,6 +144,7 @@
return "CPPFunction(%s, %s, %r, %s)" % (
self.cpptype, self.method_index, self.executor, self.arg_types)
+
class CPPFunction(CPPMethod):
def call(self, cppthis, args_w):
if self.executor is None:
@@ -167,7 +168,7 @@
except Exception, e:
capi.c_deallocate(self.cpptype.handle, newthis)
raise
- return W_CPPInstance(self.cpptype, newthis)
+ return W_CPPInstance(self.space, self.cpptype, newthis)
class W_CPPOverload(Wrappable):
@@ -237,7 +238,7 @@
class W_CPPType(Wrappable):
- _immutable_fields_ = ["name","handle"]
+ _immutable_fields_ = ["name", "handle"]
def __init__(self, space, name, handle):
self.space = space
@@ -322,9 +323,8 @@
class W_CPPInstance(Wrappable):
- _immutable_ = True
- def __init__(self, cppclass, rawobject):
- self.space = cppclass.space
+ def __init__(self, space, cppclass, rawobject):
+ self.space = space
self.cppclass = cppclass
self.rawobject = rawobject
More information about the Pypy-commit
mailing list