Author: Wim Lavrijsen <wlavrij...@lbl.gov>
Branch: cppyy-packaging
Changeset: r94404:e98cf77f5b72
Date: 2018-04-20 16:00 -0700
http://bitbucket.org/pypy/pypy/changeset/e98cf77f5b72/

Log:    upgrade to backend 0.6.0

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
@@ -121,11 +121,11 @@
 
         # TODO: the following need to match up with the globally defined C_XYZ 
low-level
         # types (see capi/__init__.py), but by using strings here, that isn't 
guaranteed
-        c_opaque_ptr = state.c_ulong
+        c_opaque_ptr = state.c_ulong    # not ptrdiff_t (which is signed)
  
         c_scope       = c_opaque_ptr
         c_type        = c_scope
-        c_object      = c_opaque_ptr
+        c_object      = c_opaque_ptr    # not voidp (to stick with one handle 
type)
         c_method      = c_opaque_ptr
         c_index       = state.c_long
         c_index_array = state.c_voidp
@@ -150,16 +150,17 @@
 
         self.capi_call_ifaces = {
             # name to opaque C++ scope representation
-            'num_scopes'               : ([c_scope],                  c_int),
-            'scope_name'               : ([c_scope, c_int],           
c_ccharp),
-
             'resolve_name'             : ([c_ccharp],                 
c_ccharp),
+            'resolve_enum'             : ([c_ccharp],                 
c_ccharp),
             'get_scope'                : ([c_ccharp],                 c_scope),
             'actual_class'             : ([c_type, c_object],         c_type),
+            'size_of_klass'            : ([c_type],                   
c_size_t),
+            'size_of_type'             : ([c_ccharp],                 
c_size_t),
 
             # memory management
             'allocate'                 : ([c_type],                   
c_object),
             'deallocate'               : ([c_type, c_object],         c_void),
+            'construct'                : ([c_type],                   
c_object),
             'destruct'                 : ([c_type, c_object],         c_void),
 
             # method/function dispatching
@@ -182,7 +183,8 @@
             'constructor'  : ([c_method, c_object, c_int, c_voidp],   
c_object),
             'call_o'       : ([c_method, c_object, c_int, c_voidp, c_type],    
 c_object),
 
-            'get_function_address'     : ([c_scope, c_index],         
c_voidp), # TODO: verify
+            'function_address_from_index'  : ([c_scope, c_index],     
c_voidp), # TODO: verify
+            'function_address_from_method' : ([c_method],             
c_voidp), # id.
 
             # handling of function argument buffer
             'allocate_function_args'   : ([c_int],                    c_voidp),
@@ -196,6 +198,8 @@
             'is_abstract'              : ([c_type],                   c_int),
             'is_enum'                  : ([c_ccharp],                 c_int),
 
+            'get_all_cpp_names'        : ([c_scope, c_voidp],         
c_voidp), # const char**
+
             # type/class reflection information
             'final_name'               : ([c_type],                   
c_ccharp),
             'scoped_final_name'        : ([c_type],                   
c_ccharp),
@@ -208,10 +212,10 @@
 
             # method/function reflection information
             'num_methods'              : ([c_scope],                  c_int),
-            'method_index_at'          : ([c_scope, c_int],           c_index),
             'method_indices_from_name' : ([c_scope, c_ccharp],        
c_index_array),
 
             'method_name'              : ([c_scope, c_index],         
c_ccharp),
+            'method_mangled_name'      : ([c_scope, c_index],         
c_ccharp),
             'method_result_type'       : ([c_scope, c_index],         
c_ccharp),
             'method_num_args'          : ([c_scope, c_index],         c_int),
             'method_req_args'          : ([c_scope, c_index],         c_int),
@@ -219,7 +223,9 @@
             'method_arg_default'       : ([c_scope, c_index, c_int],  
c_ccharp),
             'method_signature'         : ([c_scope, c_index, c_int],  
c_ccharp),
             'method_prototype'         : ([c_scope, c_index, c_int],  
c_ccharp),
+            'is_const_method'          : ([c_method],                 c_int),
 
+            'exists_method_template'   : ([c_scope, c_ccharp],        c_int),
             'method_is_template'       : ([c_scope, c_index],         c_int),
             'method_num_template_args' : ([c_scope, c_index],         c_int),
             'method_template_arg_name' : ([c_scope, c_index, c_index],         
 c_ccharp),
@@ -228,7 +234,9 @@
             'get_global_operator'      : ([c_scope, c_scope, c_scope, 
c_ccharp],   c_index),
 
             # method properties
+            'is_public_method'         : ([c_type, c_index],          c_int),
             'is_constructor'           : ([c_type, c_index],          c_int),
+            'is_destructor'            : ([c_type, c_index],          c_int),
             'is_staticmethod'          : ([c_type, c_index],          c_int),
 
             # data member reflection information
@@ -236,12 +244,14 @@
             'datamember_name'          : ([c_scope, c_int],           
c_ccharp),
             'datamember_type'          : ([c_scope, c_int],           
c_ccharp),
             'datamember_offset'        : ([c_scope, c_int],           
c_ptrdiff_t),
-
             'datamember_index'         : ([c_scope, c_ccharp],        c_int),
 
             # data member properties
             'is_publicdata'            : ([c_scope, c_int],           c_int),
             'is_staticdata'            : ([c_scope, c_int],           c_int),
+            'is_const_data'            : ([c_scope, c_int],           c_int),
+            'is_enum_data'             : ([c_scope, c_int],           c_int),
+            'get_dimension_size'       : ([c_scope, c_int, c_int],    c_int),
 
             # misc helpers
             'strtoll'                  : ([c_ccharp],                 c_llong),
@@ -328,25 +338,27 @@
     return rffi.cast(rffi.CCHARP, ptr)
 
 # name to opaque C++ scope representation ------------------------------------
-def c_num_scopes(space, cppscope):
-    return space.int_w(call_capi(space, 'num_scopes', 
[_ArgH(cppscope.handle)]))
-def c_scope_name(space, cppscope, iscope):
-    args = [_ArgH(cppscope.handle), _ArgL(iscope)]
-    return charp2str_free(space, call_capi(space, 'scope_name', args))
-
 def c_resolve_name(space, name):
     return charp2str_free(space, call_capi(space, 'resolve_name', 
[_ArgS(name)]))
+def c_resolve_enum(space, name):
+    return charp2str_free(space, call_capi(space, 'resolve_enum', 
[_ArgS(name)]))
 def c_get_scope_opaque(space, name):
     return rffi.cast(C_SCOPE, space.uint_w(call_capi(space, 'get_scope', 
[_ArgS(name)])))
 def c_actual_class(space, cppclass, cppobj):
     args = [_ArgH(cppclass.handle), _ArgH(cppobj)]
     return rffi.cast(C_TYPE, space.uint_w(call_capi(space, 'actual_class', 
args)))
+def c_size_of_klass(space, cppclass):
+    return _cdata_to_size_t(space, call_capi(space, 'size_of_klass', 
[_ArgH(cppclass.handle)]))
+def c_size_of_type(space, name):
+    return _cdata_to_size_t(space, call_capi(space, 'size_of_type', 
[_ArgS(name)]))
 
 # memory management ----------------------------------------------------------
 def c_allocate(space, cppclass):
     return _cdata_to_cobject(space, call_capi(space, 'allocate', 
[_ArgH(cppclass.handle)]))
 def c_deallocate(space, cppclass, cppobject):
     call_capi(space, 'deallocate', [_ArgH(cppclass.handle), _ArgH(cppobject)])
+def c_construct(space, cppclass):
+    return _cdata_to_cobject(space, call_capi(space, 'construct', 
[_ArgH(cppclass.handle)]))
 def c_destruct(space, cppclass, cppobject):
     call_capi(space, 'destruct', [_ArgH(cppclass.handle), _ArgH(cppobject)])
 
@@ -391,7 +403,7 @@
         w_cstr = call_capi(space, 'call_s',
             [_ArgH(cppmethod), _ArgH(cppobject), _ArgL(nargs), _ArgP(cargs),
              _ArgP(rffi.cast(rffi.VOIDP, length))])
-        cstr_len = intmask(length[0])
+        cstr_len = int(intmask(length[0]))
     finally:
         lltype.free(length, flavor='raw')
     return _cdata_to_ccharp(space, w_cstr), cstr_len
@@ -403,10 +415,13 @@
     args = [_ArgH(cppmethod), _ArgH(cppobject), _ArgL(nargs), _ArgP(cargs), 
_ArgH(cppclass.handle)]
     return _cdata_to_cobject(space, call_capi(space, 'call_o', args))
 
-def c_get_function_address(space, cppscope, index):
+def c_function_address_from_index(space, cppscope, index):
     args = [_ArgH(cppscope.handle), _ArgL(index)]
     return rffi.cast(C_FUNC_PTR,
-        _cdata_to_ptr(space, call_capi(space, 'get_function_address', args)))
+        _cdata_to_ptr(space, call_capi(space, 'function_address_from_index', 
args)))
+def c_function_address_from_method(space, cppmethod):
+    return rffi.cast(C_FUNC_PTR,
+        _cdata_to_ptr(space, call_capi(space, 'function_address_from_method', 
_ArgH(cppmethod))))
 
 # handling of function argument buffer ---------------------------------------
 def c_allocate_function_args(space, size):
@@ -430,6 +445,23 @@
 def c_is_enum(space, name):
     return space.bool_w(call_capi(space, 'is_enum', [_ArgS(name)]))
 
+def c_get_all_cpp_names(space, scope):
+    sz = lltype.malloc(rffi.SIZE_TP.TO, 1, flavor='raw', zero=True)
+    try:
+        args = [_ArgH(scope.handle), _ArgP(rffi.cast(rffi.VOIDP, sz))]
+        rawnames = rffi.cast(rffi.CCHARPP,
+            _cdata_to_ptr(space, call_capi(space, 'get_all_cpp_names', args)))
+        count = int(intmask(sz[0]))
+    finally:
+        lltype.free(sz, flavor='raw')
+    allnames = []
+    for i in range(count):
+        pystr = rffi.charp2str(rawnames[i])
+        c_free(space, rffi.cast(rffi.VOIDP, rawnames[i])) # c_free defined 
below
+        allnames.append(pystr)
+    c_free(space, rffi.cast(rffi.VOIDP, rawnames))        # id.
+    return allnames
+
 # type/class reflection information ------------------------------------------
 def c_final_name(space, cpptype):
     return charp2str_free(space, call_capi(space, 'final_name', 
[_ArgH(cpptype)]))
@@ -462,13 +494,10 @@
 def c_num_methods(space, cppscope):
     args = [_ArgH(cppscope.handle)]
     return space.int_w(call_capi(space, 'num_methods', args))
-def c_method_index_at(space, cppscope, imethod):
-    args = [_ArgH(cppscope.handle), _ArgL(imethod)]
-    return space.int_w(call_capi(space, 'method_index_at', args))
 def c_method_indices_from_name(space, cppscope, name):
     args = [_ArgH(cppscope.handle), _ArgS(name)]
     indices = rffi.cast(C_INDEX_ARRAY,
-                        _cdata_to_ptr(space, call_capi(space, 
'method_indices_from_name', args)))
+        _cdata_to_ptr(space, call_capi(space, 'method_indices_from_name', 
args)))
     if not indices:
         return []
     py_indices = []
@@ -506,6 +535,9 @@
     args = [_ArgH(cppscope.handle), _ArgL(index), _ArgL(show_formalargs)]
     return charp2str_free(space, call_capi(space, 'method_prototype', args))
 
+def c_exists_method_template(space, cppscope, name):
+    args = [_ArgH(cppscope.handle), _ArgS(name)]
+    return space.bool_w(call_capi(space, 'exists_method_template', args))
 def c_method_is_template(space, cppscope, index):
     args = [_ArgH(cppscope.handle), _ArgL(index)]
     return space.bool_w(call_capi(space, 'method_is_template', args))
@@ -531,9 +563,15 @@
     return rffi.cast(WLAVC_INDEX, -1)
 
 # method properties ----------------------------------------------------------
+def c_is_public_method(space, cppclass, index):
+    args = [_ArgH(cppclass.handle), _ArgL(index)]
+    return space.bool_w(call_capi(space, 'is_public_method', args))
 def c_is_constructor(space, cppclass, index):
     args = [_ArgH(cppclass.handle), _ArgL(index)]
     return space.bool_w(call_capi(space, 'is_constructor', args))
+def c_is_destructor(space, cppclass, index):
+    args = [_ArgH(cppclass.handle), _ArgL(index)]
+    return space.bool_w(call_capi(space, 'is_destructor', args))
 def c_is_staticmethod(space, cppclass, index):
     args = [_ArgH(cppclass.handle), _ArgL(index)]
     return space.bool_w(call_capi(space, 'is_staticmethod', args))
@@ -562,6 +600,15 @@
 def c_is_staticdata(space, cppscope, datamember_index):
     args = [_ArgH(cppscope.handle), _ArgL(datamember_index)]
     return space.bool_w(call_capi(space, 'is_staticdata', args))
+def c_is_const_data(space, cppscope, datamember_index):
+    args = [_ArgH(cppscope.handle), _ArgL(datamember_index)]
+    return space.bool_w(call_capi(space, 'is_const_data', args))
+def c_is_enum_data(space, cppscope, datamember_index):
+    args = [_ArgH(cppscope.handle), _ArgL(datamember_index)]
+    return space.bool_w(call_capi(space, 'is_enum_data', args))
+def c_get_dimension_size(space, cppscope, datamember_index, dim_idx):
+    args = [_ArgH(cppscope.handle), _ArgL(datamember_index), _ArgL(dim_idx)]
+    return space.bool_w(call_capi(space, 'get_dimension_size', args))
 
 # misc helpers ---------------------------------------------------------------
 def c_strtoll(space, svalue):
@@ -585,7 +632,7 @@
     try:
         w_cstr = call_capi(space, 'stdstring2charp',
             [_ArgH(cppstr), _ArgP(rffi.cast(rffi.VOIDP, sz))])
-        cstr_len = intmask(sz[0])
+        cstr_len = int(intmask(sz[0]))
     finally:
         lltype.free(sz, flavor='raw')
     return rffi.charpsize2str(_cdata_to_ccharp(space, w_cstr), cstr_len)
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
@@ -749,8 +749,6 @@
             return InstancePtrPtrConverter(space, clsdecl)
         elif compound == "":
             return InstanceConverter(space, clsdecl)
-    elif capi.c_is_enum(space, clean_name):
-        return _converters['unsigned'](space, default)
 
     #   5) void* or void converter (which fails on use)
     if 0 <= compound.find('*'):
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
@@ -289,8 +289,6 @@
             return InstancePtrExecutor(space, cppclass)
         elif compound == '**' or compound == '*&':
             return InstancePtrPtrExecutor(space, cppclass)
-    elif capi.c_is_enum(space, clean_name):
-        return _executors['internal_enum_type_t'](space, None)
 
     # 4) additional special cases
     if compound == '*':
diff --git a/pypy/module/_cppyy/include/capi.h 
b/pypy/module/_cppyy/include/capi.h
--- a/pypy/module/_cppyy/include/capi.h
+++ b/pypy/module/_cppyy/include/capi.h
@@ -8,26 +8,27 @@
 extern "C" {
 #endif // ifdef __cplusplus
 
-    typedef unsigned long cppyy_scope_t;
+    typedef ptrdiff_t     cppyy_scope_t;
     typedef cppyy_scope_t cppyy_type_t;
-    typedef unsigned long cppyy_object_t;
-    typedef unsigned long cppyy_method_t;
+    typedef void*         cppyy_object_t;
+    typedef ptrdiff_t     cppyy_method_t;
+
     typedef long          cppyy_index_t;
     typedef void*         cppyy_funcaddr_t;
 
     /* name to opaque C++ scope representation 
-------------------------------- */
     RPY_EXTERN
-    int cppyy_num_scopes(cppyy_scope_t parent);
+    char* cppyy_resolve_name(const char* cppitem_name);
     RPY_EXTERN
-    char* cppyy_scope_name(cppyy_scope_t parent, cppyy_index_t iscope);
-    RPY_EXTERN
-    char* cppyy_resolve_name(const char* cppitem_name);
+    char* cppyy_resolve_enum(const char* enum_type);
     RPY_EXTERN
     cppyy_scope_t cppyy_get_scope(const char* scope_name);
     RPY_EXTERN
     cppyy_type_t cppyy_actual_class(cppyy_type_t klass, cppyy_object_t obj);
     RPY_EXTERN
-    size_t cppyy_size_of(cppyy_type_t klass);
+    size_t cppyy_size_of_klass(cppyy_type_t klass);
+    RPY_EXTERN
+    size_t cppyy_size_of_type(const char* type_name);
 
     /* memory management 
------------------------------------------------------ */
     RPY_EXTERN
@@ -35,48 +36,53 @@
     RPY_EXTERN
     void cppyy_deallocate(cppyy_type_t type, cppyy_object_t self);
     RPY_EXTERN
+    cppyy_object_t cppyy_construct(cppyy_type_t type);
+    RPY_EXTERN
     void cppyy_destruct(cppyy_type_t type, cppyy_object_t self);
 
     /* method/function dispatching 
-------------------------------------------- */
     RPY_EXTERN
-    void   cppyy_call_v(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    void cppyy_call_v(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
     unsigned char cppyy_call_b(cppyy_method_t method, cppyy_object_t self, int 
nargs, void* args);
     RPY_EXTERN
-    char   cppyy_call_c(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    char cppyy_call_c(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
-    short  cppyy_call_h(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    short cppyy_call_h(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
-    int    cppyy_call_i(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    int cppyy_call_i(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
-    long   cppyy_call_l(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    long cppyy_call_l(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
     long long cppyy_call_ll(cppyy_method_t method, cppyy_object_t self, int 
nargs, void* args);
     RPY_EXTERN
-    float  cppyy_call_f(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    float cppyy_call_f(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
     double cppyy_call_d(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
     long double cppyy_call_ld(cppyy_method_t method, cppyy_object_t self, int 
nargs, void* args);
 
     RPY_EXTERN
-    void*  cppyy_call_r(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
+    void* cppyy_call_r(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args);
     RPY_EXTERN
-    char*  cppyy_call_s(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args, size_t* length);
-
+    char* cppyy_call_s(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args, size_t* length);
     RPY_EXTERN
     cppyy_object_t cppyy_constructor(cppyy_method_t method, cppyy_type_t 
klass, int nargs, void* args);
     RPY_EXTERN
+    void cppyy_destructor(cppyy_type_t type, cppyy_object_t self);
+    RPY_EXTERN
     cppyy_object_t cppyy_call_o(cppyy_method_t method, cppyy_object_t self, 
int nargs, void* args, cppyy_type_t result_type);
 
     RPY_EXTERN
-    cppyy_funcaddr_t cppyy_get_function_address(cppyy_scope_t scope, 
cppyy_index_t idx);
+    cppyy_funcaddr_t cppyy_function_address_from_index(cppyy_scope_t scope, 
cppyy_index_t idx);
+    RPY_EXTERN
+    cppyy_funcaddr_t cppyy_function_address_from_method(cppyy_method_t method);
 
     /* handling of function argument buffer 
----------------------------------- */
     RPY_EXTERN
-    void*  cppyy_allocate_function_args(int nargs);
+    void* cppyy_allocate_function_args(int nargs);
     RPY_EXTERN
-    void   cppyy_deallocate_function_args(void* args);
+    void cppyy_deallocate_function_args(void* args);
     RPY_EXTERN
     size_t cppyy_function_arg_sizeof();
     RPY_EXTERN
@@ -92,6 +98,9 @@
     RPY_EXTERN
     int cppyy_is_enum(const char* type_name);
 
+    RPY_EXTERN
+    const char** cppyy_get_all_cpp_names(cppyy_scope_t scope, size_t* count);
+
     /* class reflection information 
------------------------------------------- */
     RPY_EXTERN
     char* cppyy_final_name(cppyy_type_t type);
@@ -105,6 +114,10 @@
     char* cppyy_base_name(cppyy_type_t type, int base_index);
     RPY_EXTERN
     int cppyy_is_subtype(cppyy_type_t derived, cppyy_type_t base);
+    RPY_EXTERN
+    int cppyy_smartptr_info(const char* name, cppyy_type_t* raw, 
cppyy_method_t* deref);
+    RPY_EXTERN
+    void cppyy_add_smartptr_type(const char* type_name);
 
     /* calculate offsets between declared and actual type, up-cast: direction 
> 0; down-cast: direction < 0 */
     RPY_EXTERN
@@ -114,8 +127,6 @@
     RPY_EXTERN
     int cppyy_num_methods(cppyy_scope_t scope);
     RPY_EXTERN
-    cppyy_index_t cppyy_method_index_at(cppyy_scope_t scope, int imeth);
-    RPY_EXTERN
     cppyy_index_t* cppyy_method_indices_from_name(cppyy_scope_t scope, const 
char* name);
 
     RPY_EXTERN
@@ -136,8 +147,12 @@
     char* cppyy_method_signature(cppyy_scope_t scope, cppyy_index_t idx, int 
show_formalargs);
     RPY_EXTERN
     char* cppyy_method_prototype(cppyy_scope_t scope, cppyy_index_t idx, int 
show_formalargs);
+    RPY_EXTERN
+    int cppyy_is_const_method(cppyy_method_t);
 
     RPY_EXTERN
+    int cppyy_exists_method_template(cppyy_scope_t scope, const char* name);
+    RPY_EXTERN
     int cppyy_method_is_template(cppyy_scope_t scope, cppyy_index_t idx);
     RPY_EXTERN
     int cppyy_method_num_template_args(cppyy_scope_t scope, cppyy_index_t idx);
@@ -169,15 +184,20 @@
     char* cppyy_datamember_type(cppyy_scope_t scope, int datamember_index);
     RPY_EXTERN
     ptrdiff_t cppyy_datamember_offset(cppyy_scope_t scope, int 
datamember_index);
-
     RPY_EXTERN
     int cppyy_datamember_index(cppyy_scope_t scope, const char* name);
 
     /* data member properties 
------------------------------------------------- */
     RPY_EXTERN
-    int cppyy_is_publicdata(cppyy_type_t type, int datamember_index);
+    int cppyy_is_publicdata(cppyy_type_t type, cppyy_index_t datamember_index);
     RPY_EXTERN
-    int cppyy_is_staticdata(cppyy_type_t type, int datamember_index);
+    int cppyy_is_staticdata(cppyy_type_t type, cppyy_index_t datamember_index);
+    RPY_EXTERN
+    int cppyy_is_const_data(cppyy_scope_t scope, cppyy_index_t idata);
+    RPY_EXTERN
+    int cppyy_is_enum_data(cppyy_scope_t scope, cppyy_index_t idata);
+    RPY_EXTERN
+    int cppyy_get_dimension_size(cppyy_scope_t scope, cppyy_index_t idata, int 
dimension);
 
     /* misc helpers 
----------------------------------------------------------- */
     RPY_EXTERN
@@ -197,7 +217,7 @@
     RPY_EXTERN
     const char* cppyy_stdvector_valuetype(const char* clname);
     RPY_EXTERN
-    size_t cppyy_stdvector_valuesize(const char* clname);
+    size_t      cppyy_stdvector_valuesize(const char* clname);
 
 #ifdef __cplusplus
 }
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
@@ -322,7 +322,7 @@
         # 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.
-        funcaddr = capi.c_get_function_address(self.space, self.scope, 
self.index)
+        funcaddr = capi.c_function_address_from_index(self.space, self.scope, 
self.index)
         if funcaddr and cppthis:      # methods only for now
             state = self.space.fromcache(ffitypes.State)
 
@@ -845,24 +845,11 @@
         return self.space.w_True
 
     def ns__dir__(self):
-        # Collect a list of everything (currently) available in the namespace.
-        # The backend can filter by returning empty strings. Special care is
-        # taken for functions, which need not be unique (overloading).
-        alldir = []
-        for i in range(capi.c_num_scopes(self.space, self)):
-            sname = capi.c_scope_name(self.space, self, i)
-            if sname: alldir.append(self.space.newtext(sname))
-        allmeth = {}
-        for i in range(capi.c_num_methods(self.space, self)):
-            idx = capi.c_method_index_at(self.space, self, i)
-            mname = capi.c_method_name(self.space, self, idx)
-            if mname: allmeth.setdefault(mname, 0)
-        for m in allmeth.keys():
-            alldir.append(self.space.newtext(m))
-        for i in range(capi.c_num_datamembers(self.space, self)):
-            dname = capi.c_datamember_name(self.space, self, i)
-            if dname: alldir.append(self.space.newtext(dname))
-        return self.space.newlist(alldir)
+        alldir = capi.c_get_all_cpp_names(self.space, self)
+        w_alldir = self.space.newlist([])
+        for name in alldir:
+            w_alldir.append(self.space.wrap(name))
+        return w_alldir
         
     def missing_attribute_error(self, name):
         return oefmt(self.space.w_AttributeError,
@@ -890,8 +877,7 @@
     def _build_methods(self):
         assert len(self.methods) == 0
         methods_temp = {}
-        for i in range(capi.c_num_methods(self.space, self)):
-            idx = capi.c_method_index_at(self.space, self, i)
+        for idx in range(capi.c_num_methods(self.space, self)):
             if capi.c_is_constructor(self.space, self, idx):
                 pyname = '__init__'
             else:
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
@@ -438,9 +438,8 @@
     gbl.std.move = _cppyy.move
 
     # install a type for enums to refer to
-    # TODO: this is correct for C++98, not for C++11 and in general there will
-    # be the same issue for all typedef'd builtin types
     setattr(gbl, 'internal_enum_type_t', int)
+    setattr(gbl, 'unsigned int',         int)     # if resolved
 
     # install for user access
     _cppyy.gbl = gbl
diff --git a/pypy/module/_cppyy/src/dummy_backend.cxx 
b/pypy/module/_cppyy/src/dummy_backend.cxx
--- a/pypy/module/_cppyy/src/dummy_backend.cxx
+++ b/pypy/module/_cppyy/src/dummy_backend.cxx
@@ -407,10 +407,6 @@
 
 
 /* name to opaque C++ scope representation -------------------------------- */
-int cppyy_num_scopes(cppyy_scope_t handle) {
-    return 0;
-}
-
 char* cppyy_resolve_name(const char* cppitem_name) {
     return cppstring_to_cstring(cppitem_name);
 }
@@ -851,10 +847,13 @@
     return (cppyy_object_t)result;
 }
 
-cppyy_funcaddr_t cppyy_get_function_address(cppyy_scope_t /* scope */, 
cppyy_index_t /* idx */) {
+cppyy_funcaddr_t cppyy_function_address_from_index(cppyy_scope_t /* scope */, 
cppyy_index_t /* idx */) {
     return (cppyy_funcaddr_t)0;
 }
 
+cppyy_funcaddr_t cppyy_function_address_from_method(cppyy_method_t /* method 
*/) {
+    return (cppyy_funcaddr_t)0;
+}
 
 /* handling of function argument buffer ----------------------------------- */
 void* cppyy_allocate_function_args(int nargs) {
@@ -926,10 +925,6 @@
     return s_scopes[handle].m_methods.size();
 }
 
-cppyy_index_t cppyy_method_index_at(cppyy_scope_t /* scope */, int imeth) {
-    return (cppyy_index_t)imeth;
-}
-
 char* cppyy_method_name(cppyy_scope_t handle, cppyy_index_t method_index) {
     return 
cppstring_to_cstring(s_scopes[handle].m_methods[(int)method_index].m_name);
 }
@@ -978,8 +973,17 @@
     return (cppyy_method_t)0;
 }
 
+cppyy_index_t cppyy_get_global_operator(cppyy_scope_t /* scope */,
+        cppyy_scope_t /* lc */, cppyy_scope_t /* rc */, const char* /* op */) {
+    return (cppyy_index_t)-1;
+}
+
 
 /* method properties -----------------------------------------------------  */
+int cppyy_is_publicmethod(cppyy_type_t /* handle */, cppyy_index_t /* 
method_index */) {
+    return 1;
+}
+
 int cppyy_is_constructor(cppyy_type_t handle, cppyy_index_t method_index) {
     if (s_scopes.find(handle) != s_scopes.end())
         return s_scopes[handle].m_methods[method_index].m_type == kConstructor;
@@ -987,6 +991,10 @@
     return 0;
 }
 
+int cppyy_is_destructor(cppyy_type_t /* handle */, cppyy_index_t /* 
method_index */) {
+    return 0;
+}
+
 int cppyy_is_staticmethod(cppyy_type_t handle, cppyy_index_t method_index) {
     if (s_scopes.find(handle) != s_scopes.end())
         return s_scopes[handle].m_methods[method_index].m_type == kStatic;
@@ -1014,14 +1022,22 @@
 
 
 /* data member properties ------------------------------------------------  */
-int cppyy_is_publicdata(cppyy_scope_t handle, int idatambr) {
+int cppyy_is_publicdata(cppyy_scope_t /* handle */, cppyy_index_t /* idatambr 
*/) {
     return 1;
 }
 
-int cppyy_is_staticdata(cppyy_scope_t handle, int idatambr) {
+int cppyy_is_staticdata(cppyy_scope_t handle, cppyy_index_t idatambr) {
     return s_scopes[handle].m_datambrs[idatambr].m_isstatic;
 }
 
+int cppyy_is_const_data(cppyy_scope_t /* handle */, cppyy_index_t /* idatambr 
*/) {
+    return 0;
+}
+
+int cppyy_is_enum_data(cppyy_scope_t /* handle */, cppyy_index_t /* idatambr 
*/) {
+    return 0;
+}
+
 
 /* misc helpers ----------------------------------------------------------- */
 #if defined(_MSC_VER)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to