[pypy-svn] r48841 - pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport
rxe at codespeak.net
rxe at codespeak.net
Tue Nov 20 15:27:00 CET 2007
Author: rxe
Date: Tue Nov 20 15:27:00 2007
New Revision: 48841
Modified:
pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py
Log:
(cfbolz, rxe) add gc offset to mod wrapper
Modified: pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py
==============================================================================
--- pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py (original)
+++ pypy/branch/new-genc-tests-wrapper/pypy/translator/llsupport/modwrapper.py Tue Nov 20 15:27:00 2007
@@ -53,7 +53,8 @@
_fields_ = [("size", ctypes.c_int),
("data", ctypes.c_byte * len(arg))]
class STR(ctypes.Structure):
- _fields_ = [("hash", ctypes.c_int),
+ _fields_ = [("padding", ctypes.c_byte * GC_OFFSET),
+ ("hash", ctypes.c_int),
("chars", Chars)]
s = STR()
s.hash = 0
@@ -77,7 +78,8 @@
("data", ctypes.c_char * 1)]
class STR(ctypes.Structure):
- _fields_ = [("hash", ctypes.c_int),
+ _fields_ = [("padding", ctypes.c_byte * GC_OFFSET),
+ ("hash", ctypes.c_int),
("array", Chars)]
if res:
@@ -89,7 +91,8 @@
def struct_to_tuple(res, C_TYPE_actions):
if res:
class S(ctypes.Structure):
- _fields_ = [("item%%s" %% ii, C_TYPE) for ii, (C_TYPE, _) in enumerate(C_TYPE_actions)]
+ _fields_ = ([("padding", ctypes.c_byte * GC_OFFSET)] +
+ [("item%%s" %% ii, C_TYPE) for ii, (C_TYPE, _) in enumerate(C_TYPE_actions)])
s = ctypes.cast(res, ctypes.POINTER(S)).contents
items = [action(getattr(s, 'item%%s' %% ii)) for ii, (_, action) in enumerate(C_TYPE_actions)]
return {'type':'tuple', 'value':tuple(items)}
@@ -99,7 +102,8 @@
def list_to_array(res, action):
if res:
class List(ctypes.Structure):
- _fields_ = [("length", ctypes.c_int),
+ _fields_ = [("padding", ctypes.c_byte * GC_OFFSET),
+ ("length", ctypes.c_int),
("items", ctypes.c_void_p)]
list = ctypes.cast(res, ctypes.POINTER(List)).contents
size = list.length
@@ -112,7 +116,8 @@
if size == -1:
size = ctypes.cast(res, ctypes.POINTER(ctypes.c_int)).contents.value
class Array(ctypes.Structure):
- _fields_ = [("size", ctypes.c_int),
+ _fields_ = [("padding", ctypes.c_byte * GC_OFFSET),
+ ("size", ctypes.c_int),
("data", C_TYPE * size)]
array = ctypes.cast(res, ctypes.POINTER(Array)).contents
return [action(array.data[ii]) for ii in range(size)]
@@ -120,7 +125,8 @@
return None
def to_exception_type(addr):
- addr_str = ctypes.cast(addr+12, ctypes.POINTER(ctypes.c_int)).contents.value
+ # XXX we should define the structure
+ addr_str = ctypes.cast(addr+GC_OFFSET+12, ctypes.POINTER(ctypes.c_int)).contents.value
size = ctypes.cast(addr_str, ctypes.POINTER(ctypes.c_int)).contents.value - 1
name = ctypes.string_at(addr_str+4, size)
return name
@@ -150,7 +156,7 @@
lltype.UniChar: "ctypes.c_uint",
}
- def __init__(self, entryname, filename, graph, dllname):
+ def __init__(self, entryname, filename, graph, dllname, gcoffset=0):
self.entryname = entryname
self.dllname = dllname
basename = self.entryname + '_wrapper.py'
@@ -160,6 +166,7 @@
def create(self):
self.file = open(str(self.modfilename), 'w')
+ self.file.write("GC_OFFSET = 0")
self.file.write(self.prolog % self.dllname)
g = self.graph
More information about the Pypy-commit
mailing list