Commits

Armin Rigo committed 076963a

Tweak the immutable hints.

Comments (0)

Files changed (10)

pypy/module/_cffi_backend/ccallback.py

 
 
 class W_CDataCallback(W_CDataApplevelOwning):
-    _immutable_ = True
+    #_immutable_fields_ = ...
     ll_error = lltype.nullptr(rffi.CCHARP.TO)
 
     def __init__(self, space, ctype, w_callable, w_error):

pypy/module/_cffi_backend/cdataobj.py

 
 class W_CData(Wrappable):
     _attrs_ = ['space', '_cdata', 'ctype']
-    _immutable_ = True
+    _immutable_fields_ = ['_cdata', 'ctype']
     _cdata = lltype.nullptr(rffi.CCHARP.TO)
 
     def __init__(self, space, cdata, ctype):
     """This is the abstract base class for classes that are of the app-level
     type '_cffi_backend.CDataOwn'.  These are weakrefable."""
     _attrs_ = ['_lifeline_']    # for weakrefs
-    _immutable_ = True
 
     def _repr_extra(self):
         from pypy.module._cffi_backend.ctypeptr import W_CTypePointer
     """This is the class used for the app-level type
     '_cffi_backend.CDataOwn' created by newp()."""
     _attrs_ = []
-    _immutable_ = True
 
     def __init__(self, space, size, ctype):
         cdata = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw', zero=True)
     """Subclass with an explicit length, for allocated instances of
     the C type 'foo[]'."""
     _attrs_ = ['length']
-    _immutable_ = True
+    _immutable_fields_ = ['length']
 
     def __init__(self, space, size, ctype, length):
         W_CDataNewOwning.__init__(self, space, size, ctype)
     It has a strong reference to a W_CDataNewOwning that really owns the
     struct, which is the object returned by the app-level expression 'p[0]'."""
     _attrs_ = ['structobj']
-    _immutable_ = True
+    _immutable_fields_ = ['structobj']
 
     def __init__(self, space, cdata, ctype, structobj):
         W_CDataApplevelOwning.__init__(self, space, cdata, ctype)
     small bits of memory (e.g. just an 'int').  Its point is to not be
     a subclass of W_CDataApplevelOwning."""
     _attrs_ = []
-    _immutable_ = True
 
     def __init__(self, space, size, ctype):
         cdata = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw', zero=True)

pypy/module/_cffi_backend/ctypearray.py

 
 
 class W_CTypeArray(W_CTypePtrOrArray):
-    _immutable_ = True
+    _attrs_            = ['length', 'ctptr']
+    _immutable_fields_ = ['length', 'ctptr']
 
     def __init__(self, space, ctptr, length, arraysize, extra):
         W_CTypePtrOrArray.__init__(self, space, arraysize, extra, 0,

pypy/module/_cffi_backend/ctypeenum.py

 
 
 class W_CTypeEnum(W_CTypePrimitiveSigned):
-    _immutable_ = True
+    _attrs_            = ['enumerators2values', 'enumvalues2erators']
+    _immutable_fields_ = ['enumerators2values', 'enumvalues2erators']
 
     def __init__(self, space, name, enumerators, enumvalues):
         from pypy.module._cffi_backend.newtype import alignment

pypy/module/_cffi_backend/ctypefunc.py

 
 
 class W_CTypeFunc(W_CTypePtrBase):
-    _immutable_ = True
+    _attrs_            = ['fargs', 'ellipsis', 'cif_descr']
+    _immutable_fields_ = ['fargs', 'ellipsis', 'cif_descr']
 
     def __init__(self, space, fargs, fresult, ellipsis):
         extra = self._compute_extra_text(fargs, fresult, ellipsis)

pypy/module/_cffi_backend/ctypeobj.py

 
 
 class W_CType(Wrappable):
-    _attrs_ = ['space', 'size?', 'name', 'name_position']
-    _immutable_fields_ = _attrs_
+    _attrs_   = ['space', 'size',  'name', 'name_position']
+    _immutable_fields_ = ['size?', 'name', 'name_position']
+    # note that 'size' is not strictly immutable, because it can change
+    # from -1 to the real value in the W_CTypeStruct subclass.
 
     cast_anything = False
     is_primitive_integer = False

pypy/module/_cffi_backend/ctypeprim.py

 
 
 class W_CTypePrimitive(W_CType):
-    _immutable_ = True
+    _attrs_            = ['align']
+    _immutable_fields_ = ['align']
 
     def __init__(self, space, size, name, name_position, align):
         W_CType.__init__(self, space, size, name, name_position)
 
 
 class W_CTypePrimitiveCharOrUniChar(W_CTypePrimitive):
-    _immutable_ = True
+    _attrs_ = []
     is_primitive_integer = True
 
 
 class W_CTypePrimitiveChar(W_CTypePrimitiveCharOrUniChar):
-    _immutable_ = True
+    _attrs_ = []
     cast_anything = True
 
     def int(self, cdata):
 
 
 class W_CTypePrimitiveUniChar(W_CTypePrimitiveCharOrUniChar):
-    _immutable_ = True
+    _attrs_ = []
 
     def int(self, cdata):
         unichardata = rffi.cast(rffi.CWCHARP, cdata)
 
 
 class W_CTypePrimitiveSigned(W_CTypePrimitive):
-    _immutable_ = True
+    _attrs_            = ['value_fits_long', 'vmin', 'vrangemax']
+    _immutable_fields_ = ['value_fits_long', 'vmin', 'vrangemax']
     is_primitive_integer = True
 
     def __init__(self, *args):
 
 
 class W_CTypePrimitiveUnsigned(W_CTypePrimitive):
-    _immutable_ = True
+    _attrs_            = ['value_fits_long', 'vrangemax']
+    _immutable_fields_ = ['value_fits_long', 'vrangemax']
     is_primitive_integer = True
 
     def __init__(self, *args):
 
 
 class W_CTypePrimitiveFloat(W_CTypePrimitive):
-    _immutable_ = True
+    _attrs_ = []
 
     def cast(self, w_ob):
         space = self.space

pypy/module/_cffi_backend/ctypeptr.py

 
 
 class W_CTypePtrOrArray(W_CType):
-    _immutable_ = True
+    _attrs_            = ['ctitem', 'can_cast_anything', 'is_struct_ptr']
+    _immutable_fields_ = ['ctitem', 'can_cast_anything', 'is_struct_ptr']
 
     def __init__(self, space, size, extra, extra_position, ctitem,
                  could_cast_anything=True):
 
 class W_CTypePtrBase(W_CTypePtrOrArray):
     # base class for both pointers and pointers-to-functions
-    _immutable_ = True
+    _attrs_ = []
 
     def convert_to_object(self, cdata):
         ptrdata = rffi.cast(rffi.CCHARPP, cdata)[0]
 
 
 class W_CTypePointer(W_CTypePtrBase):
-    _immutable_ = True
+    _attrs_ = []
 
     def __init__(self, space, ctitem):
         from pypy.module._cffi_backend import ctypearray

pypy/module/_cffi_backend/ctypestruct.py

 
 
 class W_CTypeStructOrUnion(W_CType):
-    _attrs_ = ['alignment?', 'fields_list?', 'fields_dict?',
-               'custom_field_pos?']
+    _immutable_fields_ = ['alignment?', 'fields_list?', 'fields_dict?',
+                          'custom_field_pos?']
     # fields added by complete_struct_or_union():
     alignment = -1
     fields_list = None

pypy/module/_cffi_backend/ctypevoid.py

 
 
 class W_CTypeVoid(W_CType):
-    _immutable_ = True
+    _attrs_ = []
     cast_anything = True
 
     def __init__(self, space):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.