Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r66698:bf72b7176f6f
Date: 2013-08-30 11:10 -0700
http://bitbucket.org/pypy/pypy/changeset/bf72b7176f6f/
Log: use assign operator directly for std::string conversions, to cover
all cases allowed
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
@@ -518,7 +518,10 @@
def to_memory(self, space, w_obj, w_value, offset):
try:
address = rffi.cast(capi.C_OBJECT, self._get_raw_address(space,
w_obj, offset))
- capi.c_assign2stdstring(space, address, space.str_w(w_value))
+ assign = self.cppclass.get_overload("__assign__")
+ from pypy.module.cppyy import interp_cppyy
+ assign.call(
+ interp_cppyy.wrap_cppobject(space, address, self.cppclass,
do_cast=False), [w_value])
except Exception:
InstanceConverter.to_memory(self, space, w_obj, w_value, offset)
@@ -652,7 +655,7 @@
_converters["void**"] = VoidPtrPtrConverter
_converters["void*&"] = VoidPtrRefConverter
-# special cases (note: CINT backend requires the simple name 'string')
+# special cases (note: 'string' aliases added below)
_converters["std::basic_string<char>"] = StdStringConverter
_converters["const std::basic_string<char>&"] = StdStringConverter #
TODO: shouldn't copy
_converters["std::basic_string<char>&"] = StdStringRefConverter
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
@@ -249,15 +249,13 @@
std = cppyy.gbl.std
stringy_class = cppyy.gbl.stringy_class
- c, s = stringy_class(""), std.string("test string")
+ c, s = stringy_class("dummy"), std.string("test string")
c.m_string = "another test"
assert c.m_string == "another test"
assert str(c.m_string) == c.m_string
assert c.get_string1() == "another test"
- return
- # TODO: assignment from object
c.m_string = s
assert str(c.m_string) == s
assert c.m_string == s
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit