Commits

wlav committed b7f583a

code cleanup

Comments (0)

Files changed (14)

pypy/module/cppyy/__init__.py

     interpleveldefs = {
         '_load_dictionary'       : 'interp_cppyy.load_dictionary',
         '_resolve_name'          : 'interp_cppyy.resolve_name',
-        '_type_byname'           : 'interp_cppyy.type_byname',
+        '_scope_byname'          : 'interp_cppyy.scope_byname',
         '_template_byname'       : 'interp_cppyy.template_byname',
         '_set_class_generator'   : 'interp_cppyy.set_class_generator',
         '_register_class'        : 'interp_cppyy.register_class',

pypy/module/cppyy/capi/__init__.py

     [rffi.CCHARP], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-def c_resolve_name(cppitem_name):
-    return charp2str_free(_c_resolve_name(cppitem_name))
-c_get_scope = rffi.llexternal(
+def c_resolve_name(name):
+    return charp2str_free(_c_resolve_name(name))
+c_get_scope_opaque = rffi.llexternal(
     "cppyy_get_scope",
     [rffi.CCHARP], C_SCOPE,
     threadsafe=threadsafe,
     [rffi.CCHARP], C_TYPE,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_get_object_type = rffi.llexternal(
-    "cppyy_get_object_type",
+_c_actual_class = rffi.llexternal(
+    "cppyy_actual_class",
     [C_TYPE, C_OBJECT], C_TYPE,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_actual_class(cppclass, cppobj):
+    return _c_actual_class(cppclass.handle, cppobj)
 
 # memory management ----------------------------------------------------------
-c_allocate = rffi.llexternal(
+_c_allocate = rffi.llexternal(
     "cppyy_allocate",
     [C_TYPE], C_OBJECT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_deallocate = rffi.llexternal(
+def c_allocate(cppclass):
+    return _c_allocate(cppclass.handle)
+_c_deallocate = rffi.llexternal(
     "cppyy_deallocate",
     [C_TYPE, C_OBJECT], lltype.Void,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_destruct = rffi.llexternal(
+def c_deallocate(cppclass, cppobject):
+    _c_deallocate(cppclass.handle, cppobject)
+_c_destruct = rffi.llexternal(
     "cppyy_destruct",
     [C_TYPE, C_OBJECT], lltype.Void,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_destruct(cppclass, cppobject):
+    _c_destruct(cppclass.handle, cppobject)
 
 # method/function dispatching ------------------------------------------------
 c_call_v = rffi.llexternal(
     threadsafe=threadsafe,
     compilation_info=backend.eci)
 
-c_call_o = rffi.llexternal(
+_c_call_o = rffi.llexternal(
     "cppyy_call_o",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP, C_TYPE], rffi.LONG,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_call_o(method_index, cppobj, nargs, args, cppclass):
+    return _c_call_o(method_index, cppobj, nargs, args, cppclass.handle)
 
-c_get_methptr_getter = rffi.llexternal(
+_c_get_methptr_getter = rffi.llexternal(
     "cppyy_get_methptr_getter",
     [C_SCOPE, rffi.INT], C_METHPTRGETTER_PTR,
     threadsafe=threadsafe,
     compilation_info=backend.eci,
     elidable_function=True)
+def c_get_methptr_getter(cppscope, method_index):
+    return _c_get_methptr_getter(cppscope.handle, method_index)
 
 # handling of function argument buffer ---------------------------------------
 c_allocate_function_args = rffi.llexternal(
     [C_TYPE], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_num_bases = rffi.llexternal(
+_c_num_bases = rffi.llexternal(
     "cppyy_num_bases",
     [C_TYPE], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_num_bases(cppclass):
+    return _c_num_bases(cppclass.handle)
 _c_base_name = rffi.llexternal(
     "cppyy_base_name",
     [C_TYPE, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-def c_base_name(cpptype, base_index):
-    return charp2str_free(_c_base_name(cpptype, base_index))
+def c_base_name(cppclass, base_index):
+    return charp2str_free(_c_base_name(cppclass.handle, base_index))
 
 _c_is_subtype = rffi.llexternal(
     "cppyy_is_subtype",
     threadsafe=threadsafe,
     compilation_info=backend.eci,
     elidable_function=True)
-
 @jit.elidable_promote()
 def c_is_subtype(derived, base):
     if derived == base:
         return 1
-    return _c_is_subtype(derived, base)
+    return _c_is_subtype(derived.handle, base.handle)
 
 _c_base_offset = rffi.llexternal(
     "cppyy_base_offset",
     threadsafe=threadsafe,
     compilation_info=backend.eci,
     elidable_function=True)
-
 @jit.elidable_promote()
 def c_base_offset(derived, base, address):
     if derived == base:
         return 0
-    return _c_base_offset(derived, base, address)
+    return _c_base_offset(derived.handle, base.handle, address)
 
 # method/function reflection information -------------------------------------
-c_num_methods = rffi.llexternal(
+_c_num_methods = rffi.llexternal(
     "cppyy_num_methods",
     [C_SCOPE], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_num_methods(cppscope):
+    return _c_num_methods(cppscope.handle)
 _c_method_name = rffi.llexternal(
     "cppyy_method_name",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
 def c_method_name(cppscope, method_index):
-    return charp2str_free(_c_method_name(cppscope, method_index))
+    return charp2str_free(_c_method_name(cppscope.handle, method_index))
 _c_method_result_type = rffi.llexternal(
     "cppyy_method_result_type",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
 def c_method_result_type(cppscope, method_index):
-    return charp2str_free(_c_method_result_type(cppscope, method_index))
-c_method_num_args = rffi.llexternal(
+    return charp2str_free(_c_method_result_type(cppscope.handle, method_index))
+_c_method_num_args = rffi.llexternal(
     "cppyy_method_num_args",
     [C_SCOPE, rffi.INT], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_method_req_args = rffi.llexternal(
+def c_method_num_args(cppscope, method_index):
+    return _c_method_num_args(cppscope.handle, method_index)
+_c_method_req_args = rffi.llexternal(
     "cppyy_method_req_args",
     [C_SCOPE, rffi.INT], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_method_req_args(cppscope, method_index):
+    return _c_method_req_args(cppscope.handle, method_index)
 _c_method_arg_type = rffi.llexternal(
     "cppyy_method_arg_type",
     [C_SCOPE, rffi.INT, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
 def c_method_arg_type(cppscope, method_index, arg_index):
-    return charp2str_free(_c_method_arg_type(cppscope, method_index, arg_index))
+    return charp2str_free(_c_method_arg_type(cppscope.handle, method_index, arg_index))
 _c_method_arg_default = rffi.llexternal(
     "cppyy_method_arg_default",
     [C_SCOPE, rffi.INT, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
 def c_method_arg_default(cppscope, method_index, arg_index):
-    return charp2str_free(_c_method_arg_default(cppscope, method_index, arg_index))
+    return charp2str_free(_c_method_arg_default(cppscope.handle, method_index, arg_index))
 _c_method_signature = rffi.llexternal(
     "cppyy_method_signature",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
 def c_method_signature(cppscope, method_index):
-    return charp2str_free(_c_method_signature(cppscope, method_index))
+    return charp2str_free(_c_method_signature(cppscope.handle, method_index))
 
-c_method_index = rffi.llexternal(
+_c_method_index = rffi.llexternal(
     "cppyy_method_index",
     [C_SCOPE, rffi.CCHARP], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_method_index(cppscope, name):
+    return _c_method_index(cppscope.handle, name)
 
-c_get_method = rffi.llexternal(
+_c_get_method = rffi.llexternal(
     "cppyy_get_method",
     [C_SCOPE, rffi.INT], C_METHOD,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_get_method(cppscope, method_index):
+    return _c_get_method(cppscope.handle, method_index)
 
 # method properties ----------------------------------------------------------
-c_is_constructor = rffi.llexternal(
+_c_is_constructor = rffi.llexternal(
     "cppyy_is_constructor",
     [C_TYPE, rffi.INT], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_is_staticmethod = rffi.llexternal(
+def c_is_constructor(cppclass, method_index):
+    return _c_is_constructor(cppclass.handle, method_index)
+_c_is_staticmethod = rffi.llexternal(
     "cppyy_is_staticmethod",
     [C_TYPE, rffi.INT], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_is_staticmethod(cppclass, method_index):
+    return _c_is_staticmethod(cppclass.handle, method_index)
 
 # data member reflection information -----------------------------------------
-c_num_data_members = rffi.llexternal(
-    "cppyy_num_data_members",
+_c_num_datamembers = rffi.llexternal(
+    "cppyy_num_datamembers",
     [C_SCOPE], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-_c_data_member_name = rffi.llexternal(
-    "cppyy_data_member_name",
+def c_num_datamembers(cppscope):
+    return _c_num_datamembers(cppscope.handle)
+_c_datamember_name = rffi.llexternal(
+    "cppyy_datamember_name",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-def c_data_member_name(cppscope, data_member_index):
-    return charp2str_free(_c_data_member_name(cppscope, data_member_index))
-_c_data_member_type = rffi.llexternal(
-    "cppyy_data_member_type",
+def c_datamember_name(cppscope, datamember_index):
+    return charp2str_free(_c_datamember_name(cppscope.handle, datamember_index))
+_c_datamember_type = rffi.llexternal(
+    "cppyy_datamember_type",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-def c_data_member_type(cppscope, data_member_index):
-    return charp2str_free(_c_data_member_type(cppscope, data_member_index))
-c_data_member_offset = rffi.llexternal(
-    "cppyy_data_member_offset",
+def c_datamember_type(cppscope, datamember_index):
+    return charp2str_free(_c_datamember_type(cppscope.handle, datamember_index))
+_c_datamember_offset = rffi.llexternal(
+    "cppyy_datamember_offset",
     [C_SCOPE, rffi.INT], rffi.SIZE_T,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_datamember_offset(cppscope, datamember_index):
+    return _c_datamember_offset(cppscope.handle, datamember_index)
 
-c_data_member_index = rffi.llexternal(
-    "cppyy_data_member_index",
+_c_datamember_index = rffi.llexternal(
+    "cppyy_datamember_index",
     [C_SCOPE, rffi.CCHARP], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_datamember_index(cppscope, name):
+    return _c_datamember_index(cppscope.handle, name)
 
 # data member properties -----------------------------------------------------
-c_is_publicdata = rffi.llexternal(
+_c_is_publicdata = rffi.llexternal(
     "cppyy_is_publicdata",
     [C_SCOPE, rffi.INT], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
-c_is_staticdata = rffi.llexternal(
+def c_is_publicdata(cppscope, datamember_index):
+    return _c_is_publicdata(cppscope.handle, datamember_index)
+_c_is_staticdata = rffi.llexternal(
     "cppyy_is_staticdata",
     [C_SCOPE, rffi.INT], rffi.INT,
     threadsafe=threadsafe,
     compilation_info=backend.eci)
+def c_is_staticdata(cppscope, datamember_index):
+    return _c_is_staticdata(cppscope.handle, datamember_index)
 
 # misc helpers ---------------------------------------------------------------
 c_strtoll = rffi.llexternal(

pypy/module/cppyy/converter.py

         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
         raise FastCallNotPossible
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         self._is_abstract(space)
 
     def to_memory(self, space, w_obj, w_value, offset):
         else:
             self.size = array_size
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         if hasattr(space, "fake"):
             raise NotImplementedError
         # read access, so no copy needed
     def __init__(self, space, array_size):
         self.size = sys.maxint
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         # read access, so no copy needed
         address_value = self._get_raw_address(space, w_obj, offset)
         address = rffi.cast(rffi.ULONGP, address_value)
     def default_argument_libffi(self, space, argchain):
         argchain.arg(self.default)
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = self._get_raw_address(space, w_obj, offset)
         rffiptr = rffi.cast(self.rffiptype, address)
         return space.wrap(rffiptr[0])
     def convert_argument_libffi(self, space, w_obj, argchain):
         argchain.arg(self._unwrap_object(space, w_obj))
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = rffi.cast(rffi.CCHARP, self._get_raw_address(space, w_obj, offset))
         if address[0] == '\x01':
             return space.w_True
     def convert_argument_libffi(self, space, w_obj, argchain): 
         argchain.arg(self._unwrap_object(space, w_obj))
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = rffi.cast(rffi.CCHARP, self._get_raw_address(space, w_obj, offset))
         return space.wrap(address[0])
 
     def _unwrap_object(self, space, w_obj):
         return r_singlefloat(space.float_w(w_obj))
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = self._get_raw_address(space, w_obj, offset)
         rffiptr = rffi.cast(self.rffiptype, address)
         return space.wrap(float(rffiptr[0]))
         ba = rffi.cast(rffi.CCHARP, address)
         ba[capi.c_function_arg_typeoffset()] = 'o'
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = self._get_raw_address(space, w_obj, offset)
         charpptr = rffi.cast(rffi.CCHARPP, address)
         return space.wrap(rffi.charp2str(charpptr[0]))
 class InstancePtrConverter(TypeConverter):
     _immutable_ = True
 
-    def __init__(self, space, cpptype, name):
-        from pypy.module.cppyy.interp_cppyy import W_CPPType
-        assert isinstance(cpptype, W_CPPType)
-        self.cpptype = cpptype
-        self.name = name
+    def __init__(self, space, cppclass):
+        from pypy.module.cppyy.interp_cppyy import W_CPPClass
+        assert isinstance(cppclass, W_CPPClass)
+        self.cppclass = cppclass
 
     def _unwrap_object(self, space, w_obj):
         from pypy.module.cppyy.interp_cppyy import W_CPPInstance
         obj = space.interpclass_w(w_obj)
         if isinstance(obj, W_CPPInstance):
-            if capi.c_is_subtype(obj.cppclass.handle, self.cpptype.handle):
+            if capi.c_is_subtype(obj.cppclass, self.cppclass):
                 rawobject = obj.get_rawobject()
-                offset = capi.c_base_offset(
-                    obj.cppclass.handle, self.cpptype.handle, rawobject)
+                offset = capi.c_base_offset(obj.cppclass, self.cppclass, rawobject)
                 obj_address = capi.direct_ptradd(rawobject, offset)
                 return rffi.cast(capi.C_OBJECT, obj_address)
         raise OperationError(space.w_TypeError,
                              space.wrap("cannot pass %s as %s" %
-                             (space.type(w_obj).getname(space, "?"), self.cpptype.name)))
+                             (space.type(w_obj).getname(space, "?"), self.cppclass.name)))
 
     def convert_argument(self, space, w_obj, address):
         x = rffi.cast(rffi.VOIDPP, address)
     def convert_argument_libffi(self, space, w_obj, argchain):
         argchain.arg(self._unwrap_object(space, w_obj))
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = rffi.cast(capi.C_OBJECT, self._get_raw_address(space, w_obj, offset))
         from pypy.module.cppyy import interp_cppyy
-        return interp_cppyy.wrap_cppobject_nocast(space, w_type, self.cpptype, address, True, False)
+        return interp_cppyy.wrap_cppobject_nocast(
+            space, w_pycppclass, self.cppclass, address, isref=True, python_owns=False)
 
     def to_memory(self, space, w_obj, w_value, offset):
         address = rffi.cast(rffi.VOIDPP, self._get_raw_address(space, w_obj, offset))
 class InstanceConverter(InstancePtrConverter):
     _immutable_ = True
 
-    def from_memory(self, space, w_obj, w_type, offset):
+    def from_memory(self, space, w_obj, w_pycppclass, offset):
         address = rffi.cast(capi.C_OBJECT, self._get_raw_address(space, w_obj, offset))
         from pypy.module.cppyy import interp_cppyy
-        return interp_cppyy.wrap_cppobject_nocast(space, w_type, self.cpptype, address, False, False)
+        return interp_cppyy.wrap_cppobject_nocast(
+            space, w_pycppclass, self.cppclass, address, isref=False, python_owns=False)
 
     def to_memory(self, space, w_obj, w_value, offset):
         self._is_abstract(space)
 
     def __init__(self, space, extra):
         from pypy.module.cppyy import interp_cppyy
-        cpptype = interp_cppyy.type_byname(space, "std::string")
-        InstanceConverter.__init__(self, space, cpptype, "std::string")
+        cppclass = interp_cppyy.scope_byname(space, "std::string")
+        InstanceConverter.__init__(self, space, cppclass)
 
     def _unwrap_object(self, space, w_obj):
         try:
 
     def __init__(self, space, extra):
         from pypy.module.cppyy import interp_cppyy
-        cpptype = interp_cppyy.type_byname(space, "std::string")
-        InstancePtrConverter.__init__(self, space, cpptype, "std::string")
+        cppclass = interp_cppyy.scope_byname(space, "std::string")
+        InstancePtrConverter.__init__(self, space, cppclass)
 
 
 _converters = {}         # builtin and custom types
 
     #   5) generalized cases (covers basically all user classes)
     from pypy.module.cppyy import interp_cppyy
-    cpptype = interp_cppyy.type_byname(space, clean_name)
-    if cpptype:
+    cppclass = interp_cppyy.scope_byname(space, clean_name)
+    if cppclass:
         # type check for the benefit of the annotator
-        from pypy.module.cppyy.interp_cppyy import W_CPPType
-        cpptype = space.interp_w(W_CPPType, cpptype, can_be_None=False)
+        from pypy.module.cppyy.interp_cppyy import W_CPPClass
+        cppclass = space.interp_w(W_CPPClass, cppclass, can_be_None=False)
         if compound == "*" or compound == "&":
-            return InstancePtrConverter(space, cpptype, clean_name)
+            return InstancePtrConverter(space, cppclass)
         elif compound == "":
-            return InstanceConverter(space, cpptype, clean_name)
+            return InstanceConverter(space, cppclass)
     elif capi.c_is_enum(clean_name):
         return UnsignedIntConverter(space, default)
     

pypy/module/cppyy/executor.py

     _immutable_ = True
     libffitype = NULL
 
-    def __init__(self, space, cpptype):
+    def __init__(self, space, extra):
         pass
 
     def execute(self, space, cppmethod, cppthis, num_args, args):
     _immutable_ = True
     libffitype = libffi.types.pointer
 
-    def __init__(self, space, cpptype):
-        FunctionExecutor.__init__(self, space, cpptype)
-        self.cpptype = cpptype
+    def __init__(self, space, cppclass):
+        FunctionExecutor.__init__(self, space, cppclass)
+        self.cppclass = cppclass
 
     def execute(self, space, cppmethod, cppthis, num_args, args):
         from pypy.module.cppyy import interp_cppyy
         long_result = capi.c_call_l(cppmethod, cppthis, num_args, args)
         ptr_result = rffi.cast(capi.C_OBJECT, long_result)
-        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, False)
+        return interp_cppyy.wrap_cppobject(
+            space, space.w_None, self.cppclass, ptr_result, isref=False, python_owns=False)
 
     def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy import interp_cppyy
         ptr_result = rffi.cast(capi.C_OBJECT, libffifunc.call(argchain, rffi.VOIDP))
-        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, False)
+        return interp_cppyy.wrap_cppobject(
+            space, space.w_None, self.cppclass, ptr_result, isref=False, python_owns=False)
 
 class InstancePtrPtrExecutor(InstancePtrExecutor):
     _immutable_ = True
         voidp_result = capi.c_call_r(cppmethod, cppthis, num_args, args)
         ref_address = rffi.cast(rffi.VOIDPP, voidp_result)
         ptr_result = rffi.cast(capi.C_OBJECT, ref_address[0])
-        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, False)
+        return interp_cppyy.wrap_cppobject(
+            space, space.w_None, self.cppclass, ptr_result, isref=False, python_owns=False)
 
     def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
 
     def execute(self, space, cppmethod, cppthis, num_args, args):
         from pypy.module.cppyy import interp_cppyy
-        long_result = capi.c_call_o(cppmethod, cppthis, num_args, args, self.cpptype.handle)
+        long_result = capi.c_call_o(cppmethod, cppthis, num_args, args, self.cppclass)
         ptr_result = rffi.cast(capi.C_OBJECT, long_result)
-        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, True)
+        return interp_cppyy.wrap_cppobject(
+            space, space.w_None, self.cppclass, ptr_result, isref=False, python_owns=True)
 
     def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
 
     #   3) types/classes, either by ref/ptr or by value
     from pypy.module.cppyy import interp_cppyy
-    cpptype = interp_cppyy.type_byname(space, clean_name)
-    if cpptype:
+    cppclass = interp_cppyy.scope_byname(space, clean_name)
+    if cppclass:
         # type check for the benefit of the annotator
-        from pypy.module.cppyy.interp_cppyy import W_CPPType
-        cpptype = space.interp_w(W_CPPType, cpptype, can_be_None=False)
+        from pypy.module.cppyy.interp_cppyy import W_CPPClass
+        cppclass = space.interp_w(W_CPPClass, cppclass, can_be_None=False)
         if compound == "":
-            return InstanceExecutor(space, cpptype)
+            return InstanceExecutor(space, cppclass)
         elif compound == "*" or compound == "&":
-            return InstancePtrExecutor(space, cpptype)
+            return InstancePtrExecutor(space, cppclass)
         elif compound == "**" or compound == "*&":
-            return InstancePtrPtrExecutor(space, cpptype)
+            return InstancePtrPtrExecutor(space, cppclass)
     elif capi.c_is_enum(clean_name):
         return UnsignedIntExecutor(space, None)
 

pypy/module/cppyy/include/capi.h

     char* cppyy_resolve_name(const char* cppitem_name);
     cppyy_scope_t cppyy_get_scope(const char* scope_name);
     cppyy_type_t cppyy_get_template(const char* template_name);
-    cppyy_type_t cppyy_get_object_type(cppyy_type_t klass, cppyy_object_t obj);
+    cppyy_type_t cppyy_actual_class(cppyy_type_t klass, cppyy_object_t obj);
 
     /* memory management ------------------------------------------------------ */
     cppyy_object_t cppyy_allocate(cppyy_type_t type);
     int cppyy_is_staticmethod(cppyy_type_t type, int method_index);
 
     /* data member reflection information ------------------------------------  */
-    int cppyy_num_data_members(cppyy_scope_t scope);
-    char* cppyy_data_member_name(cppyy_scope_t scope, int data_member_index);
-    char* cppyy_data_member_type(cppyy_scope_t scope, int data_member_index);
-    size_t cppyy_data_member_offset(cppyy_scope_t scope, int data_member_index);
+    int cppyy_num_datamembers(cppyy_scope_t scope);
+    char* cppyy_datamember_name(cppyy_scope_t scope, int datamember_index);
+    char* cppyy_datamember_type(cppyy_scope_t scope, int datamember_index);
+    size_t cppyy_datamember_offset(cppyy_scope_t scope, int datamember_index);
 
-    int cppyy_data_member_index(cppyy_scope_t scope, const char* name);
+    int cppyy_datamember_index(cppyy_scope_t scope, const char* name);
 
     /* data member properties ------------------------------------------------  */
-    int cppyy_is_publicdata(cppyy_type_t type, int data_member_index);
-    int cppyy_is_staticdata(cppyy_type_t type, int data_member_index);
+    int cppyy_is_publicdata(cppyy_type_t type, int datamember_index);
+    int cppyy_is_staticdata(cppyy_type_t type, int datamember_index);
 
     /* misc helpers ----------------------------------------------------------- */
     void cppyy_free(void* ptr);

pypy/module/cppyy/interp_cppyy.py

 
 class State(object):
     def __init__(self, space):
-        self.r_cppscope_cache = {
-            "void" : W_CPPType(space, "void", capi.C_NULL_TYPE) }
-        self.r_cpptemplate_cache = {}
-        self.type_registry = {}
+        self.cppscope_cache = {
+            "void" : W_CPPClass(space, "void", capi.C_NULL_TYPE) }
+        self.cpptemplate_cache = {}
+        self.cppclass_registry = {}
         self.w_clgen_callback = None
 
 @unwrap_spec(name=str)
     return space.wrap(capi.c_resolve_name(name))
 
 @unwrap_spec(name=str)
-def type_byname(space, name):
+def scope_byname(space, name):
     true_name = capi.c_resolve_name(name)
 
     state = space.fromcache(State)
     try:
-        return state.r_cppscope_cache[true_name]
+        return state.cppscope_cache[true_name]
     except KeyError:
         pass
 
-    cppscope = capi.c_get_scope(true_name)
-    assert lltype.typeOf(cppscope) == capi.C_SCOPE
-    if cppscope:
-        final_name = capi.c_final_name(cppscope)
-        if capi.c_is_namespace(cppscope):
-            r_cppscope = W_CPPNamespace(space, final_name, cppscope)
-        elif capi.c_has_complex_hierarchy(cppscope):
-            r_cppscope = W_ComplexCPPType(space, final_name, cppscope)
+    opaque_handle = capi.c_get_scope_opaque(true_name)
+    assert lltype.typeOf(opaque_handle) == capi.C_SCOPE
+    if opaque_handle:
+        final_name = capi.c_final_name(opaque_handle)
+        if capi.c_is_namespace(opaque_handle):
+            cppscope = W_CPPNamespace(space, final_name, opaque_handle)
+        elif capi.c_has_complex_hierarchy(opaque_handle):
+            cppscope = W_ComplexCPPClass(space, final_name, opaque_handle)
         else:
-            r_cppscope = W_CPPType(space, final_name, cppscope)
-        state.r_cppscope_cache[name] = r_cppscope
+            cppscope = W_CPPClass(space, final_name, opaque_handle)
+        state.cppscope_cache[name] = cppscope
 
-        r_cppscope._find_methods()
-        r_cppscope._find_data_members()
-        return r_cppscope
+        cppscope._find_methods()
+        cppscope._find_datamembers()
+        return cppscope
 
     return None
 
 def template_byname(space, name):
     state = space.fromcache(State)
     try:
-        return state.r_cpptemplate_cache[name]
+        return state.cpptemplate_cache[name]
     except KeyError:
         pass
 
-    cpptemplate = capi.c_get_template(name)
-    assert lltype.typeOf(cpptemplate) == capi.C_TYPE
-    if cpptemplate:
-        r_cpptemplate = W_CPPTemplateType(space, name, cpptemplate)
-        state.r_cpptemplate_cache[name] = r_cpptemplate
-        return r_cpptemplate
+    opaque_handle = capi.c_get_template(name)
+    assert lltype.typeOf(opaque_handle) == capi.C_TYPE
+    if opaque_handle:
+        cpptemplate = W_CPPTemplateType(space, name, opaque_handle)
+        state.cpptemplate_cache[name] = cpptemplate
+        return cpptemplate
 
     return None
 
     state = space.fromcache(State)
     state.w_clgen_callback = w_callback
 
-@unwrap_spec(w_type=W_Root)
-def register_class(space, w_type):
-    w_cpptype = space.findattr(w_type, space.wrap("_cpp_proxy"))
-    cpptype = space.interp_w(W_CPPType, w_cpptype, can_be_None=False)
+@unwrap_spec(w_pycppclass=W_Root)
+def register_class(space, w_pycppclass):
+    w_cppclass = space.findattr(w_pycppclass, space.wrap("_cpp_proxy"))
+    cppclass = space.interp_w(W_CPPClass, w_cppclass, can_be_None=False)
     state = space.fromcache(State)
-    state.type_registry[cpptype.handle] = w_type
+    state.cppclass_registry[cppclass.handle] = w_pycppclass
 
 
 class W_CPPLibrary(Wrappable):
     """ A concrete function after overloading has been resolved """
     _immutable_ = True
     
-    def __init__(self, cpptype, method_index, result_type, arg_defs, args_required):
-        self.space = cpptype.space
-        self.cpptype = cpptype
-        self.method_index = method_index
-        self.cppmethod = capi.c_get_method(self.cpptype.handle, method_index)
+    def __init__(self, space, containing_scope, method_index, result_type, arg_defs, args_required):
+        self.space = space
+        self.scope = containing_scope
+        self.index = method_index
+        self.cppmethod = capi.c_get_method(self.scope, method_index)
         self.arg_defs = arg_defs
         self.args_required = args_required
-        self.executor = executor.get_executor(self.space, result_type)
+        self.result_type = result_type
 
         # Setup of the method dispatch's innards is done lazily, i.e. only when
-        # the method is actually used. TODO: executor should be lazy as well.
+        # the method is actually used.
         self.arg_converters = None
+        self.executor = None
         self._libffifunc = None
 
     @jit.unroll_safe
     def _setup(self, cppthis):
         self.arg_converters = [converter.get_converter(self.space, arg_type, arg_dflt)
                                    for arg_type, arg_dflt in self.arg_defs]
+        self.executor = executor.get_executor(self.space, self.result_type)
 
         # Each CPPMethod corresponds one-to-one to a C++ equivalent and cppthis
         # has been offset to the matching class. Hence, the libffi pointer is
         # uniquely defined and needs to be setup only once.
-        methgetter = capi.c_get_methptr_getter(self.cpptype.handle, self.method_index)
+        methgetter = capi.c_get_methptr_getter(self.scope, self.index)
         if methgetter and cppthis:      # methods only for now
             funcptr = methgetter(rffi.cast(capi.C_OBJECT, cppthis))
             argtypes_libffi = [conv.libffitype for conv in self.arg_converters
         capi.c_deallocate_function_args(args)
 
     def signature(self):
-        return capi.c_method_signature(self.cpptype.handle, self.method_index)
+        return capi.c_method_signature(self.scope, self.index)
 
     def __repr__(self):
-        return "CPPFunction(%s, %s, %r, %s)" % (
-            self.cpptype, self.method_index, self.executor, self.arg_defs)
+        return "CPPMethod: %s" % self.signature()
 
     def _freeze_(self):
         assert 0, "you should never have a pre-built instance of this!"
 class CPPFunction(CPPMethod):
     _immutable_ = True
 
+    def __repr__(self):
+        return "CPPFunction: %s" % self.signature()
+
 
 class CPPConstructor(CPPMethod):
     _immutable_ = True
 
     def call(self, cppthis, args_w):
-        newthis = capi.c_allocate(self.cpptype.handle)
+        newthis = capi.c_allocate(self.scope)
         assert lltype.typeOf(newthis) == capi.C_OBJECT
         try:
             CPPMethod.call(self, newthis, args_w)
         except:
-            capi.c_deallocate(self.cpptype.handle, newthis)
+            capi.c_deallocate(self.scope, newthis)
             raise
-        return wrap_new_cppobject_nocast(self.space, None, self.cpptype, newthis, False, True)
+        return wrap_new_cppobject_nocast(
+            self.space, self.space.w_None, self.scope, newthis, isref=False, python_owns=True)
+
+    def __repr__(self):
+        return "CPPConstructor: %s" % self.signature()
 
 
 class W_CPPOverload(Wrappable):
     _immutable_ = True
 
-    def __init__(self, space, scope_handle, func_name, functions):
+    def __init__(self, space, containing_scope, functions):
         self.space = space
-        assert lltype.typeOf(scope_handle) == capi.C_SCOPE
-        self.scope_handle = scope_handle
-        self.func_name = func_name
+        self.scope = containing_scope
         self.functions = debug.make_sure_not_resized(functions)
 
     def is_static(self):
         cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance, can_be_None=True)
         if cppinstance is not None:
             cppinstance._nullcheck()
-            assert isinstance(cppinstance.cppclass, W_CPPType)
-            cppthis = cppinstance.cppclass.get_cppthis(cppinstance, self.scope_handle)
+            cppthis = cppinstance.get_cppthis(self.scope)
         else:
             cppthis = capi.C_NULL_OBJECT
         assert lltype.typeOf(cppthis) == capi.C_OBJECT
                 errmsg += '    '+e.errorstr(self.space)
             except Exception, e:
                 errmsg += '\n  '+cppyyfunc.signature()+' =>\n'
-                errmsg += '    Exception:'+str(e)
+                errmsg += '    Exception: '+str(e)
 
         raise OperationError(self.space.w_TypeError, self.space.wrap(errmsg))
 
         return self.space.wrap(sig)
 
     def __repr__(self):
-        return "W_CPPOverload(%s, %s)" % (self.func_name, self.functions)
+        return "W_CPPOverload(%s)" % [f.signature() for f in self.functions]
 
 W_CPPOverload.typedef = TypeDef(
     'CPPOverload',
 class W_CPPDataMember(Wrappable):
     _immutable_ = True
 
-    def __init__(self, space, scope_handle, type_name, offset, is_static):
+    def __init__(self, space, containing_scope, type_name, offset, is_static):
         self.space = space
-        assert lltype.typeOf(scope_handle) == capi.C_SCOPE
-        self.scope_handle = scope_handle
+        self.scope = containing_scope
         self.converter = converter.get_converter(self.space, type_name, '')
         self.offset = offset
         self._is_static = is_static
     @jit.elidable_promote()
     def _get_offset(self, cppinstance):
         if cppinstance:
-            assert lltype.typeOf(cppinstance.cppclass.handle) == lltype.typeOf(self.scope_handle)
+            assert lltype.typeOf(cppinstance.cppclass.handle) == lltype.typeOf(self.scope.handle)
             offset = self.offset + capi.c_base_offset(
-                cppinstance.cppclass.handle, self.scope_handle, cppinstance.get_rawobject())
+                cppinstance.cppclass, self.scope, cppinstance.get_rawobject())
         else:
             offset = self.offset
         return offset
 
-    def get(self, w_cppinstance, w_type):
+    def get(self, w_cppinstance, w_pycppclass):
         cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance, can_be_None=True)
         offset = self._get_offset(cppinstance)
-        return self.converter.from_memory(self.space, w_cppinstance, w_type, offset)
+        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_CPPInstance, w_cppinstance, can_be_None=True)
 
 class W_CPPScope(Wrappable):
     _immutable_ = True
-    _immutable_fields_ = ["methods[*]", "data_members[*]"]
+    _immutable_fields_ = ["methods[*]", "datamembers[*]"]
 
     kind = "scope"
 
-    def __init__(self, space, name, handle):
+    def __init__(self, space, name, opaque_handle):
         self.space = space
         self.name = name
-        assert lltype.typeOf(handle) == capi.C_SCOPE
-        self.handle = handle
+        assert lltype.typeOf(opaque_handle) == capi.C_SCOPE
+        self.handle = opaque_handle
         self.methods = {}
         # Do not call "self._find_methods()" here, so that a distinction can
         #  be made between testing for existence (i.e. existence in the cache
         #  of classes) and actual use. Point being that a class can use itself,
         #  e.g. as a return type or an argument to one of its methods.
 
-        self.data_members = {}
+        self.datamembers = {}
         # Idem self.methods: a type could hold itself by pointer.
 
     def _find_methods(self):
-        num_methods = capi.c_num_methods(self.handle)
+        num_methods = capi.c_num_methods(self)
         args_temp = {}
         for i in range(num_methods):
-            method_name = capi.c_method_name(self.handle, i)
+            method_name = capi.c_method_name(self, i)
             pymethod_name = helper.map_operator_name(
-                    method_name, capi.c_method_num_args(self.handle, i),
-                    capi.c_method_result_type(self.handle, i))
+                    method_name, capi.c_method_num_args(self, i),
+                    capi.c_method_result_type(self, i))
             if not pymethod_name in self.methods:
                 cppfunction = self._make_cppfunction(i)
                 overload = args_temp.setdefault(pymethod_name, [])
                 overload.append(cppfunction)
         for name, functions in args_temp.iteritems():
-            overload = W_CPPOverload(self.space, self.handle, name, functions[:])
+            overload = W_CPPOverload(self.space, self, functions[:])
             self.methods[name] = overload
 
     def get_method_names(self):
             return self.methods[name]
         except KeyError:
             pass
-        return self.find_overload(name)
+        new_method = self.find_overload(name)
+        self.methods[name] = new_method
+        return new_method
 
-    def get_data_member_names(self):
-        return self.space.newlist([self.space.wrap(name) for name in self.data_members])
+    def get_datamember_names(self):
+        return self.space.newlist([self.space.wrap(name) for name in self.datamembers])
 
     @jit.elidable_promote('0')
-    def get_data_member(self, name):
+    def get_datamember(self, name):
         try:
-            return self.data_members[name]
+            return self.datamembers[name]
         except KeyError:
             pass
-        return self.find_data_member(name)
+        new_dm = self.find_datamember(name)
+        self.datamembers[name] = new_dm
+        return new_dm
 
     def missing_attribute_error(self, name):
         return OperationError(
             self.space.w_AttributeError,
             self.space.wrap("%s '%s' has no attribute %s" % (self.kind, self.name, name)))
 
+    def __eq__(self, other):
+        return self.handle == other.handle
+
 
 # For now, keep namespaces and classes separate as namespaces are extensible
 # with info from multiple dictionaries and do not need to bother with meta
 # may be in order at some point.
 class W_CPPNamespace(W_CPPScope):
     _immutable_ = True
-
     kind = "namespace"
 
     def _make_cppfunction(self, method_index):
-        result_type = capi.c_method_result_type(self.handle, method_index)
-        num_args = capi.c_method_num_args(self.handle, method_index)
-        args_required = capi.c_method_req_args(self.handle, method_index)
+        result_type = capi.c_method_result_type(self, method_index)
+        num_args = capi.c_method_num_args(self, method_index)
+        args_required = capi.c_method_req_args(self, method_index)
         arg_defs = []
         for i in range(num_args):
-            arg_type = capi.c_method_arg_type(self.handle, method_index, i)
-            arg_dflt = capi.c_method_arg_default(self.handle, method_index, i)
+            arg_type = capi.c_method_arg_type(self, method_index, i)
+            arg_dflt = capi.c_method_arg_default(self, method_index, i)
             arg_defs.append((arg_type, arg_dflt))
-        return CPPFunction(self, method_index, result_type, arg_defs, args_required)
+        return CPPFunction(self.space, self, method_index, result_type, arg_defs, args_required)
 
-    def _make_data_member(self, dm_name, dm_idx):
-        type_name = capi.c_data_member_type(self.handle, dm_idx)
-        offset = capi.c_data_member_offset(self.handle, dm_idx)
-        data_member = W_CPPDataMember(self.space, self.handle, type_name, offset, True)
-        self.data_members[dm_name] = data_member
-        return data_member
+    def _make_datamember(self, dm_name, dm_idx):
+        type_name = capi.c_datamember_type(self, dm_idx)
+        offset = capi.c_datamember_offset(self, dm_idx)
+        datamember = W_CPPDataMember(self.space, self, type_name, offset, True)
+        self.datamembers[dm_name] = datamember
+        return datamember
 
-    def _find_data_members(self):
-        num_data_members = capi.c_num_data_members(self.handle)
-        for i in range(num_data_members):
-            if not capi.c_is_publicdata(self.handle, i):
+    def _find_datamembers(self):
+        num_datamembers = capi.c_num_datamembers(self)
+        for i in range(num_datamembers):
+            if not capi.c_is_publicdata(self, i):
                 continue
-            data_member_name = capi.c_data_member_name(self.handle, i)
-            if not data_member_name in self.data_members:
-                self._make_data_member(data_member_name, i)
+            datamember_name = capi.c_datamember_name(self, i)
+            if not datamember_name in self.datamembers:
+                self._make_datamember(datamember_name, i)
 
     def find_overload(self, meth_name):
         # TODO: collect all overloads, not just the non-overloaded version
-        meth_idx = capi.c_method_index(self.handle, meth_name)
+        meth_idx = capi.c_method_index(self, meth_name)
         if meth_idx < 0:
             raise self.missing_attribute_error(meth_name)
         cppfunction = self._make_cppfunction(meth_idx)
-        overload = W_CPPOverload(self.space, self.handle, meth_name, [cppfunction])
-        self.methods[meth_name] = overload
+        overload = W_CPPOverload(self.space, self, [cppfunction])
         return overload
 
-    def find_data_member(self, dm_name):
-        dm_idx = capi.c_data_member_index(self.handle, dm_name)
+    def find_datamember(self, dm_name):
+        dm_idx = capi.c_datamember_index(self, dm_name)
         if dm_idx < 0:
             raise self.missing_attribute_error(dm_name)
-        data_member = self._make_data_member(dm_name, dm_idx)
-        return data_member
+        datamember = self._make_datamember(dm_name, dm_idx)
+        return datamember
 
     def update(self):
         self._find_methods()
-        self._find_data_members()
+        self._find_datamembers()
 
     def is_namespace(self):
         return self.space.w_True
     update = interp2app(W_CPPNamespace.update, unwrap_spec=['self']),
     get_method_names = interp2app(W_CPPNamespace.get_method_names, unwrap_spec=['self']),
     get_overload = interp2app(W_CPPNamespace.get_overload, unwrap_spec=['self', str]),
-    get_data_member_names = interp2app(W_CPPNamespace.get_data_member_names, unwrap_spec=['self']),
-    get_data_member = interp2app(W_CPPNamespace.get_data_member, unwrap_spec=['self', str]),
+    get_datamember_names = interp2app(W_CPPNamespace.get_datamember_names, unwrap_spec=['self']),
+    get_datamember = interp2app(W_CPPNamespace.get_datamember, unwrap_spec=['self', str]),
     is_namespace = interp2app(W_CPPNamespace.is_namespace, unwrap_spec=['self']),
 )
 W_CPPNamespace.typedef.acceptable_as_base_class = False
 
 
-class W_CPPType(W_CPPScope):
+class W_CPPClass(W_CPPScope):
     _immutable_ = True
-
     kind = "class"
 
     def _make_cppfunction(self, method_index):
-        result_type = capi.c_method_result_type(self.handle, method_index)
-        num_args = capi.c_method_num_args(self.handle, method_index)
-        args_required = capi.c_method_req_args(self.handle, method_index)
+        result_type = capi.c_method_result_type(self, method_index)
+        num_args = capi.c_method_num_args(self, method_index)
+        args_required = capi.c_method_req_args(self, method_index)
         arg_defs = []
         for i in range(num_args):
-            arg_type = capi.c_method_arg_type(self.handle, method_index, i)
-            arg_dflt = capi.c_method_arg_default(self.handle, method_index, i)
+            arg_type = capi.c_method_arg_type(self, method_index, i)
+            arg_dflt = capi.c_method_arg_default(self, method_index, i)
             arg_defs.append((arg_type, arg_dflt))
-        if capi.c_is_constructor(self.handle, method_index):
+        if capi.c_is_constructor(self, method_index):
             result_type = "constructor"
             cls = CPPConstructor
-        elif capi.c_is_staticmethod(self.handle, method_index):
+        elif capi.c_is_staticmethod(self, method_index):
             cls = CPPFunction
         else:
             cls = CPPMethod
-        return cls(self, method_index, result_type, arg_defs, args_required)
+        return cls(self.space, self, method_index, result_type, arg_defs, args_required)
 
-    def _find_data_members(self):
-        num_data_members = capi.c_num_data_members(self.handle)
-        for i in range(num_data_members):
-            if not capi.c_is_publicdata(self.handle, i):
+    def _find_datamembers(self):
+        num_datamembers = capi.c_num_datamembers(self)
+        for i in range(num_datamembers):
+            if not capi.c_is_publicdata(self, i):
                 continue
-            data_member_name = capi.c_data_member_name(self.handle, i)
-            type_name = capi.c_data_member_type(self.handle, i)
-            offset = capi.c_data_member_offset(self.handle, i)
-            is_static = bool(capi.c_is_staticdata(self.handle, i))
-            data_member = W_CPPDataMember(self.space, self.handle, type_name, offset, is_static)
-            self.data_members[data_member_name] = data_member
+            datamember_name = capi.c_datamember_name(self, i)
+            type_name = capi.c_datamember_type(self, i)
+            offset = capi.c_datamember_offset(self, i)
+            is_static = bool(capi.c_is_staticdata(self, i))
+            datamember = W_CPPDataMember(self.space, self, type_name, offset, is_static)
+            self.datamembers[datamember_name] = datamember
 
     def find_overload(self, name):
         raise self.missing_attribute_error(name)
 
-    def find_data_member(self, name):
+    def find_datamember(self, name):
         raise self.missing_attribute_error(name)
 
-    def get_cppthis(self, cppinstance, scope_handle):
-        assert self.handle == cppinstance.cppclass.handle
+    def get_cppthis(self, cppinstance, calling_scope):
+        assert self == cppinstance.cppclass
         return cppinstance.get_rawobject()
 
     def is_namespace(self):
 
     def get_base_names(self):
         bases = []
-        num_bases = capi.c_num_bases(self.handle)
+        num_bases = capi.c_num_bases(self)
         for i in range(num_bases):
-            base_name = capi.c_base_name(self.handle, i)
+            base_name = capi.c_base_name(self, i)
             bases.append(self.space.wrap(base_name))
         return self.space.newlist(bases)
 
-W_CPPType.typedef = TypeDef(
-    'CPPType',
-    type_name = interp_attrproperty('name', W_CPPType),
-    get_base_names = interp2app(W_CPPType.get_base_names, unwrap_spec=['self']),
-    get_method_names = interp2app(W_CPPType.get_method_names, unwrap_spec=['self']),
-    get_overload = interp2app(W_CPPType.get_overload, unwrap_spec=['self', str]),
-    get_data_member_names = interp2app(W_CPPType.get_data_member_names, unwrap_spec=['self']),
-    get_data_member = interp2app(W_CPPType.get_data_member, unwrap_spec=['self', str]),
-    is_namespace = interp2app(W_CPPType.is_namespace, unwrap_spec=['self']),
+W_CPPClass.typedef = TypeDef(
+    'CPPClass',
+    type_name = interp_attrproperty('name', W_CPPClass),
+    get_base_names = interp2app(W_CPPClass.get_base_names, unwrap_spec=['self']),
+    get_method_names = interp2app(W_CPPClass.get_method_names, unwrap_spec=['self']),
+    get_overload = interp2app(W_CPPClass.get_overload, unwrap_spec=['self', str]),
+    get_datamember_names = interp2app(W_CPPClass.get_datamember_names, unwrap_spec=['self']),
+    get_datamember = interp2app(W_CPPClass.get_datamember, unwrap_spec=['self', str]),
+    is_namespace = interp2app(W_CPPClass.is_namespace, unwrap_spec=['self']),
 )
-W_CPPType.typedef.acceptable_as_base_class = False
+W_CPPClass.typedef.acceptable_as_base_class = False
 
 
-class W_ComplexCPPType(W_CPPType):
+class W_ComplexCPPClass(W_CPPClass):
     _immutable_ = True
 
-    def get_cppthis(self, cppinstance, scope_handle):
-        assert self.handle == cppinstance.cppclass.handle
-        offset = capi.c_base_offset(self.handle, scope_handle, cppinstance.get_rawobject())
+    def get_cppthis(self, cppinstance, calling_scope):
+        assert self == cppinstance.cppclass
+        offset = capi.c_base_offset(self, calling_scope, cppinstance.get_rawobject())
         return capi.direct_ptradd(cppinstance.get_rawobject(), offset)
 
-W_ComplexCPPType.typedef = TypeDef(
-    'ComplexCPPType',
-    type_name = interp_attrproperty('name', W_CPPType),
-    get_base_names = interp2app(W_ComplexCPPType.get_base_names, unwrap_spec=['self']),
-    get_method_names = interp2app(W_ComplexCPPType.get_method_names, unwrap_spec=['self']),
-    get_overload = interp2app(W_ComplexCPPType.get_overload, unwrap_spec=['self', str]),
-    get_data_member_names = interp2app(W_ComplexCPPType.get_data_member_names, unwrap_spec=['self']),
-    get_data_member = interp2app(W_ComplexCPPType.get_data_member, unwrap_spec=['self', str]),
-    is_namespace = interp2app(W_ComplexCPPType.is_namespace, unwrap_spec=['self']),
+W_ComplexCPPClass.typedef = TypeDef(
+    'ComplexCPPClass',
+    type_name = interp_attrproperty('name', W_CPPClass),
+    get_base_names = interp2app(W_ComplexCPPClass.get_base_names, unwrap_spec=['self']),
+    get_method_names = interp2app(W_ComplexCPPClass.get_method_names, unwrap_spec=['self']),
+    get_overload = interp2app(W_ComplexCPPClass.get_overload, unwrap_spec=['self', str]),
+    get_datamember_names = interp2app(W_ComplexCPPClass.get_datamember_names, unwrap_spec=['self']),
+    get_datamember = interp2app(W_ComplexCPPClass.get_datamember, unwrap_spec=['self', str]),
+    is_namespace = interp2app(W_ComplexCPPClass.is_namespace, unwrap_spec=['self']),
 )
-W_ComplexCPPType.typedef.acceptable_as_base_class = False
+W_ComplexCPPClass.typedef.acceptable_as_base_class = False
 
 
 class W_CPPTemplateType(Wrappable):
     _immutable_ = True
 
-    def __init__(self, space, name, handle):
+    def __init__(self, space, name, opaque_handle):
         self.space = space
         self.name = name
-        assert lltype.typeOf(handle) == capi.C_TYPE
-        self.handle = handle
+        assert lltype.typeOf(opaque_handle) == capi.C_TYPE
+        self.handle = opaque_handle
 
     def __call__(self, args_w):
         # TODO: this is broken but unused (see pythonify.py)
         fullname = "".join([self.name, '<', self.space.str_w(args_w[0]), '>'])
-        return type_byname(self.space, fullname)
+        return scope_byname(self.space, fullname)
 
 W_CPPTemplateType.typedef = TypeDef(
     'CPPTemplateType',
 
     def __init__(self, space, cppclass, rawobject, isref, python_owns):
         self.space = space
-        assert isinstance(cppclass, W_CPPType)
         self.cppclass = cppclass
         assert lltype.typeOf(rawobject) == capi.C_OBJECT
         assert not isref or rawobject
             raise OperationError(self.space.w_ReferenceError,
                                  self.space.wrap("trying to access a NULL pointer"))
 
+    def get_cppthis(self, calling_scope):
+        return self.cppclass.get_cppthis(self, calling_scope)
+
     def get_rawobject(self):
         if not self.isref:
             return self._rawobject
         assert isinstance(self, W_CPPInstance)
         if self._rawobject and not self.isref:
             memory_regulator.unregister(self)
-            capi.c_destruct(self.cppclass.handle, self._rawobject)
+            capi.c_destruct(self.cppclass, self._rawobject)
             self._rawobject = capi.C_NULL_OBJECT
 
     def __del__(self):
 memory_regulator = MemoryRegulator()
 
 
-def get_wrapped_type(space, handle):
+def get_pythonized_cppclass(space, handle):
     state = space.fromcache(State)
     try:
-        w_type = state.type_registry[handle]
+        w_pycppclass = state.cppclass_registry[handle]
     except KeyError:
         final_name = capi.c_scoped_final_name(handle)
-        w_type = space.call_function(state.w_clgen_callback, space.wrap(final_name))
-    return w_type
+        w_pycppclass = space.call_function(state.w_clgen_callback, space.wrap(final_name))
+    return w_pycppclass
 
-def wrap_new_cppobject_nocast(space, w_type, cpptype, rawobject, isref, python_owns):
-    if w_type is None:
-        w_type = get_wrapped_type(space, cpptype.handle)
-    w_cppinstance = space.allocate_instance(W_CPPInstance, w_type)
+def wrap_new_cppobject_nocast(space, w_pycppclass, cppclass, rawobject, isref, python_owns):
+    if space.is_w(w_pycppclass, space.w_None):
+        w_pycppclass = get_pythonized_cppclass(space, cppclass.handle)
+    w_cppinstance = space.allocate_instance(W_CPPInstance, w_pycppclass)
     cppinstance = space.interp_w(W_CPPInstance, w_cppinstance, can_be_None=False)
-    W_CPPInstance.__init__(cppinstance, space, cpptype, rawobject, isref, python_owns)
+    W_CPPInstance.__init__(cppinstance, space, cppclass, rawobject, isref, python_owns)
     memory_regulator.register(cppinstance)
     return w_cppinstance
 
-def wrap_cppobject_nocast(space, w_type, cpptype, rawobject, isref, python_owns):
+def wrap_cppobject_nocast(space, w_pycppclass, cppclass, rawobject, isref, python_owns):
     obj = memory_regulator.retrieve(rawobject)
-    if obj and obj.cppclass == cpptype:
-         return obj
-    return wrap_new_cppobject_nocast(space, w_type, cpptype, rawobject, isref, python_owns)
+    if obj and obj.cppclass == cppclass:
+        return obj
+    return wrap_new_cppobject_nocast(space, w_pycppclass, cppclass, rawobject, isref, python_owns)
 
-def wrap_cppobject(space, w_type, cpptype, rawobject, isref, python_owns):
+def wrap_cppobject(space, w_pycppclass, cppclass, rawobject, isref, python_owns):
     if rawobject:
-        actual = capi.c_get_object_type(cpptype.handle, rawobject)
-        if actual != cpptype.handle:
-            offset = capi.c_base_offset(actual, cpptype.handle, rawobject)
+        actual = capi.c_actual_class(cppclass, rawobject)
+        if actual != cppclass.handle:
+            offset = capi._c_base_offset(actual, cppclass.handle, rawobject)
             rawobject = capi.direct_ptradd(rawobject, offset)
-            w_type = get_wrapped_type(space, actual)
-            w_cpptype = space.findattr(w_type, space.wrap("_cpp_proxy"))
-            cpptype = space.interp_w(W_CPPType, w_cpptype, can_be_None=False)
-    return wrap_cppobject_nocast(space, w_type, cpptype, rawobject, isref, python_owns)
+            w_pycppclass = get_pythonized_cppclass(space, actual)
+            w_cppclass = space.findattr(w_pycppclass, space.wrap("_cpp_proxy"))
+            cppclass = space.interp_w(W_CPPClass, w_cppclass, can_be_None=False)
+    return wrap_cppobject_nocast(space, w_pycppclass, cppclass, rawobject, isref, python_owns)
 
 @unwrap_spec(cppinstance=W_CPPInstance)
 def addressof(space, cppinstance):
      return space.wrap(address)
 
 @unwrap_spec(address=int, owns=bool)
-def bind_object(space, address, w_type, owns=False):
+def bind_object(space, address, w_pycppclass, owns=False):
     rawobject = rffi.cast(capi.C_OBJECT, address)
-    w_cpptype = space.findattr(w_type, space.wrap("_cpp_proxy"))
-    cpptype = space.interp_w(W_CPPType, w_cpptype, can_be_None=False)
-    return wrap_cppobject_nocast(space, w_type, cpptype, rawobject, False, owns)
+    w_cppclass = space.findattr(w_pycppclass, space.wrap("_cpp_proxy"))
+    cppclass = space.interp_w(W_CPPClass, w_cppclass, can_be_None=False)
+    return wrap_cppobject_nocast(space, w_pycppclass, cppclass, rawobject, False, owns)

pypy/module/cppyy/pythonify.py

 class CppyyScopeMeta(type):
     def __getattr__(self, name):
         try:
-            return get_cppitem(self, name)  # will cache on self
-        except TypeError:
+            return get_pycppitem(self, name)  # will cache on self
+        except TypeError, t:
             raise AttributeError("%s object has no attribute '%s'" % (self, name))
 
 class CppyyNamespaceMeta(CppyyScopeMeta):
 
 
 def clgen_callback(name):
-    return get_cppclass(name)
+    return get_pycppclass(name)
 cppyy._set_class_generator(clgen_callback)
 
-def make_static_function(cpptype, func_name, cppol):
+def make_static_function(func_name, cppol):
     def function(*args):
         return cppol.call(None, *args)
     function.__name__ = func_name
     return method
 
 
-def make_data_member(cppdm):
+def make_datamember(cppdm):
     rettype = cppdm.get_returntype()
     if not rettype:                              # return builtin type
         cppclass = None
     else:                                        # return instance
         try:
-            cppclass = get_cppclass(rettype)
+            cppclass = get_pycppclass(rettype)
         except AttributeError:
             import warnings
             warnings.warn("class %s unknown: no data member access" % rettype,
     else:
         d = dict()
         def cpp_proxy_loader(cls):
-            cpp_proxy = cppyy._type_byname(cls.__name__ != '::' and cls.__name__ or '')
+            cpp_proxy = cppyy._scope_byname(cls.__name__ != '::' and cls.__name__ or '')
             del cls.__class__._cpp_proxy
             cls._cpp_proxy = cpp_proxy
             return cpp_proxy
         # insert static methods into the "namespace" dictionary
         for func_name in cppns.get_method_names():
             cppol = cppns.get_overload(func_name)
-            pyfunc = make_static_function(cppns, func_name, cppol)
+            pyfunc = make_static_function(func_name, cppol)
             setattr(pycppns, func_name, pyfunc)
 
         # add all data members to the dictionary of the class to be created, and
         # static ones also to the meta class (needed for property setters)
-        for dm in cppns.get_data_member_names():
-            cppdm = cppns.get_data_member(dm)
-            pydm = make_data_member(cppdm)
+        for dm in cppns.get_datamember_names():
+            cppdm = cppns.get_datamember(dm)
+            pydm = make_datamember(cppdm)
             setattr(pycppns, dm, pydm)
             setattr(metans, dm, pydm)
 
                 break
     return tuple(bases)
 
-def make_new(class_name, cpptype):
+def make_new(class_name, cppclass):
     try:
-        constructor_overload = cpptype.get_overload(cpptype.type_name)
+        constructor_overload = cppclass.get_overload(cppclass.type_name)
     except AttributeError:
         msg = "cannot instantiate abstract class '%s'" % class_name
         def __new__(cls, *args):
             return constructor_overload.call(None, *args)
     return __new__
 
-def make_cppclass(scope, class_name, final_class_name, cpptype):
+def make_pycppclass(scope, class_name, final_class_name, cppclass):
 
     # get a list of base classes for class creation
-    bases = [get_cppclass(base) for base in cpptype.get_base_names()]
+    bases = [get_pycppclass(base) for base in cppclass.get_base_names()]
     if not bases:
         bases = [CPPObject,]
     else:
     metacpp = type(CppyyClass)(class_name+'_meta', _drop_cycles(metabases), {})
 
     # create the python-side C++ class representation
-    d = {"_cpp_proxy" : cpptype,
-         "__new__"    : make_new(class_name, cpptype),
+    d = {"_cpp_proxy" : cppclass,
+         "__new__"    : make_new(class_name, cppclass),
          }
-    pycpptype = metacpp(class_name, _drop_cycles(bases), d)
+    pycppclass = metacpp(class_name, _drop_cycles(bases), d)
  
     # cache result early so that the class methods can find the class itself
-    setattr(scope, final_class_name, pycpptype)
+    setattr(scope, final_class_name, pycppclass)
 
     # insert (static) methods into the class dictionary
-    for meth_name in cpptype.get_method_names():
-        cppol = cpptype.get_overload(meth_name)
+    for meth_name in cppclass.get_method_names():
+        cppol = cppclass.get_overload(meth_name)
         if cppol.is_static():
-            setattr(pycpptype, meth_name, make_static_function(cpptype, meth_name, cppol))
+            setattr(pycppclass, meth_name, make_static_function(meth_name, cppol))
         else:
-            setattr(pycpptype, meth_name, make_method(meth_name, cppol))
+            setattr(pycppclass, meth_name, make_method(meth_name, cppol))
 
     # add all data members to the dictionary of the class to be created, and
     # static ones also to the meta class (needed for property setters)
-    for dm_name in cpptype.get_data_member_names():
-        cppdm = cpptype.get_data_member(dm_name)
-        pydm = make_data_member(cppdm)
+    for dm_name in cppclass.get_datamember_names():
+        cppdm = cppclass.get_datamember(dm_name)
+        pydm = make_datamember(cppdm)
 
-        setattr(pycpptype, dm_name, pydm)
+        setattr(pycppclass, dm_name, pydm)
         if cppdm.is_static():
             setattr(metacpp, dm_name, pydm)
 
-    _pythonize(pycpptype)
-    cppyy._register_class(pycpptype)
-    return pycpptype
+    _pythonize(pycppclass)
+    cppyy._register_class(pycppclass)
+    return pycppclass
 
 def make_cpptemplatetype(scope, template_name):
     return CppyyTemplateType(scope, template_name)
 
 
-def get_cppitem(scope, name):
+def get_pycppitem(scope, name):
     # resolve typedefs/aliases
     full_name = (scope == gbl) and name or (scope.__name__+'::'+name)
     true_name = cppyy._resolve_name(full_name)
     if true_name != full_name:
-        return get_cppclass(true_name)
+        return get_pycppclass(true_name)
 
     pycppitem = None
 
     # classes
-    cppitem = cppyy._type_byname(true_name)
+    cppitem = cppyy._scope_byname(true_name)
     if cppitem:
         if cppitem.is_namespace():
             pycppitem = make_cppnamespace(scope, true_name, cppitem)
             setattr(scope, name, pycppitem)
         else:
-            pycppitem = make_cppclass(scope, true_name, name, cppitem)
+            pycppitem = make_pycppclass(scope, true_name, name, cppitem)
 
     # templates
     if not cppitem:
     if not cppitem:
         try:
             cppitem = scope._cpp_proxy.get_overload(name)
-            pycppitem = make_static_function(scope._cpp_proxy, name, cppitem)
+            pycppitem = make_static_function(name, cppitem)
             setattr(scope.__class__, name, pycppitem)
             pycppitem = getattr(scope, name)      # binds function as needed
         except AttributeError:
     # data
     if not cppitem:
         try:
-            cppitem = scope._cpp_proxy.get_data_member(name)
-            pycppitem = make_data_member(cppitem)
+            cppitem = scope._cpp_proxy.get_datamember(name)
+            pycppitem = make_datamember(cppitem)
             setattr(scope, name, pycppitem)
             if cppitem.is_static():
                 setattr(scope.__class__, name, pycppitem)
         scope += c
     yield scope
 
-def get_cppclass(name):
+def get_pycppclass(name):
     # break up the name, to walk the scopes and get the class recursively
     scope = gbl
     for part in scope_splitter(name):
         return dct
     
 
-# user interface objects (note the two-step of not calling type_byname here:
+# user interface objects (note the two-step of not calling scope_byname here:
 # creation of global functions may cause the creation of classes in the global
 # namespace, so gbl must exist at that point to cache them)
 gbl = make_cppnamespace(None, "::", None, False)   # global C++ namespace

pypy/module/cppyy/src/cintcwrapper.cxx

     return (cppyy_type_t)sz;
 }
 
-cppyy_type_t cppyy_get_object_type(cppyy_type_t klass, cppyy_object_t obj) {
+cppyy_type_t cppyy_actual_class(cppyy_type_t klass, cppyy_object_t obj) {
     TClassRef cr = type_from_handle(klass);
     TClass* clActual = cr->GetActualClass( (void*)obj );
     if (clActual && clActual != cr.GetClass()) {
 
 
 /* data member reflection information ------------------------------------- */
-int cppyy_num_data_members(cppyy_scope_t handle) {
+int cppyy_num_datamembers(cppyy_scope_t handle) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass() && cr->GetListOfDataMembers())
         return cr->GetListOfDataMembers()->GetSize();
     return 0;
 }
 
-char* cppyy_data_member_name(cppyy_scope_t handle, int data_member_index) {
+char* cppyy_datamember_name(cppyy_scope_t handle, int datamember_index) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass()) {
-        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(data_member_index);
+        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(datamember_index);
         return cppstring_to_cstring(m->GetName());
     }
-    TGlobal& gbl = g_globalvars[data_member_index];
+    TGlobal& gbl = g_globalvars[datamember_index];
     return cppstring_to_cstring(gbl.GetName());
 }
 
-char* cppyy_data_member_type(cppyy_scope_t handle, int data_member_index) {
+char* cppyy_datamember_type(cppyy_scope_t handle, int datamember_index) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass())  {
-        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(data_member_index);
+        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(datamember_index);
         std::string fullType = m->GetFullTypeName();
         if ((int)m->GetArrayDim() > 1 || (!m->IsBasic() && m->IsaPointer()))
             fullType.append("*");
         }
         return cppstring_to_cstring(fullType);
     }
-    TGlobal& gbl = g_globalvars[data_member_index];
+    TGlobal& gbl = g_globalvars[datamember_index];
     return cppstring_to_cstring(gbl.GetFullTypeName());
 }
 
-size_t cppyy_data_member_offset(cppyy_scope_t handle, int data_member_index) {
+size_t cppyy_datamember_offset(cppyy_scope_t handle, int datamember_index) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass()) {
-        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(data_member_index);
+        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(datamember_index);
         return (size_t)m->GetOffsetCint();
     }
-    TGlobal& gbl = g_globalvars[data_member_index];
+    TGlobal& gbl = g_globalvars[datamember_index];
     return (size_t)gbl.GetAddress();
 }
 
-int cppyy_data_member_index(cppyy_scope_t handle, const char* name) {
+int cppyy_datamember_index(cppyy_scope_t handle, const char* name) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass()) {
         // called from updates; add a hard reset as the code itself caches in
 
 
 /* data member properties ------------------------------------------------  */
-int cppyy_is_publicdata(cppyy_scope_t handle, int data_member_index) {
+int cppyy_is_publicdata(cppyy_scope_t handle, int datamember_index) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass()) {
-        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(data_member_index);
+        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(datamember_index);
         return m->Property() & G__BIT_ISPUBLIC;
     }
     return 1;  // global data is always public
 }
 
-int cppyy_is_staticdata(cppyy_scope_t handle, int data_member_index) {
+int cppyy_is_staticdata(cppyy_scope_t handle, int datamember_index) {
     TClassRef cr = type_from_handle(handle);
     if (cr.GetClass()) {
-        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(data_member_index);
+        TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At(datamember_index);
         return m->Property() & G__BIT_ISSTATIC;
     }
     return 1;  // global data is always static

pypy/module/cppyy/src/reflexcwrapper.cxx

    return (cppyy_type_t)tt.Id();
 }
 
-cppyy_type_t cppyy_get_object_type(cppyy_type_t klass, cppyy_object_t obj) {
+cppyy_type_t cppyy_actual_class(cppyy_type_t klass, cppyy_object_t obj) {
     Reflex::Type t = type_from_handle(klass);
     Reflex::Type tActual = t.DynamicType(Reflex::Object(t, (void*)obj));
     if (tActual && tActual != t) {
 
 
 /* data member reflection information ------------------------------------- */
-int cppyy_num_data_members(cppyy_scope_t handle) {
+int cppyy_num_datamembers(cppyy_scope_t handle) {
     Reflex::Scope s = scope_from_handle(handle);
     // fix enum representation by adding them to the containing scope as per C++
     // TODO: this (relatively harmlessly) dupes data members when updating in the
     return s.DataMemberSize();
 }
 
-char* cppyy_data_member_name(cppyy_scope_t handle, int data_member_index) {
+char* cppyy_datamember_name(cppyy_scope_t handle, int datamember_index) {
     Reflex::Scope s = scope_from_handle(handle);
-    Reflex::Member m = s.DataMemberAt(data_member_index);
+    Reflex::Member m = s.DataMemberAt(datamember_index);
     std::string name = m.Name();
     return cppstring_to_cstring(name);
 }
 
-char* cppyy_data_member_type(cppyy_scope_t handle, int data_member_index) {
+char* cppyy_datamember_type(cppyy_scope_t handle, int datamember_index) {
     Reflex::Scope s = scope_from_handle(handle);
-    Reflex::Member m = s.DataMemberAt(data_member_index);
+    Reflex::Member m = s.DataMemberAt(datamember_index);
     std::string name = m.TypeOf().Name(Reflex::FINAL|Reflex::SCOPED|Reflex::QUALIFIED);
     return cppstring_to_cstring(name);
 }
 
-size_t cppyy_data_member_offset(cppyy_scope_t handle, int data_member_index) {
+size_t cppyy_datamember_offset(cppyy_scope_t handle, int datamember_index) {
     Reflex::Scope s = scope_from_handle(handle);
-    Reflex::Member m = s.DataMemberAt(data_member_index);
+    Reflex::Member m = s.DataMemberAt(datamember_index);
     if (m.IsArtificial() && m.TypeOf().IsEnum())
         return (size_t)&m.InterpreterOffset();
     return m.Offset();
 }
 
-int cppyy_data_member_index(cppyy_scope_t handle, const char* name) {
+int cppyy_datamember_index(cppyy_scope_t handle, const char* name) {
     Reflex::Scope s = scope_from_handle(handle);
     // the following appears dumb, but the internal storage for Reflex is an
     // unsorted std::vector anyway, so there's no gain to be had in using the
     // Scope::DataMemberByName() function (which returns Member, not an index)
-    int num_dm = cppyy_num_data_members(handle);
+    int num_dm = cppyy_num_datamembers(handle);
     for (int idm = 0; idm < num_dm; ++idm) {
         Reflex::Member m = s.DataMemberAt(idm);
         if (m.Name() == name || m.Name(Reflex::FINAL) == name) {
 
 
 /* data member properties ------------------------------------------------  */
-int cppyy_is_publicdata(cppyy_scope_t handle, int data_member_index) {
+int cppyy_is_publicdata(cppyy_scope_t handle, int datamember_index) {
     Reflex::Scope s = scope_from_handle(handle);
-    Reflex::Member m = s.DataMemberAt(data_member_index);
+    Reflex::Member m = s.DataMemberAt(datamember_index);
     return m.IsPublic();
 }
 
-int cppyy_is_staticdata(cppyy_scope_t handle, int data_member_index) {
+int cppyy_is_staticdata(cppyy_scope_t handle, int datamember_index) {
     Reflex::Scope s = scope_from_handle(handle);
-    Reflex::Member m = s.DataMemberAt(data_member_index);
+    Reflex::Member m = s.DataMemberAt(datamember_index);
     return m.IsStatic();
 }
 

pypy/module/cppyy/test/bench1.py

         import cppyy
         self.lib = cppyy.load_reflection_info("./example01Dict.so")
 
-        self.cls  = cppyy._type_byname("example01")
+        self.cls  = cppyy._scope_byname("example01")
         self.inst = self.cls.get_overload(self.cls.type_name).call(None, 0)
 
     def __call__(self):

pypy/module/cppyy/test/test_advancedcpp.py

         assert isinstance(c, gbl.some_concrete_class)
         assert isinstance(c, gbl.some_abstract_class)
 
-    def test06_data_members(self):
+    def test06_datamembers(self):
         """Test data member access when using virtual inheritence"""
 
         import cppyy

pypy/module/cppyy/test/test_cppyy.py

         raise OSError("'make' failed (see stderr)")
 
 class TestCPPYYImplementation:
-    def test_class_query(self):
+    def test01_class_query(self):
         dct = interp_cppyy.load_dictionary(space, test_dct)
-        w_cppyyclass = interp_cppyy.type_byname(space, "example01")
-        w_cppyyclass2 = interp_cppyy.type_byname(space, "example01")
+        w_cppyyclass = interp_cppyy.scope_byname(space, "example01")
+        w_cppyyclass2 = interp_cppyy.scope_byname(space, "example01")
         assert space.is_w(w_cppyyclass, w_cppyyclass2)
         adddouble = w_cppyyclass.methods["staticAddToDouble"]
         func, = adddouble.functions
+        assert func.executor is None
+        func._setup(None)     # creates executor
         assert isinstance(func.executor, executor.DoubleExecutor)
         assert func.arg_defs == [("double", "")]
 
         cls.w_example01, cls.w_payload = cls.space.unpackiterable(cls.space.appexec([], """():
             import cppyy
             cppyy.load_reflection_info(%r)
-            return cppyy._type_byname('example01'), cppyy._type_byname('payload')""" % (test_dct, )))
+            return cppyy._scope_byname('example01'), cppyy._scope_byname('payload')""" % (test_dct, )))
 
     def test01_static_int(self):
         """Test passing of an int, returning of an int, and overloading on a

pypy/module/cppyy/test/test_fragile.py

 
         g = fragile.G()
 
-    def test08_unhandled_scoped_data_member(self):
+    def test08_unhandled_scoped_datamember(self):
         """Test that an unhandled scoped data member does not cause infinite recursion"""
 
         import cppyy
 
         j = fragile.J()
         assert fragile.J.method1.__doc__ == j.method1.__doc__
-        assert j.method1.__doc__ == "fragile::J::method1(int, double)"
+        assert j.method1.__doc__ == "int fragile::J::method1(int, double)"

pypy/module/cppyy/test/test_zjit.py

         drv = jit.JitDriver(greens=[], reds=["i", "inst", "addDataToInt"])
         def f():
             lib = interp_cppyy.load_dictionary(space, "./example01Dict.so")
-            cls  = interp_cppyy.type_byname(space, "example01")
+            cls  = interp_cppyy.scope_byname(space, "example01")
             inst = cls.get_overload("example01").call(None, [FakeInt(0)])
             addDataToInt = cls.get_overload("addDataToInt")
             assert isinstance(inst, interp_cppyy.W_CPPInstance)
         drv = jit.JitDriver(greens=[], reds=["i", "inst", "addDataToInt"])
         def f():
             lib = interp_cppyy.load_dictionary(space, "./example01Dict.so")
-            cls  = interp_cppyy.type_byname(space, "example01")
+            cls  = interp_cppyy.scope_byname(space, "example01")
             inst = cls.get_overload("example01").call(None, [FakeInt(0)])
             addDataToInt = cls.get_overload("overloadedAddDataToInt")
             assert isinstance(inst, interp_cppyy.W_CPPInstance)