[pypy-commit] pypy reflex-support: remove all _immutable_ references as they don't work the way I expected ...
wlav
noreply at buildbot.pypy.org
Mon Oct 29 21:50:26 CET 2012
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r58601:e0a926dca235
Date: 2012-10-29 13:49 -0700
http://bitbucket.org/pypy/pypy/changeset/e0a926dca235/
Log: remove all _immutable_ references as they don't work the way I
expected ...
diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -67,7 +67,6 @@
class TypeConverter(object):
- _immutable_ = True
libffitype = lltype.nullptr(jit_libffi.FFI_TYPE_P.TO)
uses_local = False
@@ -128,7 +127,6 @@
class ArrayTypeConverterMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.pointer
def __init__(self, space, array_size):
@@ -158,7 +156,6 @@
class PtrTypeConverterMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.pointer
def __init__(self, space, array_size):
@@ -200,7 +197,6 @@
class NumericTypeConverterMixin(object):
_mixin_ = True
- _immutable_ = True
def convert_argument_libffi(self, space, w_obj, address, call_local):
x = rffi.cast(self.c_ptrtype, address)
@@ -222,7 +218,6 @@
class ConstRefNumericTypeConverterMixin(NumericTypeConverterMixin):
_mixin_ = True
- _immutable_ = True
uses_local = True
def convert_argument_libffi(self, space, w_obj, address, call_local):
@@ -235,7 +230,6 @@
class IntTypeConverterMixin(NumericTypeConverterMixin):
_mixin_ = True
- _immutable_ = True
def convert_argument(self, space, w_obj, address, call_local):
x = rffi.cast(self.c_ptrtype, address)
@@ -243,7 +237,6 @@
class FloatTypeConverterMixin(NumericTypeConverterMixin):
_mixin_ = True
- _immutable_ = True
def convert_argument(self, space, w_obj, address, call_local):
x = rffi.cast(self.c_ptrtype, address)
@@ -253,7 +246,6 @@
class VoidConverter(TypeConverter):
- _immutable_ = True
libffitype = jit_libffi.types.void
def __init__(self, space, name):
@@ -265,8 +257,6 @@
class BoolConverter(ffitypes.typeid(bool), TypeConverter):
- _immutable_ = True
-
def convert_argument(self, space, w_obj, address, call_local):
x = rffi.cast(rffi.LONGP, address)
x[0] = self._unwrap_object(space, w_obj)
@@ -290,8 +280,6 @@
address[0] = '\x00'
class CharConverter(ffitypes.typeid(rffi.CHAR), TypeConverter):
- _immutable_ = True
-
def convert_argument(self, space, w_obj, address, call_local):
x = rffi.cast(rffi.CCHARP, address)
x[0] = self._unwrap_object(space, w_obj)
@@ -309,8 +297,6 @@
address[0] = self._unwrap_object(space, w_value)
class FloatConverter(ffitypes.typeid(rffi.FLOAT), FloatTypeConverterMixin, TypeConverter):
- _immutable_ = True
-
def __init__(self, space, default):
if default:
fval = float(rfloat.rstring_to_float(default))
@@ -324,7 +310,6 @@
return space.wrap(float(rffiptr[0]))
class ConstFloatRefConverter(FloatConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
typecode = 'F'
@@ -333,8 +318,6 @@
raise FastCallNotPossible
class DoubleConverter(ffitypes.typeid(rffi.DOUBLE), FloatTypeConverterMixin, TypeConverter):
- _immutable_ = True
-
def __init__(self, space, default):
if default:
self.default = rffi.cast(self.c_type, rfloat.rstring_to_float(default))
@@ -342,14 +325,11 @@
self.default = rffi.cast(self.c_type, 0.)
class ConstDoubleRefConverter(ConstRefNumericTypeConverterMixin, DoubleConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
typecode = 'D'
class CStringConverter(TypeConverter):
- _immutable_ = True
-
def convert_argument(self, space, w_obj, address, call_local):
x = rffi.cast(rffi.LONGP, address)
arg = space.str_w(w_obj)
@@ -367,7 +347,6 @@
class VoidPtrConverter(TypeConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
def _unwrap_object(self, space, w_obj):
@@ -388,7 +367,6 @@
x[0] = self._unwrap_object(space, w_obj)
class VoidPtrPtrConverter(TypeConverter):
- _immutable_ = True
uses_local = True
def convert_argument(self, space, w_obj, address, call_local):
@@ -410,11 +388,9 @@
pass # no set on buffer/array/None
class VoidPtrRefConverter(VoidPtrPtrConverter):
- _immutable_ = True
uses_local = True
class InstancePtrConverter(TypeConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
def __init__(self, space, cppclass):
@@ -457,8 +433,6 @@
address[0] = rffi.cast(rffi.VOIDP, self._unwrap_object(space, w_value))
class InstanceConverter(InstancePtrConverter):
- _immutable_ = True
-
def convert_argument_libffi(self, space, w_obj, address, call_local):
from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
raise FastCallNotPossible # TODO: by-value is a jit_libffi special case
@@ -473,7 +447,6 @@
self._is_abstract(space)
class InstancePtrPtrConverter(InstancePtrConverter):
- _immutable_ = True
uses_local = True
def convert_argument(self, space, w_obj, address, call_local):
@@ -505,8 +478,6 @@
class StdStringConverter(InstanceConverter):
- _immutable_ = True
-
def __init__(self, space, extra):
from pypy.module.cppyy import interp_cppyy
cppclass = interp_cppyy.scope_byname(space, "std::string")
@@ -537,8 +508,6 @@
capi.c_free_stdstring(rffi.cast(capi.C_OBJECT, rffi.cast(rffi.VOIDPP, arg)[0]))
class StdStringRefConverter(InstancePtrConverter):
- _immutable_ = True
-
def __init__(self, space, extra):
from pypy.module.cppyy import interp_cppyy
cppclass = interp_cppyy.scope_byname(space, "std::string")
@@ -546,7 +515,6 @@
class PyObjectConverter(TypeConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
def convert_argument(self, space, w_obj, address, call_local):
@@ -675,11 +643,9 @@
for c_type, names in type_info:
class BasicConverter(ffitypes.typeid(c_type), IntTypeConverterMixin, TypeConverter):
- _immutable_ = True
def __init__(self, space, default):
self.default = rffi.cast(self.c_type, capi.c_strtoll(default))
class ConstRefConverter(ConstRefNumericTypeConverterMixin, BasicConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
for name in names:
_converters[name] = BasicConverter
@@ -692,11 +658,9 @@
for c_type, names in type_info:
class BasicConverter(ffitypes.typeid(c_type), IntTypeConverterMixin, TypeConverter):
- _immutable_ = True
def __init__(self, space, default):
self.default = rffi.cast(self.c_type, capi.c_strtoll(default))
class ConstRefConverter(ConstRefNumericTypeConverterMixin, BasicConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
typecode = 'r'
def convert_argument(self, space, w_obj, address, call_local):
@@ -718,11 +682,9 @@
for c_type, names in type_info:
class BasicConverter(ffitypes.typeid(c_type), IntTypeConverterMixin, TypeConverter):
- _immutable_ = True
def __init__(self, space, default):
self.default = rffi.cast(self.c_type, capi.c_strtoull(default))
class ConstRefConverter(ConstRefNumericTypeConverterMixin, BasicConverter):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
for name in names:
_converters[name] = BasicConverter
@@ -746,11 +708,9 @@
for tcode, tsize, names in array_info:
class ArrayConverter(ArrayTypeConverterMixin, TypeConverter):
- _immutable_ = True
typecode = tcode
typesize = tsize
class PtrConverter(PtrTypeConverterMixin, TypeConverter):
- _immutable_ = True
typecode = tcode
typesize = tsize
for name in names:
diff --git a/pypy/module/cppyy/executor.py b/pypy/module/cppyy/executor.py
--- a/pypy/module/cppyy/executor.py
+++ b/pypy/module/cppyy/executor.py
@@ -27,7 +27,6 @@
NULL = lltype.nullptr(jit_libffi.FFI_TYPE_P.TO)
class FunctionExecutor(object):
- _immutable_ = True
libffitype = NULL
def __init__(self, space, extra):
@@ -43,7 +42,6 @@
class PtrTypeExecutor(FunctionExecutor):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
typecode = 'P'
@@ -65,7 +63,6 @@
class VoidExecutor(FunctionExecutor):
- _immutable_ = True
libffitype = jit_libffi.types.void
def execute(self, space, cppmethod, cppthis, num_args, args):
@@ -79,7 +76,6 @@
class NumericExecutorMixin(object):
_mixin_ = True
- _immutable_ = True
def _wrap_object(self, space, obj):
return space.wrap(obj)
@@ -96,7 +92,6 @@
class NumericRefExecutorMixin(object):
_mixin_ = True
- _immutable_ = True
def __init__(self, space, extra):
FunctionExecutor.__init__(self, space, extra)
@@ -128,7 +123,6 @@
class CStringExecutor(FunctionExecutor):
- _immutable_ = True
def execute(self, space, cppmethod, cppthis, num_args, args):
lresult = capi.c_call_l(cppmethod, cppthis, num_args, args)
@@ -138,7 +132,6 @@
class ConstructorExecutor(VoidExecutor):
- _immutable_ = True
def execute(self, space, cppmethod, cppthis, num_args, args):
capi.c_constructor(cppmethod, cppthis, num_args, args)
@@ -146,7 +139,6 @@
class InstancePtrExecutor(FunctionExecutor):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
def __init__(self, space, cppclass):
@@ -169,7 +161,6 @@
space, space.w_None, self.cppclass, ptr_result, isref=False, python_owns=False)
class InstancePtrPtrExecutor(InstancePtrExecutor):
- _immutable_ = True
def execute(self, space, cppmethod, cppthis, num_args, args):
from pypy.module.cppyy import interp_cppyy
@@ -184,7 +175,6 @@
raise FastCallNotPossible
class InstanceExecutor(InstancePtrExecutor):
- _immutable_ = True
def execute(self, space, cppmethod, cppthis, num_args, args):
from pypy.module.cppyy import interp_cppyy
@@ -199,7 +189,6 @@
class StdStringExecutor(InstancePtrExecutor):
- _immutable_ = True
def execute(self, space, cppmethod, cppthis, num_args, args):
charp_result = capi.c_call_s(cppmethod, cppthis, num_args, args)
@@ -211,7 +200,6 @@
class PyObjectExecutor(PtrTypeExecutor):
- _immutable_ = True
def wrap_result(self, space, lresult):
space.getbuiltinmodule("cpyext")
@@ -326,10 +314,8 @@
for c_type, stub, names in type_info:
class BasicExecutor(ffitypes.typeid(c_type), NumericExecutorMixin, FunctionExecutor):
- _immutable_ = True
c_stubcall = staticmethod(stub)
class BasicRefExecutor(ffitypes.typeid(c_type), NumericRefExecutorMixin, FunctionExecutor):
- _immutable_ = True
libffitype = jit_libffi.types.pointer
for name in names:
_executors[name] = BasicExecutor
@@ -355,7 +341,6 @@
for tcode, names in ptr_info:
class PtrExecutor(PtrTypeExecutor):
- _immutable_ = True
typecode = tcode
for name in names:
_executors[name+'*'] = PtrExecutor
diff --git a/pypy/module/cppyy/ffitypes.py b/pypy/module/cppyy/ffitypes.py
--- a/pypy/module/cppyy/ffitypes.py
+++ b/pypy/module/cppyy/ffitypes.py
@@ -12,7 +12,6 @@
class BoolTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.uchar
c_type = rffi.UCHAR
c_ptrtype = rffi.UCHARP
@@ -29,7 +28,6 @@
class CharTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.schar
c_type = rffi.CHAR
c_ptrtype = rffi.CCHARP # there's no such thing as rffi.CHARP
@@ -53,7 +51,6 @@
class ShortTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.sshort
c_type = rffi.SHORT
c_ptrtype = rffi.SHORTP
@@ -63,7 +60,6 @@
class UShortTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.ushort
c_type = rffi.USHORT
c_ptrtype = rffi.USHORTP
@@ -73,7 +69,6 @@
class IntTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.sint
c_type = rffi.INT
c_ptrtype = rffi.INTP
@@ -83,7 +78,6 @@
class UIntTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.uint
c_type = rffi.UINT
c_ptrtype = rffi.UINTP
@@ -93,7 +87,6 @@
class LongTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.slong
c_type = rffi.LONG
c_ptrtype = rffi.LONGP
@@ -103,7 +96,6 @@
class ULongTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.ulong
c_type = rffi.ULONG
c_ptrtype = rffi.ULONGP
@@ -113,7 +105,6 @@
class LongLongTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.sint64
c_type = rffi.LONGLONG
c_ptrtype = rffi.LONGLONGP
@@ -123,7 +114,6 @@
class ULongLongTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.uint64
c_type = rffi.ULONGLONG
c_ptrtype = rffi.ULONGLONGP
@@ -133,7 +123,6 @@
class FloatTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.float
c_type = rffi.FLOAT
c_ptrtype = rffi.FLOATP
@@ -147,7 +136,6 @@
class DoubleTypeMixin(object):
_mixin_ = True
- _immutable_ = True
libffitype = jit_libffi.types.double
c_type = rffi.DOUBLE
c_ptrtype = rffi.DOUBLEP
diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -117,7 +117,6 @@
function if available, makes the call, and returns the wrapped result. It
also takes care of offset casting and recycling of known objects through
the memory_regulator."""
- _immutable_ = True
def __init__(self, space, containing_scope, method_index, arg_defs, args_required):
self.space = space
@@ -145,7 +144,7 @@
@jit.unroll_safe
def call(self, cppthis, args_w):
- jit.promote(self)
+ #jit.promote(self)
assert lltype.typeOf(cppthis) == capi.C_OBJECT
# check number of given arguments against required (== total - defaults)
@@ -189,7 +188,7 @@
@jit.unroll_safe
def do_fast_call(self, cppthis, args_w, call_local):
- jit.promote(self)
+ #jit.promote(self)
if self.cif_descr is None:
raise FastCallNotPossible
cif_descr = self.cif_descr
@@ -313,7 +312,7 @@
@jit.unroll_safe
def prepare_arguments(self, args_w, call_local):
- jit.promote(self)
+ #jit.promote(self)
args = capi.c_allocate_function_args(len(args_w))
stride = capi.c_function_arg_sizeof()
for i in range(len(args_w)):
@@ -364,7 +363,6 @@
"""Global (namespaced) function dispatcher. For now, the base class has
all the needed functionality, by allowing the C++ this pointer to be null
in the call. An optimization is expected there, however."""
- _immutable_ = True
def __repr__(self):
return "CPPFunction: %s" % self.signature()
@@ -374,7 +372,6 @@
"""Method dispatcher that constructs new objects. In addition to the call,
it allocates memory for the newly constructed object and sets ownership
to Python."""
- _immutable_ = True
def call(self, cppthis, args_w):
newthis = capi.c_allocate(self.scope)
@@ -395,7 +392,6 @@
"""Method dispatcher specific to Python's __setitem__ mapped onto C++'s
operator[](int). The former function takes an extra argument to assign to
the return type of the latter."""
- _immutable_ = True
def call(self, cppthis, args_w):
end = len(args_w)-1
@@ -412,8 +408,7 @@
"""Dispatcher that is actually available at the app-level: it is a
collection of (possibly) overloaded methods or functions. It calls these
in order and deals with error handling and reporting."""
- _immutable_ = True
- _immutable_fields_ = ["functions[*]"]
+ #_immutable_fields_ = ["functions[*]"]
def __init__(self, space, containing_scope, functions):
self.space = space
@@ -421,10 +416,9 @@
from pypy.rlib import debug
self.functions = debug.make_sure_not_resized(functions)
+ @jit.elidable_promote()
def is_static(self):
- f = self.functions[0]
- assert isinstance(f, CPPMethod)
- if isinstance(f, CPPFunction):
+ if isinstance(self.functions[0], CPPFunction):
return self.space.w_True
return self.space.w_False
@@ -449,7 +443,7 @@
#
# TODO: figure out what happens if a callback into from the C++ call
# raises a Python exception.
- jit.promote(self)
+ #jit.promote(self)
for i in range(len(self.functions)):
cppyyfunc = self.functions[i]
try:
@@ -492,7 +486,6 @@
class W_CPPDataMember(Wrappable):
- _immutable_ = True
def __init__(self, space, containing_scope, type_name, offset, is_static):
self.space = space
@@ -539,8 +532,7 @@
class W_CPPScope(Wrappable):
- _immutable_ = True
- _immutable_fields_ = ["methods[*]", "datamembers[*]"]
+ #_immutable_fields_ = ["methods[*]", "datamembers[*]"]
kind = "scope"
@@ -640,7 +632,6 @@
# classes for inheritance. Both are python classes, though, and refactoring
# may be in order at some point.
class W_CPPNamespace(W_CPPScope):
- _immutable_ = True
kind = "namespace"
def _make_cppfunction(self, pyname, index):
@@ -724,7 +715,6 @@
class W_CPPClass(W_CPPScope):
- _immutable_ = True
kind = "class"
def __init__(self, space, name, opaque_handle):
@@ -808,7 +798,6 @@
class W_ComplexCPPClass(W_CPPClass):
- _immutable_ = True
def get_cppthis(self, cppinstance, calling_scope):
assert self == cppinstance.cppclass
@@ -830,7 +819,6 @@
class W_CPPTemplateType(Wrappable):
- _immutable_ = True
def __init__(self, space, name, opaque_handle):
self.space = space
More information about the pypy-commit
mailing list