Author: Armin Rigo <ar...@tunes.org> Branch: ffi-backend Changeset: r55819:cdc09d58bf7a Date: 2012-06-25 17:26 +0200 http://bitbucket.org/pypy/pypy/changeset/cdc09d58bf7a/
Log: Void type. diff --git a/pypy/module/_ffi_backend/__init__.py b/pypy/module/_ffi_backend/__init__.py --- a/pypy/module/_ffi_backend/__init__.py +++ b/pypy/module/_ffi_backend/__init__.py @@ -15,6 +15,7 @@ 'new_struct_type': 'newtype.new_struct_type', 'new_union_type': 'newtype.new_union_type', 'complete_struct_or_union': 'newtype.complete_struct_or_union', + 'new_void_type': 'newtype.new_void_type', 'newp': 'func.newp', 'cast': 'func.cast', diff --git a/pypy/module/_ffi_backend/ctypeobj.py b/pypy/module/_ffi_backend/ctypeobj.py --- a/pypy/module/_ffi_backend/ctypeobj.py +++ b/pypy/module/_ffi_backend/ctypeobj.py @@ -93,7 +93,10 @@ return align def _alignof(self): - xxx + space = self.space + raise operationerrfmt(space.w_TypeError, + "ctype '%s' is of unknown alignment", + self.name) def offsetof(self, fieldname): space = self.space @@ -147,7 +150,9 @@ ctitem = self.ctitem datasize = ctitem.size if datasize < 0: - xxx + raise operationerrfmt(space.w_TypeError, + "cannot instantiate ctype '%s' of unknown size", + self.name) if isinstance(ctitem, W_CTypePrimitiveChar): datasize *= 2 # forcefully add a null character cdata = cdataobj.W_CDataOwn(space, datasize, self) @@ -164,12 +169,14 @@ self.name) def add(self, cdata, i): + space = self.space ctitem = self.ctitem if ctitem.size < 0: - xxx - "ctype '%s' points to items of unknown size" + raise operationerrfmt(space.w_TypeError, + "ctype '%s' points to items of unknown size", + self.name) p = rffi.ptradd(cdata, i * self.ctitem.size) - return cdataobj.W_CData(self.space, p, self) + return cdataobj.W_CData(space, p, self) def _alignof(self): from pypy.module._ffi_backend import newtype @@ -541,6 +548,12 @@ xxx +class W_CTypeVoid(W_CType): + + def __init__(self, space): + W_CType.__init__(self, space, -1, "void", len("void")) + + class W_CField(Wrappable): _immutable_ = True def __init__(self, ctype, offset, bitshift, bitsize): diff --git a/pypy/module/_ffi_backend/newtype.py b/pypy/module/_ffi_backend/newtype.py --- a/pypy/module/_ffi_backend/newtype.py +++ b/pypy/module/_ffi_backend/newtype.py @@ -179,3 +179,9 @@ ctype.alignment = totalalignment ctype.fields_list = fields_list ctype.fields_dict = fields_dict + +# ____________________________________________________________ + +def new_void_type(space): + ctype = ctypeobj.W_CTypeVoid(space) + return ctype _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit