Author: Wim Lavrijsen <[email protected]>
Branch: cppyy-packaging
Changeset: r92060:27a381b2e6b9
Date: 2017-08-03 15:08 -0700
http://bitbucket.org/pypy/pypy/changeset/27a381b2e6b9/
Log: remove load_reflection_info (lives in frontend)
diff --git a/pypy/module/_cppyy/__init__.py b/pypy/module/_cppyy/__init__.py
--- a/pypy/module/_cppyy/__init__.py
+++ b/pypy/module/_cppyy/__init__.py
@@ -6,7 +6,6 @@
See http://doc.pypy.org/en/latest/cppyy.html for full details."
interpleveldefs = {
- '_load_dictionary' : 'interp_cppyy.load_dictionary',
'_resolve_name' : 'interp_cppyy.resolve_name',
'_scope_byname' : 'interp_cppyy.scope_byname',
'_template_byname' : 'interp_cppyy.template_byname',
@@ -22,7 +21,6 @@
appleveldefs = {
'_init_pythonify' : 'pythonify._init_pythonify',
- 'load_reflection_info' : 'pythonify.load_reflection_info',
'add_pythonization' : 'pythonify.add_pythonization',
'Template' : 'pythonify.CPPTemplate',
}
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
@@ -320,9 +320,6 @@
ptr = _cdata_to_ptr(space, w_cdata) # see above ... something better?
return rffi.cast(rffi.CCHARP, ptr)
-def c_load_dictionary(name):
- return libffi.CDLL(name)
-
# name to opaque C++ scope representation ------------------------------------
def c_num_scopes(space, cppscope):
return space.int_w(call_capi(space, 'num_scopes',
[_ArgH(cppscope.handle)]))
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
@@ -31,21 +31,6 @@
def lt(self, a, b):
return a.priority() < b.priority()
-@unwrap_spec(name='text')
-def load_dictionary(space, name):
- try:
- cdll = capi.c_load_dictionary(name)
- if not cdll:
- raise OperationError(space.w_RuntimeError, space.newtext(str("could
not load dictionary " + name)))
-
- except rdynload.DLOpenError as e:
- if hasattr(space, "fake"): # FakeSpace fails e.msg (?!)
- errmsg = "failed to load cdll"
- else:
- errmsg = e.msg
- raise OperationError(space.w_RuntimeError, space.newtext(str(errmsg)))
- return W_CPPLibrary(space, cdll)
-
class State(object):
def __init__(self, space):
self.cppscope_cache = {
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
@@ -403,17 +403,6 @@
pyclass.__getitem__ = getitem
pyclass.__len__ = return2
-_loaded_dictionaries = {}
-def load_reflection_info(name):
- """Takes the name of a library containing reflection info, returns a handle
- to the loaded library."""
- try:
- return _loaded_dictionaries[name]
- except KeyError:
- import _cppyy
- lib = _cppyy._load_dictionary(name)
- _loaded_dictionaries[name] = lib
- return lib
def _init_pythonify():
# _cppyy should not be loaded at the module level, as that will trigger a
diff --git a/pypy/module/_cppyy/test/Makefile b/pypy/module/_cppyy/test/Makefile
--- a/pypy/module/_cppyy/test/Makefile
+++ b/pypy/module/_cppyy/test/Makefile
@@ -26,7 +26,7 @@
endif
-ifndef HASREFLEX
+ifndef HASGENREFLEX
%Dict.so: %.cxx
$(CXX) -shared $(cppflags) -o $@ $^
diff --git a/pypy/module/_cppyy/test/conftest.py
b/pypy/module/_cppyy/test/conftest.py
--- a/pypy/module/_cppyy/test/conftest.py
+++ b/pypy/module/_cppyy/test/conftest.py
@@ -14,10 +14,10 @@
py.test.skip("genreflex is not installed")
import re
if tst == 'test_pythonify.py' and \
- not re.search("AppTestPYTHONIFY.test0[1-6]", item.location[2]):
+ not re.search("AppTestPYTHONIFY.test0[1-5]", item.location[2]):
py.test.skip("genreflex is not installed")
elif tst == 'test_datatypes.py' and \
- not re.search("AppTestDATATYPES.test0[1-8]", item.location[2]):
+ not re.search("AppTestDATATYPES.test0[1-7]", item.location[2]):
py.test.skip("genreflex is not installed")
def pytest_ignore_collect(path, config):
diff --git a/pypy/module/_cppyy/test/datatypes.h
b/pypy/module/_cppyy/test/datatypes.h
--- a/pypy/module/_cppyy/test/datatypes.h
+++ b/pypy/module/_cppyy/test/datatypes.h
@@ -1,6 +1,3 @@
-#ifndef CPPYY_DUMMY_BACKEND
-#include "RtypesCore.h"
-#else
// copied from RtypesCore.h ...
#if defined(R__WIN32) && !defined(__CINT__)
typedef __int64 Long64_t; //Portable signed long integer 8 bytes
@@ -9,7 +6,7 @@
typedef long long Long64_t; //Portable signed long integer 8 bytes
typedef unsigned long long ULong64_t;//Portable unsigned long integer 8 bytes
#endif
-#endif
+
#include <vector>
const int N = 5;
diff --git a/pypy/module/_cppyy/test/std_streams_LinkDef.h
b/pypy/module/_cppyy/test/std_streams_LinkDef.h
deleted file mode 100644
--- a/pypy/module/_cppyy/test/std_streams_LinkDef.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifdef __CINT__
-
-#pragma link off all globals;
-#pragma link off all classes;
-#pragma link off all functions;
-
-#endif
diff --git a/pypy/module/_cppyy/test/test_advancedcpp.py
b/pypy/module/_cppyy/test/test_advancedcpp.py
--- a/pypy/module/_cppyy/test/test_advancedcpp.py
+++ b/pypy/module/_cppyy/test/test_advancedcpp.py
@@ -1,8 +1,12 @@
import py, os, sys
+from .support import setup_make
+
currpath = py.path.local(__file__).dirpath()
test_dct = str(currpath.join("advancedcppDict.so"))
+def setup_module(mod):
+ setup_make("advancedcppDict.so")
def setup_module(mod):
if sys.platform == 'win32':
@@ -18,8 +22,8 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_advanced = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_default_arguments(self):
"""Test usage of default arguments"""
@@ -146,10 +150,10 @@
def test03a_namespace_lookup_on_update(self):
"""Test whether namespaces can be shared across dictionaries."""
- import _cppyy
+ import _cppyy, ctypes
gbl = _cppyy.gbl
- lib2 = _cppyy.load_reflection_info("advancedcpp2Dict.so")
+ lib2 = ctypes.CDLL("./advancedcpp2Dict.so", ctypes.RTLD_GLOBAL)
assert gbl.a_ns is gbl.a_ns
assert gbl.a_ns.d_ns is gbl.a_ns.d_ns
diff --git a/pypy/module/_cppyy/test/test_cppyy.py
b/pypy/module/_cppyy/test/test_cppyy.py
--- a/pypy/module/_cppyy/test/test_cppyy.py
+++ b/pypy/module/_cppyy/test/test_cppyy.py
@@ -14,7 +14,8 @@
class TestCPPYYImplementation:
def test01_class_query(self, space):
# NOTE: this test needs to run before test_pythonify.py
- dct = interp_cppyy.load_dictionary(space, test_dct)
+ import ctypes
+ dct = ctypes.CDLL(test_dct)
w_cppyyclass = interp_cppyy.scope_byname(space, "example01")
w_cppyyclass2 = interp_cppyy.scope_byname(space, "example01")
assert space.is_w(w_cppyyclass, w_cppyyclass2)
@@ -30,10 +31,12 @@
spaceconfig = dict(usemodules=['_cppyy', '_rawffi', 'itertools'])
def setup_class(cls):
- cls.w_example01, cls.w_payload =
cls.space.unpackiterable(cls.space.appexec([], """():
- import _cppyy
- _cppyy.load_reflection_info(%r)
- return _cppyy._scope_byname('example01'),
_cppyy._scope_byname('payload')""" % (test_dct, )))
+ cls.w_lib, cls.w_example01, cls.w_payload = \
+ cls.space.unpackiterable(cls.space.appexec([], """():
+ import _cppyy, ctypes
+ lib = ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)
+ return lib, _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
diff --git a/pypy/module/_cppyy/test/test_crossing.py
b/pypy/module/_cppyy/test/test_crossing.py
--- a/pypy/module/_cppyy/test/test_crossing.py
+++ b/pypy/module/_cppyy/test/test_crossing.py
@@ -1,4 +1,5 @@
import py, os, sys
+from .support import setup_make
from pypy.interpreter.gateway import interp2app, unwrap_spec
from rpython.translator.tool.cbuild import ExternalCompilationInfo
@@ -14,11 +15,7 @@
test_dct = str(currpath.join("crossingDict.so"))
def setup_module(mod):
- if sys.platform == 'win32':
- py.test.skip("win32 not supported so far")
- err = os.system("cd '%s' && make crossingDict.so" % currpath)
- if err:
- raise OSError("'make' failed (see stderr)")
+ setup_make("crossingDict.so")
# from pypy/module/cpyext/test/test_cpyext.py; modified to accept more external
# symbols and called directly instead of import_module
@@ -145,8 +142,8 @@
def test02_crossing_dict(self):
"""Test availability of all needed classes in the dict"""
- import _cppyy
- _cppyy.load_reflection_info(self.test_dct)
+ import _cppyy, ctypes
+ lib = ctypes.CDLL(self.test_dct, ctypes.RTLD_GLOBAL)
assert _cppyy.gbl.crossing == _cppyy.gbl.crossing
crossing = _cppyy.gbl.crossing
diff --git a/pypy/module/_cppyy/test/test_datatypes.py
b/pypy/module/_cppyy/test/test_datatypes.py
--- a/pypy/module/_cppyy/test/test_datatypes.py
+++ b/pypy/module/_cppyy/test/test_datatypes.py
@@ -14,17 +14,11 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_datatypes = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
cls.w_N = cls.space.newint(5) # should be imported from the dictionary
- def test01_load_reflection_cache(self):
- """Loading reflection info twice should result in the same object"""
- import _cppyy
- lib2 = _cppyy.load_reflection_info(self.test_dct)
- assert self.datatypes is lib2
-
- def test02_instance_data_read_access(self):
+ def test01_instance_data_read_access(self):
"""Read access to instance public data and verify values"""
import _cppyy
@@ -112,7 +106,7 @@
c.__destruct__()
- def test03_instance_data_write_access(self):
+ def test02_instance_data_write_access(self):
"""Test write access to instance public data and verify values"""
import _cppyy
@@ -199,7 +193,7 @@
c.__destruct__()
- def test04_array_passing(self):
+ def test03_array_passing(self):
"""Test passing of array arguments"""
import _cppyy, array, sys
@@ -237,7 +231,7 @@
c.__destruct__()
- def test05_class_read_access(self):
+ def test04_class_read_access(self):
"""Test read access to class public data and verify values"""
import _cppyy, sys
@@ -278,7 +272,7 @@
c.__destruct__()
- def test06_class_data_write_access(self):
+ def test05_class_data_write_access(self):
"""Test write access to class public data and verify values"""
import _cppyy, sys
@@ -342,7 +336,7 @@
c.__destruct__()
- def test07_range_access(self):
+ def test06_range_access(self):
"""Test the ranges of integer types"""
import _cppyy, sys
@@ -358,7 +352,7 @@
c.__destruct__()
- def test08_type_conversions(self):
+ def test07_type_conversions(self):
"""Test conversions between builtin types"""
import _cppyy, sys
@@ -376,7 +370,7 @@
c.__destruct__()
- def test09_global_builtin_type(self):
+ def test08_global_builtin_type(self):
"""Test access to a global builtin type"""
import _cppyy
@@ -392,7 +386,7 @@
assert gbl.get_global_int() == 22
assert gbl.g_int == 22
- def test10_global_ptr(self):
+ def test09_global_ptr(self):
"""Test access of global objects through a pointer"""
import _cppyy
@@ -423,7 +417,7 @@
assert gbl.g_pod.m_int == 43
assert gbl.g_pod.m_double == 2.14
- def test11_enum(self):
+ def test10_enum(self):
"""Test access to enums"""
import _cppyy
@@ -471,7 +465,7 @@
assert gbl.kBanana == 29
assert gbl.kCitrus == 34
- def test12_string_passing(self):
+ def test11_string_passing(self):
"""Test passing/returning of a const char*"""
import _cppyy
@@ -481,7 +475,7 @@
assert c.get_valid_string('aap') == 'aap'
#assert c.get_invalid_string() == ''
- def test13_copy_contructor(self):
+ def test12_copy_contructor(self):
"""Test copy constructor"""
import _cppyy
@@ -497,7 +491,7 @@
for i in range(4):
assert t1[i] == t3[i]
- def test14_object_returns(self):
+ def test13_object_returns(self):
"""Test access to and return of PODs"""
import _cppyy
@@ -524,7 +518,7 @@
assert c.get_pod_ptrref().m_int == 666
assert c.get_pod_ptrref().m_double == 3.14
- def test15_object_arguments(self):
+ def test14_object_arguments(self):
"""Test setting and returning of a POD through arguments"""
import _cppyy
@@ -592,7 +586,7 @@
assert p.m_int == 888
assert p.m_double == 3.14
- def test16_nullptr_passing(self):
+ def test15_nullptr_passing(self):
"""Integer 0 ('NULL') and None allowed to pass through instance*"""
import _cppyy
@@ -607,7 +601,7 @@
assert not c.m_ppod
assert not c.get_pod_ptr()
- def test17_respect_privacy(self):
+ def test16_respect_privacy(self):
"""Test that privacy settings are respected"""
import _cppyy
@@ -620,7 +614,7 @@
c.__destruct__()
- def test18_object_and_pointer_comparisons(self):
+ def test17_object_and_pointer_comparisons(self):
"""Verify object and pointer comparisons"""
import _cppyy
@@ -657,7 +651,7 @@
assert l3 != l5
assert l5 != l3
- def test19_object_validity(self):
+ def test18_object_validity(self):
"""Test object validity checking"""
from _cppyy import gbl
@@ -671,7 +665,7 @@
assert not d2
- def test20_buffer_reshaping(self):
+ def test19_buffer_reshaping(self):
"""Test usage of buffer sizing"""
import _cppyy
@@ -692,7 +686,7 @@
for i in range(self.N):
assert arr[i] == l[i]
- def test21_voidp(self):
+ def test20_voidp(self):
"""Test usage of void* data"""
import _cppyy
diff --git a/pypy/module/_cppyy/test/test_fragile.py
b/pypy/module/_cppyy/test/test_fragile.py
--- a/pypy/module/_cppyy/test/test_fragile.py
+++ b/pypy/module/_cppyy/test/test_fragile.py
@@ -1,15 +1,12 @@
import py, os, sys
+from .support import setup_make
+
currpath = py.path.local(__file__).dirpath()
test_dct = str(currpath.join("fragileDict.so"))
-
def setup_module(mod):
- if sys.platform == 'win32':
- py.test.skip("win32 not supported so far")
- err = os.system("cd '%s' && make fragileDict.so" % currpath)
- if err:
- raise OSError("'make' failed (see stderr)")
+ setup_make("fragileDict.so")
class AppTestFRAGILE:
spaceconfig = dict(usemodules=['_cppyy', '_rawffi', 'itertools'])
@@ -17,21 +14,10 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_fragile = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
- def test01_load_failure(self):
- """Test failure to load dictionary"""
-
- import _cppyy
- raises(RuntimeError, _cppyy.load_reflection_info, "does_not_exist.so")
-
- try:
- _cppyy.load_reflection_info("does_not_exist.so")
- except RuntimeError as e:
- assert "does_not_exist.so" in str(e)
-
- def test02_missing_classes(self):
+ def test01_missing_classes(self):
"""Test (non-)access to missing classes"""
import _cppyy
@@ -54,7 +40,7 @@
assert fragile.C().check() == ord('C')
raises(TypeError, fragile.C().use_no_such, None)
- def test03_arguments(self):
+ def test02_arguments(self):
"""Test reporting when providing wrong arguments"""
import _cppyy
@@ -72,7 +58,7 @@
d.overload('a')
d.overload(1)
- def test04_unsupported_arguments(self):
+ def test03_unsupported_arguments(self):
"""Test arguments that are yet unsupported"""
import _cppyy
@@ -87,7 +73,7 @@
raises(TypeError, e.overload, None)
raises(TypeError, getattr, e, 'm_pp_no_such')
- def test05_wrong_arg_addressof(self):
+ def test04_wrong_arg_addressof(self):
"""Test addressof() error reporting"""
import _cppyy
@@ -109,7 +95,7 @@
assert _cppyy.addressof(None) == 0
assert _cppyy.addressof(_cppyy.gbl.nullptr) == 0
- def test06_wrong_this(self):
+ def test05_wrong_this(self):
"""Test that using an incorrect self argument raises"""
import _cppyy
@@ -130,7 +116,7 @@
assert isinstance(a.gime_null(), fragile.A)
raises(ReferenceError, fragile.A.check, a.gime_null())
- def test07_unnamed_enum(self):
+ def test06_unnamed_enum(self):
"""Test that an unnamed enum does not cause infinite recursion"""
import _cppyy
@@ -141,7 +127,7 @@
g = fragile.G()
- def test08_unhandled_scoped_datamember(self):
+ def test07_unhandled_scoped_datamember(self):
"""Test that an unhandled scoped data member does not cause infinite
recursion"""
import _cppyy
@@ -152,7 +138,7 @@
h = fragile.H()
- def test09_operator_bool(self):
+ def test08_operator_bool(self):
"""Access to global vars with an operator bool() returning False"""
import _cppyy
@@ -163,7 +149,7 @@
g = _cppyy.gbl.fragile.gI
assert not g
- def test10_documentation(self):
+ def test09_documentation(self):
"""Check contents of documentation"""
import _cppyy
@@ -205,7 +191,7 @@
except TypeError as e:
assert "cannot instantiate abstract class 'O'" in str(e)
- def test11_dir(self):
+ def test10_dir(self):
"""Test __dir__ method"""
import _cppyy
@@ -223,7 +209,7 @@
#assert 'fglobal' in members # function
#assert 'gI'in members # variable
- def test12_imports(self):
+ def test11_imports(self):
"""Test ability to import from namespace (or fail with ImportError)"""
import _cppyy
@@ -258,7 +244,7 @@
from _cppyy.gbl.fragile.nested1.nested2.nested3 import A
assert _cppyy.gbl.fragile.nested1.nested2.nested3.A is nested3.A
- def test13_missing_casts(self):
+ def test12_missing_casts(self):
"""Test proper handling when a hierarchy is not fully available"""
import _cppyy
@@ -275,7 +261,7 @@
l = k.GimeL()
assert l is k.GimeL()
- def test14_double_enum_trouble(self):
+ def test13_double_enum_trouble(self):
"""Test a redefinition of enum in a derived class"""
return # don't bother; is fixed in cling-support
diff --git a/pypy/module/_cppyy/test/test_operators.py
b/pypy/module/_cppyy/test/test_operators.py
--- a/pypy/module/_cppyy/test/test_operators.py
+++ b/pypy/module/_cppyy/test/test_operators.py
@@ -1,15 +1,12 @@
import py, os, sys
+from .support import setup_make
currpath = py.path.local(__file__).dirpath()
test_dct = str(currpath.join("operatorsDict.so"))
def setup_module(mod):
- if sys.platform == 'win32':
- py.test.skip("win32 not supported so far")
- err = os.system("cd '%s' && make operatorsDict.so" % currpath)
- if err:
- raise OSError("'make' failed (see stderr)")
+ setup_make("operatorsDict.so")
class AppTestOPERATORS:
spaceconfig = dict(usemodules=['_cppyy', '_rawffi', 'itertools'])
@@ -18,8 +15,8 @@
cls.w_N = cls.space.newint(5) # should be imported from the dictionary
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_operators = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def teardown_method(self, meth):
import gc
diff --git a/pypy/module/_cppyy/test/test_overloads.py
b/pypy/module/_cppyy/test/test_overloads.py
--- a/pypy/module/_cppyy/test/test_overloads.py
+++ b/pypy/module/_cppyy/test/test_overloads.py
@@ -18,8 +18,8 @@
env = os.environ
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_overloads = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_class_based_overloads(self):
"""Test functions overloaded on different C++ clases"""
diff --git a/pypy/module/_cppyy/test/test_pythonify.py
b/pypy/module/_cppyy/test/test_pythonify.py
--- a/pypy/module/_cppyy/test/test_pythonify.py
+++ b/pypy/module/_cppyy/test/test_pythonify.py
@@ -1,7 +1,7 @@
import py, os, sys
+from .support import setup_make
from pypy.module._cppyy import interp_cppyy, executor
-from .support import setup_make
currpath = py.path.local(__file__).dirpath()
@@ -16,16 +16,10 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_example01 = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
- def test01_load_dictionary_cache(self):
- """Test whether loading a dictionary twice results in the same
object."""
- import _cppyy
- lib2 = _cppyy.load_reflection_info(self.test_dct)
- assert self.example01 is lib2
-
- def test02_finding_classes(self):
+ def test01_finding_classes(self):
"""Test the lookup of a class, and its caching."""
import _cppyy
example01_class = _cppyy.gbl.example01
@@ -34,7 +28,7 @@
raises(AttributeError, '_cppyy.gbl.nonexistingclass')
- def test03_calling_static_functions(self):
+ def test02_calling_static_functions(self):
"""Test calling of static methods."""
import _cppyy, sys, math
example01_class = _cppyy.gbl.example01
@@ -70,7 +64,7 @@
raises(TypeError, 'example01_class.staticStrcpy(1.)') # TODO: this
leaks
- def test04_constructing_and_calling(self):
+ def test03_constructing_and_calling(self):
"""Test object and method calls."""
import _cppyy
example01_class = _cppyy.gbl.example01
@@ -122,7 +116,7 @@
instance.__destruct__()
assert example01_class.getCount() == 0
- def test05_passing_object_by_pointer(self):
+ def test04_passing_object_by_pointer(self):
import _cppyy
example01_class = _cppyy.gbl.example01
payload_class = _cppyy.gbl.payload
@@ -145,7 +139,7 @@
e.__destruct__()
assert example01_class.getCount() == 0
- def test06_returning_object_by_pointer(self):
+ def test05_returning_object_by_pointer(self):
import _cppyy
example01_class = _cppyy.gbl.example01
payload_class = _cppyy.gbl.payload
@@ -165,7 +159,7 @@
e.__destruct__()
assert example01_class.getCount() == 0
- def test07_returning_object_by_value(self):
+ def test06_returning_object_by_value(self):
import _cppyy
example01_class = _cppyy.gbl.example01
payload_class = _cppyy.gbl.payload
@@ -187,7 +181,7 @@
e.__destruct__()
assert example01_class.getCount() == 0
- def test08_global_functions(self):
+ def test07_global_functions(self):
import _cppyy
assert _cppyy.gbl.globalAddOneToInt(3) == 4 # creation lookup
@@ -196,7 +190,7 @@
assert _cppyy.gbl.ns_example01.globalAddOneToInt(4) == 5
assert _cppyy.gbl.ns_example01.globalAddOneToInt(4) == 5
- def test09_memory(self):
+ def test08_memory(self):
"""Test proper C++ destruction by the garbage collector"""
import _cppyy, gc
@@ -240,7 +234,7 @@
# TODO: need ReferenceError on touching pl_a
- def test10_default_arguments(self):
+ def test09_default_arguments(self):
"""Test propagation of default function arguments"""
import _cppyy
@@ -275,7 +269,7 @@
assert g(11., 2) == 2.
assert g(11.) == 11.
- def test11_overload_on_arguments(self):
+ def test10_overload_on_arguments(self):
"""Test functions overloaded on arguments"""
import _cppyy
@@ -286,14 +280,14 @@
assert e.overloadedAddDataToInt(4, 5) == 10
assert e.overloadedAddDataToInt(6, 7, 8) == 22
- def test12_typedefs(self):
+ def test11_typedefs(self):
"""Test access and use of typedefs"""
import _cppyy
assert _cppyy.gbl.example01 == _cppyy.gbl.example01_t
- def test13_underscore_in_class_name(self):
+ def test12_underscore_in_class_name(self):
"""Test recognition of '_' as part of a valid class name"""
import _cppyy
@@ -305,7 +299,7 @@
assert hasattr(z, 'myint')
assert z.gime_z_(z)
- def test14_bound_unbound_calls(self):
+ def test13_bound_unbound_calls(self):
"""Test (un)bound method calls"""
import _cppyy
@@ -319,7 +313,7 @@
e = _cppyy.gbl.example01(2)
assert 5 == meth(e, 3)
- def test15_installable_function(self):
+ def test14_installable_function(self):
"""Test installing and calling global C++ function as python method"""
import _cppyy
@@ -330,7 +324,7 @@
assert 2 == e.fresh(1)
assert 3 == e.fresh(2)
- def test16_subclassing(self):
+ def test15_subclassing(self):
"""A sub-class on the python side should have that class as type"""
import _cppyy
@@ -376,8 +370,8 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_example01 = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_pythonizations(self):
"""Test addition of user-defined pythonizations"""
diff --git a/pypy/module/_cppyy/test/test_stltypes.py
b/pypy/module/_cppyy/test/test_stltypes.py
--- a/pypy/module/_cppyy/test/test_stltypes.py
+++ b/pypy/module/_cppyy/test/test_stltypes.py
@@ -1,15 +1,12 @@
import py, os, sys
+from .support import setup_make
currpath = py.path.local(__file__).dirpath()
test_dct = str(currpath.join("stltypesDict.so"))
def setup_module(mod):
- if sys.platform == 'win32':
- py.test.skip("win32 not supported so far")
- err = os.system("cd '%s' && make stltypesDict.so" % currpath)
- if err:
- raise OSError("'make' failed (see stderr)")
+ setup_make("stltypesDict.so")
class AppTestSTLVECTOR:
spaceconfig = dict(usemodules=['_cppyy', '_rawffi', 'itertools'])
@@ -18,8 +15,8 @@
cls.w_N = cls.space.newint(13)
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_stlvector = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_builtin_type_vector_types(self):
"""Test access to std::vector<int>/std::vector<double>"""
@@ -205,8 +202,8 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_stlstring = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_string_argument_passing(self):
"""Test mapping of python strings and std::string"""
@@ -284,8 +281,8 @@
cls.w_N = cls.space.newint(13)
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_stlstring = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_builtin_list_type(self):
"""Test access to a list<int>"""
@@ -340,8 +337,8 @@
cls.w_N = cls.space.newint(13)
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_stlstring = cls.space.appexec([], """():
- import _cppyy
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_builtin_map_type(self):
"""Test access to a map<int,int>"""
@@ -448,8 +445,8 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_stlstring = cls.space.appexec([], """():
- import _cppyy, sys
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_builtin_vector_iterators(self):
"""Test iterator comparison with operator== reflected"""
@@ -485,8 +482,8 @@
def setup_class(cls):
cls.w_test_dct = cls.space.newtext(test_dct)
cls.w_stlstring = cls.space.appexec([], """():
- import _cppyy, sys
- return _cppyy.load_reflection_info(%r)""" % (test_dct, ))
+ import ctypes
+ return ctypes.CDLL(%r, ctypes.RTLD_GLOBAL)""" % (test_dct, ))
def test01_explicit_templates(self):
"""Explicit use of Template class"""
diff --git a/pypy/module/_cppyy/test/test_zjit.py
b/pypy/module/_cppyy/test/test_zjit.py
--- a/pypy/module/_cppyy/test/test_zjit.py
+++ b/pypy/module/_cppyy/test/test_zjit.py
@@ -51,11 +51,7 @@
test_dct = str(currpath.join("example01Dict.so"))
def setup_module(mod):
- if sys.platform == 'win32':
- py.test.skip("win32 not supported so far")
- err = os.system("cd '%s' && make example01Dict.so" % currpath)
- if err:
- raise OSError("'make' failed (see stderr)")
+ setup_make("example01Dict.so")
class FakeBase(W_Root):
@@ -263,7 +259,8 @@
space = FakeSpace()
drv = jit.JitDriver(greens=[], reds=["i", "inst", "cppmethod"])
def f():
- lib = interp_cppyy.load_dictionary(space, "./example01Dict.so")
+ import ctypes
+ lib = ctypes.CDLL("./example01Dict.so", ctypes.RTLD_GLOBAL)
cls = interp_cppyy.scope_byname(space, "example01")
inst = cls.get_overload("example01").call(None, [FakeInt(0)])
cppmethod = cls.get_overload(method_name)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit