Commit fd2a776b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6bde31f8
...@@ -34,17 +34,27 @@ cdef extern from *: ...@@ -34,17 +34,27 @@ cdef extern from *:
from libc.stdio cimport printf # XXX temp from libc.stdio cimport printf # XXX temp
# XXX -> pygolang
cdef extern from "wcfs_misc.h" namespace "io" nogil:
error EOF "io::EOF_"
error ErrUnexpectedEOF
cdef extern from "wcfs_watchlink.h" nogil: cdef extern from "wcfs_watchlink.h" nogil:
cppclass _WatchLink: cppclass _WatchLink:
error close() error close()
#error recvReq(ctx, PinReq *rx_into) error recvReq(context.Context ctx, PinReq *prx)
pair[string, error] sendReq(context.Context ctx, const string &req) pair[string, error] sendReq(context.Context ctx, const string &req)
cppclass WatchLink (refptr[_WatchLink]): cppclass WatchLink (refptr[_WatchLink]):
# WatchLink.X = WatchLink->X in C++ # WatchLink.X = WatchLink->X in C++
error close "_ptr()->close" () error close "_ptr()->close" ()
error recvReq "_ptr()->recvReq" (context.Context ctx, PinReq *prx)
pair[string, error] sendReq "_ptr()->sendReq" (context.Context ctx, const string &req) pair[string, error] sendReq "_ptr()->sendReq" (context.Context ctx, const string &req)
cppclass PinReq:
pass
cdef extern from "wcfs.h" nogil: cdef extern from "wcfs.h" nogil:
cppclass WCFS: cppclass WCFS:
string mountpoint string mountpoint
...@@ -84,7 +94,19 @@ cdef class PyWatchLink: ...@@ -84,7 +94,19 @@ cdef class PyWatchLink:
raise RuntimeError(err.Error()) # XXX exc class? raise RuntimeError(err.Error()) # XXX exc class?
# XXX recvReq def recvReq(PyWatchLink pywlink, context.PyContext pyctx): # -> PinReq | None when EOF
cdef PinReq req
with nogil:
err = wlink_recvReq_pyexc(pywlink.wlink, pyctx.ctx, &req)
if err.eq(EOF):
return None
if err != nil:
raise RuntimeError(err.Error()) # XXX exc class?
cdef PyPinReq pyreq = PyPinReq.__new__()
pyreq.pinreq = req
return pyreq
def sendReq(PyWatchLink pywlink, context.PyContext pyctx, string req): # -> reply(string) def sendReq(PyWatchLink pywlink, context.PyContext pyctx, string req): # -> reply(string)
with nogil: with nogil:
...@@ -92,18 +114,17 @@ cdef class PyWatchLink: ...@@ -92,18 +114,17 @@ cdef class PyWatchLink:
reply = _.first reply = _.first
err = _.second err = _.second
printf("pyxsendReq: reply='%s'\n", reply.c_str()) #printf("pyxsendReq: reply='%s'\n", reply.c_str())
if err != nil: if err != nil:
raise RuntimeError(err.Error()) # XXX -> Xpy(err) ? pyraiseIf(err) ? raise RuntimeError(err.Error()) # XXX -> Xpy(err) ? pyraiseIf(err) ?
printf("pyxsendReq: reply -> ok\n") #printf("pyxsendReq: reply -> ok\n")
return reply return reply
cdef class PyPinReq: cdef class PyPinReq:
pass cdef PinReq pinreq
...@@ -119,5 +140,8 @@ cdef nogil: ...@@ -119,5 +140,8 @@ cdef nogil:
error wlink_close_pyexc(WatchLink wlink) except +topyexc: error wlink_close_pyexc(WatchLink wlink) except +topyexc:
return wlink.close() return wlink.close()
error wlink_recvReq_pyexc(WatchLink wlink, context.Context ctx, PinReq *prx) except +topyexc:
return wlink.recvReq(ctx, prx)
pair[string, error] wlink_sendReq_pyexc(WatchLink wlink, context.Context ctx, const string &req) except +topyexc: pair[string, error] wlink_sendReq_pyexc(WatchLink wlink, context.Context ctx, const string &req) except +topyexc:
return wlink.sendReq(ctx, req) return wlink.sendReq(ctx, req)
...@@ -55,7 +55,7 @@ using std::vector; ...@@ -55,7 +55,7 @@ using std::vector;
const nullptr_t nil = nullptr; const nullptr_t nil = nullptr;
// io:: // io:: XXX -> pygolang
namespace io { namespace io {
extern const global<error> EOF_; extern const global<error> EOF_;
......
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