Commit 3ebe99a6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f89760d1
...@@ -24,11 +24,13 @@ ...@@ -24,11 +24,13 @@
# XXX doc # XXX doc
from libcpp cimport nullptr_t, nullptr as nil from libcpp cimport nullptr_t, nullptr as nil
from libcpp.string cimport string
cdef extern from *: cdef extern from *:
ctypedef bint cbool "bool" ctypedef bint cbool "bool"
cdef extern from "wcfs_misc.h" nogil: cdef extern from "wcfs_misc.h" nogil:
cppclass error: cppclass error:
string Error() const
cbool operator==(nullptr_t) const cbool operator==(nullptr_t) const
cbool operator!=(nullptr_t) const cbool operator!=(nullptr_t) const
cbool operator==(const error&) const cbool operator==(const error&) const
...@@ -48,7 +50,7 @@ cdef class PyWatchLink: ...@@ -48,7 +50,7 @@ cdef class PyWatchLink:
with nogil: with nogil:
err = wlink_close_pyexc(pywlink.wlink) err = wlink_close_pyexc(pywlink.wlink)
if err != nil: if err != nil:
raise RuntimeError(err) # XXX exc class? raise RuntimeError(err.Error()) # XXX exc class?
......
...@@ -50,15 +50,18 @@ using std::vector; ...@@ -50,15 +50,18 @@ using std::vector;
const nullptr_t nil = nullptr; const nullptr_t nil = nullptr;
// error mimics error from Go. // error mimics error from Go.
struct error { class error {
string err; // XXX -> private + ,error() ? string _err;
public:
string Error() const;
error() {} error() {}
error(nullptr_t) {} // = nil error(nullptr_t) {} // = nil
// == nil // == nil
bool operator==(nullptr_t) const { bool operator==(nullptr_t) const {
return err.empty(); return _err.empty();
} }
bool operator!=(nullptr_t) const { bool operator!=(nullptr_t) const {
return !(*this==NULL); return !(*this==NULL);
...@@ -66,7 +69,7 @@ struct error { ...@@ -66,7 +69,7 @@ struct error {
// == error // == error
bool operator==(const error &rhs) const { bool operator==(const error &rhs) const {
return (err == rhs.err); return (_err == rhs._err);
} }
bool operator!=(const error &rhs) const { bool operator!=(const error &rhs) const {
return !(*this==rhs); return !(*this==rhs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment