diff options
Diffstat (limited to 'sources/shiboken6/tests/samplebinding/samplesnippets.cpp')
-rw-r--r-- | sources/shiboken6/tests/samplebinding/samplesnippets.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/samplebinding/samplesnippets.cpp b/sources/shiboken6/tests/samplebinding/samplesnippets.cpp index 12ff7fc1d..43e6b08de 100644 --- a/sources/shiboken6/tests/samplebinding/samplesnippets.cpp +++ b/sources/shiboken6/tests/samplebinding/samplesnippets.cpp @@ -18,3 +18,37 @@ static PyObject *Sbk_IntWrapper_add_ints(PyObject * /* self */, PyObject *args) } } // @snippet intwrapper_add_ints + +// @snippet stdcomplex_floor +%PYARG_0 = PyFloat_FromDouble(std::floor(%CPPSELF.abs_value())); +// @snippet stdcomplex_floor + +// @snippet stdcomplex_ceil +%PYARG_0 = PyFloat_FromDouble(std::ceil(%CPPSELF.abs_value())); +// @snippet stdcomplex_ceil + +// @snippet stdcomplex_abs +%PYARG_0 = PyFloat_FromDouble(%CPPSELF.abs_value()); +// @snippet stdcomplex_abs + +// @snippet stdcomplex_pow +%RETURN_TYPE %0 = %CPPSELF.pow(%1); +%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); +// @snippet stdcomplex_pow + +// @snippet size_char_ct +// Convert a string "{width}x{height}" specification +{ + double width = -1; + double height = -1; + const std::string s = %1; + const auto pos = s.find('x'); + if (pos != std::string::npos) { + std::istringstream wstr(s.substr(0, pos)); + wstr >> width; + std::istringstream hstr(s.substr(pos + 1, s.size() - pos - 1)); + hstr >> height; + } + %0 = new %TYPE(width, height); +} +// @snippet size_char_ct |