Author: Wim Lavrijsen <[email protected]>
Branch: cppyy-packaging
Changeset: r94400:0df7710aad8b
Date: 2017-10-30 13:14 -0700
http://bitbucket.org/pypy/pypy/changeset/0df7710aad8b/
Log: naming consistency w/ CPython/cppyy
diff --git a/pypy/module/_cppyy/__init__.py b/pypy/module/_cppyy/__init__.py
--- a/pypy/module/_cppyy/__init__.py
+++ b/pypy/module/_cppyy/__init__.py
@@ -13,7 +13,7 @@
'_set_function_generator': 'interp_cppyy.set_function_generator',
'_register_class' : 'interp_cppyy.register_class',
'_get_nullptr' : 'interp_cppyy.get_nullptr',
- 'CPPClassBase' : 'interp_cppyy.W_CPPClass',
+ 'CPPInstanceBase' : 'interp_cppyy.W_CPPInstance',
'addressof' : 'interp_cppyy.addressof',
'_bind_object' : 'interp_cppyy._bind_object',
'bind_object' : 'interp_cppyy.bind_object',
diff --git a/pypy/module/_cppyy/capi/loadable_capi.py
b/pypy/module/_cppyy/capi/loadable_capi.py
--- a/pypy/module/_cppyy/capi/loadable_capi.py
+++ b/pypy/module/_cppyy/capi/loadable_capi.py
@@ -607,7 +607,7 @@
"""Return a python string taking into account \0"""
from pypy.module._cppyy import interp_cppyy
- cppstr = space.interp_w(interp_cppyy.W_CPPClass, w_self, can_be_None=False)
+ cppstr = space.interp_w(interp_cppyy.W_CPPInstance, w_self,
can_be_None=False)
return space.newtext(c_stdstring2charp(space, cppstr._rawobject))
# setup pythonizations for later use at run-time
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
@@ -22,8 +22,8 @@
def get_rawobject(space, w_obj, can_be_None=True):
- from pypy.module._cppyy.interp_cppyy import W_CPPClass
- cppinstance = space.interp_w(W_CPPClass, w_obj, can_be_None=can_be_None)
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance
+ cppinstance = space.interp_w(W_CPPInstance, w_obj, can_be_None=can_be_None)
if cppinstance:
rawobject = cppinstance.get_rawobject()
assert lltype.typeOf(rawobject) == capi.C_OBJECT
@@ -31,15 +31,15 @@
return capi.C_NULL_OBJECT
def set_rawobject(space, w_obj, address):
- from pypy.module._cppyy.interp_cppyy import W_CPPClass
- cppinstance = space.interp_w(W_CPPClass, w_obj, can_be_None=True)
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance
+ cppinstance = space.interp_w(W_CPPInstance, w_obj, can_be_None=True)
if cppinstance:
assert lltype.typeOf(cppinstance._rawobject) == capi.C_OBJECT
cppinstance._rawobject = rffi.cast(capi.C_OBJECT, address)
def get_rawobject_nonnull(space, w_obj):
- from pypy.module._cppyy.interp_cppyy import W_CPPClass
- cppinstance = space.interp_w(W_CPPClass, w_obj, can_be_None=True)
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance
+ cppinstance = space.interp_w(W_CPPInstance, w_obj, can_be_None=True)
if cppinstance:
cppinstance._nullcheck()
rawobject = cppinstance.get_rawobject()
@@ -502,8 +502,8 @@
self.clsdecl = clsdecl
def _unwrap_object(self, space, w_obj):
- from pypy.module._cppyy.interp_cppyy import W_CPPClass
- if isinstance(w_obj, W_CPPClass):
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance
+ if isinstance(w_obj, W_CPPInstance):
from pypy.module._cppyy.interp_cppyy import
INSTANCE_FLAGS_IS_R_VALUE
if w_obj.flags & INSTANCE_FLAGS_IS_R_VALUE:
# reject moves as all are explicit
@@ -534,8 +534,8 @@
class InstanceMoveConverter(InstanceRefConverter):
def _unwrap_object(self, space, w_obj):
# moving is same as by-ref, but have to check that move is allowed
- from pypy.module._cppyy.interp_cppyy import W_CPPClass,
INSTANCE_FLAGS_IS_R_VALUE
- if isinstance(w_obj, W_CPPClass):
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance,
INSTANCE_FLAGS_IS_R_VALUE
+ if isinstance(w_obj, W_CPPInstance):
if w_obj.flags & INSTANCE_FLAGS_IS_R_VALUE:
w_obj.flags &= ~INSTANCE_FLAGS_IS_R_VALUE
return InstanceRefConverter._unwrap_object(self, space, w_obj)
@@ -598,8 +598,8 @@
raise FastCallNotPossible
def finalize_call(self, space, w_obj, call_local):
- from pypy.module._cppyy.interp_cppyy import W_CPPClass
- assert isinstance(w_obj, W_CPPClass)
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance
+ assert isinstance(w_obj, W_CPPInstance)
r = rffi.cast(rffi.VOIDPP, call_local)
w_obj._rawobject = rffi.cast(capi.C_OBJECT, r[0])
@@ -617,8 +617,8 @@
InstanceConverter.__init__(self, space, cppclass)
def _unwrap_object(self, space, w_obj):
- from pypy.module._cppyy.interp_cppyy import W_CPPClass
- if isinstance(w_obj, W_CPPClass):
+ from pypy.module._cppyy.interp_cppyy import W_CPPInstance
+ if isinstance(w_obj, W_CPPInstance):
arg = InstanceConverter._unwrap_object(self, space, w_obj)
return capi.c_stdstring2stdstring(space, arg)
else:
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
@@ -174,7 +174,7 @@
@staticmethod
def unpack_cppthis(space, w_cppinstance, declaring_scope):
- cppinstance = space.interp_w(W_CPPClass, w_cppinstance,
can_be_None=False)
+ cppinstance = space.interp_w(W_CPPInstance, w_cppinstance,
can_be_None=False)
cppinstance._nullcheck()
return cppinstance.get_cppthis(declaring_scope)
@@ -611,7 +611,7 @@
self.scope.name)
w_result = W_CPPOverload.call(self, w_cppinstance, args_w)
newthis = rffi.cast(capi.C_OBJECT, self.space.uint_w(w_result))
- cppinstance = self.space.interp_w(W_CPPClass, w_cppinstance,
can_be_None=True)
+ cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance,
can_be_None=True)
if cppinstance is not None:
cppinstance._rawobject = newthis
memory_regulator.register(cppinstance)
@@ -682,7 +682,7 @@
return offset
def get(self, w_cppinstance, w_pycppclass):
- cppinstance = self.space.interp_w(W_CPPClass, w_cppinstance,
can_be_None=True)
+ cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance,
can_be_None=True)
if not cppinstance:
raise oefmt(self.space.w_AttributeError,
"attribute access requires an instance")
@@ -690,7 +690,7 @@
return self.converter.from_memory(self.space, w_cppinstance,
w_pycppclass, offset)
def set(self, w_cppinstance, w_value):
- cppinstance = self.space.interp_w(W_CPPClass, w_cppinstance,
can_be_None=True)
+ cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance,
can_be_None=True)
if not cppinstance:
raise oefmt(self.space.w_AttributeError,
"attribute access requires an instance")
@@ -1029,7 +1029,7 @@
W_CPPComplexClassDecl.typedef.acceptable_as_base_class = False
-class W_CPPClass(W_Root):
+class W_CPPInstance(W_Root):
_attrs_ = ['space', 'clsdecl', '_rawobject', 'flags',
'finalizer_registered']
_immutable_fields_ = ['clsdecl']
@@ -1109,8 +1109,8 @@
# find a global overload in gbl, in __gnu_cxx (for iterators), or in
the
# scopes of the argument classes (TODO: implement that last option)
try:
- # TODO: expecting w_other to be an W_CPPClass is too limiting
- other = self.space.interp_w(W_CPPClass, w_other, can_be_None=False)
+ # TODO: expecting w_other to be an W_CPPInstance is too limiting
+ other = self.space.interp_w(W_CPPInstance, w_other,
can_be_None=False)
for name in ["", "__gnu_cxx", "__1"]:
nss = scope_byname(self.space, name)
meth_idx = capi.c_get_global_operator(
@@ -1132,7 +1132,7 @@
# fallback 2: direct pointer comparison (the class comparison is
needed since
# the first data member in a struct and the struct have the same
address)
- other = self.space.interp_w(W_CPPClass, w_other, can_be_None=False) #
TODO: factor out
+ other = self.space.interp_w(W_CPPInstance, w_other, can_be_None=False)
# TODO: factor out
iseq = (self._rawobject == other._rawobject) and (self.clsdecl ==
other.clsdecl)
return self.space.newbool(iseq)
@@ -1176,19 +1176,19 @@
if self.flags & INSTANCE_FLAGS_PYTHON_OWNS:
self.destruct()
-W_CPPClass.typedef = TypeDef(
- 'CPPClass',
- __python_owns__ = GetSetProperty(W_CPPClass.fget_python_owns,
W_CPPClass.fset_python_owns),
- __init__ = interp2app(W_CPPClass.instance__init__),
- __eq__ = interp2app(W_CPPClass.instance__eq__),
- __ne__ = interp2app(W_CPPClass.instance__ne__),
- __nonzero__ = interp2app(W_CPPClass.instance__nonzero__),
- __len__ = interp2app(W_CPPClass.instance__len__),
- __cmp__ = interp2app(W_CPPClass.instance__cmp__),
- __repr__ = interp2app(W_CPPClass.instance__repr__),
- __destruct__ = interp2app(W_CPPClass.destruct),
+W_CPPInstance.typedef = TypeDef(
+ 'CPPInstance',
+ __python_owns__ = GetSetProperty(W_CPPInstance.fget_python_owns,
W_CPPInstance.fset_python_owns),
+ __init__ = interp2app(W_CPPInstance.instance__init__),
+ __eq__ = interp2app(W_CPPInstance.instance__eq__),
+ __ne__ = interp2app(W_CPPInstance.instance__ne__),
+ __nonzero__ = interp2app(W_CPPInstance.instance__nonzero__),
+ __len__ = interp2app(W_CPPInstance.instance__len__),
+ __cmp__ = interp2app(W_CPPInstance.instance__cmp__),
+ __repr__ = interp2app(W_CPPInstance.instance__repr__),
+ __destruct__ = interp2app(W_CPPInstance.destruct),
)
-W_CPPClass.typedef.acceptable_as_base_class = True
+W_CPPInstance.typedef.acceptable_as_base_class = True
class MemoryRegulator:
@@ -1200,7 +1200,7 @@
# Note that for now, the associated test carries an m_padding to make
# a difference in the addresses.
def __init__(self):
- self.objects = rweakref.RWeakValueDictionary(int, W_CPPClass)
+ self.objects = rweakref.RWeakValueDictionary(int, W_CPPInstance)
def register(self, obj):
if not obj._rawobject:
@@ -1266,8 +1266,8 @@
return obj
# fresh creation
- w_cppinstance = space.allocate_instance(W_CPPClass, w_pycppclass)
- cppinstance = space.interp_w(W_CPPClass, w_cppinstance, can_be_None=False)
+ w_cppinstance = space.allocate_instance(W_CPPInstance, w_pycppclass)
+ cppinstance = space.interp_w(W_CPPInstance, w_cppinstance,
can_be_None=False)
cppinstance.__init__(space, clsdecl, rawobject, is_ref, python_owns)
memory_regulator.register(cppinstance)
return w_cppinstance
@@ -1311,7 +1311,7 @@
def move(space, w_obj):
"""Casts the given instance into an C++-style rvalue."""
- obj = space.interp_w(W_CPPClass, w_obj, can_be_None=True)
+ obj = space.interp_w(W_CPPInstance, w_obj, can_be_None=True)
if obj:
obj.flags |= INSTANCE_FLAGS_IS_R_VALUE
return w_obj
diff --git a/pypy/module/_cppyy/pythonify.py b/pypy/module/_cppyy/pythonify.py
--- a/pypy/module/_cppyy/pythonify.py
+++ b/pypy/module/_cppyy/pythonify.py
@@ -7,7 +7,7 @@
# Metaclasses are needed to store C++ static data members as properties. Since
# the interp-level does not support metaclasses, they are created at app-level.
# These are the metaclass base classes:
-class CPPMetaScope(type):
+class CPPScope(type):
def __getattr__(self, name):
try:
return get_scoped_pycppitem(self, name) # will cache on self
@@ -15,11 +15,11 @@
raise AttributeError("%s object has no attribute '%s' (details:
%s)" %
(self, name, str(e)))
-class CPPMetaNamespace(CPPMetaScope):
+class CPPMetaNamespace(CPPScope):
def __dir__(self):
return self.__cppdecl__.__dir__()
-class CPPMetaClass(CPPMetaScope):
+class CPPClass(CPPScope):
pass
# namespace base class (class base class defined in _init_pythonify)
@@ -173,7 +173,7 @@
# get a list of base classes for class creation
bases = [get_pycppclass(base) for base in decl.get_base_names()]
if not bases:
- bases = [CPPClass,]
+ bases = [CPPInstance,]
else:
# it's possible that the required class now has been built if one of
# the base classes uses it in e.g. a function interface
@@ -214,7 +214,7 @@
# create a metaclass to allow properties (for static data write access)
metabases = [type(base) for base in bases]
- metacpp = type(CPPMetaScope)(cl_name+'_meta', _drop_cycles(metabases),
d_meta)
+ metacpp = type(CPPScope)(cl_name+'_meta', _drop_cycles(metabases), d_meta)
# create the python-side C++ class
pycls = metacpp(cl_name, _drop_cycles(bases), d_class)
@@ -412,11 +412,11 @@
# at pypy-c startup, rather than on the "import _cppyy" statement
import _cppyy
- # root of all proxy classes: CPPClass in pythonify exists to combine the
- # CPPMetaScope metaclass with the interp-level CPPClassBase
- global CPPClass
- class CPPClass(_cppyy.CPPClassBase):
- __metaclass__ = CPPMetaScope
+ # root of all proxy classes: CPPInstance in pythonify exists to combine
+ # the CPPScope metaclass with the interp-level CPPInstanceBase
+ global CPPInstance
+ class CPPInstance(_cppyy.CPPInstanceBase):
+ __metaclass__ = CPPScope
pass
# class generator callback
diff --git a/pypy/module/_cppyy/test/test_zjit.py
b/pypy/module/_cppyy/test/test_zjit.py
--- a/pypy/module/_cppyy/test/test_zjit.py
+++ b/pypy/module/_cppyy/test/test_zjit.py
@@ -282,7 +282,7 @@
inst = interp_cppyy._bind_object(space, FakeInt(0), cls, True)
cls.get_overload("__init__").call(inst, [FakeInt(0)])
cppmethod = cls.get_overload(method_name)
- assert isinstance(inst, interp_cppyy.W_CPPClass)
+ assert isinstance(inst, interp_cppyy.W_CPPInstance)
i = 10
while i > 0:
drv.jit_merge_point(inst=inst, cppmethod=cppmethod, i=i)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit