aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Lavrijsen <WLavrijsen@lbl.gov>2018-04-20 16:00:02 -0700
committerWim Lavrijsen <WLavrijsen@lbl.gov>2018-04-20 16:00:02 -0700
commit2a107bcdbf9334746f981a54d30ba4b69713b64b (patch)
treec08f6e1d8da01abdf158254cafcce148fa44d4c4
parentmerge default into branch (diff)
downloadpypy-2a107bcdbf9334746f981a54d30ba4b69713b64b.tar.gz
pypy-2a107bcdbf9334746f981a54d30ba4b69713b64b.tar.bz2
pypy-2a107bcdbf9334746f981a54d30ba4b69713b64b.zip
upgrade to backend 0.6.0
-rw-r--r--pypy/module/_cppyy/capi/loadable_capi.py91
-rw-r--r--pypy/module/_cppyy/converter.py2
-rw-r--r--pypy/module/_cppyy/executor.py2
-rw-r--r--pypy/module/_cppyy/include/capi.h72
-rw-r--r--pypy/module/_cppyy/interp_cppyy.py28
-rw-r--r--pypy/module/_cppyy/pythonify.py3
-rw-r--r--pypy/module/_cppyy/src/dummy_backend.cxx38
7 files changed, 150 insertions, 86 deletions
diff --git a/pypy/module/_cppyy/capi/loadable_capi.py b/pypy/module/_cppyy/capi/loadable_capi.py
index 4e4dd0aad9..00614c1a0c 100644
--- a/pypy/module/_cppyy/capi/loadable_capi.py
+++ b/pypy/module/_cppyy/capi/loadable_capi.py
@@ -121,11 +121,11 @@ class State(object):
# 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 @@ class State(object):
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 @@ class State(object):
'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 @@ class State(object):
'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 @@ class State(object):
# 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 @@ class State(object):
'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 @@ class State(object):
'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 @@ class State(object):
'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 @@ def _cdata_to_ccharp(space, w_cdata):
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 @@ def c_call_s(space, cppmethod, cppobject, nargs, cargs):
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 @@ def c_call_o(space, cppmethod, cppobject, nargs, cargs, cppclass):
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_abstract(space, cpptype):
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_base_offset1(space, derived_h, base, address, direction):
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 @@ def c_method_prototype(space, cppscope, index, show_formalargs=True):
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 @@ def c_get_global_operator(space, nss, lc, rc, op):
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_publicdata(space, cppscope, datamember_index):
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 @@ def c_stdstring2charp(space, cppstr):
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
index 88ebe662c2..83931137e4 100644
--- a/pypy/module/_cppyy/converter.py
+++ b/pypy/module/_cppyy/converter.py
@@ -749,8 +749,6 @@ def get_converter(space, _name, default):
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
index 4aad4e2115..3e258d8988 100644
--- a/pypy/module/_cppyy/executor.py
+++ b/pypy/module/_cppyy/executor.py
@@ -289,8 +289,6 @@ def get_executor(space, name):
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
index b232764c41..1488b3c5dd 100644
--- 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);
- RPY_EXTERN
- char* cppyy_scope_name(cppyy_scope_t parent, cppyy_index_t iscope);
- RPY_EXTERN
char* cppyy_resolve_name(const char* cppitem_name);
RPY_EXTERN
+ 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 @@ extern "C" {
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 @@ extern "C" {
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 @@ extern "C" {
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 @@ extern "C" {
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 @@ extern "C" {
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 @@ extern "C" {
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, 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_is_staticdata(cppyy_type_t type, int datamember_index);
+ int cppyy_get_dimension_size(cppyy_scope_t scope, cppyy_index_t idata, int dimension);
/* misc helpers ----------------------------------------------------------- */
RPY_EXTERN
@@ -197,7 +217,7 @@ extern "C" {
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
index 103dc44a91..3c6de6be85 100644
--- a/pypy/module/_cppyy/interp_cppyy.py
+++ b/pypy/module/_cppyy/interp_cppyy.py
@@ -322,7 +322,7 @@ class CPPMethod(object):
# 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 @@ class W_CPPNamespaceDecl(W_CPPScopeDecl):
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 @@ class W_CPPClassDecl(W_CPPScopeDecl):
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
index c224c35d79..9b37215ce2 100644
--- a/pypy/module/_cppyy/pythonify.py
+++ b/pypy/module/_cppyy/pythonify.py
@@ -438,9 +438,8 @@ def _init_pythonify():
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
index 6d1f0a51aa..c5376f5cc6 100644
--- a/pypy/module/_cppyy/src/dummy_backend.cxx
+++ b/pypy/module/_cppyy/src/dummy_backend.cxx
@@ -407,10 +407,6 @@ static inline char* cppstring_to_cstring(const std::string& name) {
/* 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 @@ cppyy_object_t cppyy_constructor(cppyy_method_t method, cppyy_type_t handle, int
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 @@ int cppyy_num_methods(cppyy_scope_t handle) {
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 @@ cppyy_method_t cppyy_get_method(cppyy_scope_t handle, cppyy_index_t method_index
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 @@ int cppyy_is_constructor(cppyy_type_t handle, cppyy_index_t method_index) {
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 @@ ptrdiff_t cppyy_datamember_offset(cppyy_scope_t handle, int idatambr) {
/* 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)