Commit fd2a776b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6bde31f8
......@@ -34,17 +34,27 @@ cdef extern from *:
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:
cppclass _WatchLink:
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)
cppclass WatchLink (refptr[_WatchLink]):
# WatchLink.X = WatchLink->X in C++
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)
cppclass PinReq:
pass
cdef extern from "wcfs.h" nogil:
cppclass WCFS:
string mountpoint
......@@ -84,7 +94,19 @@ cdef class PyWatchLink:
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)
with nogil:
......@@ -92,18 +114,17 @@ cdef class PyWatchLink:
reply = _.first
err = _.second
printf("pyxsendReq: reply='%s'\n", reply.c_str())
#printf("pyxsendReq: reply='%s'\n", reply.c_str())
if err != nil:
raise RuntimeError(err.Error()) # XXX -> Xpy(err) ? pyraiseIf(err) ?
printf("pyxsendReq: reply -> ok\n")
#printf("pyxsendReq: reply -> ok\n")
return reply
cdef class PyPinReq:
pass
cdef PinReq pinreq
......@@ -119,5 +140,8 @@ cdef nogil:
error wlink_close_pyexc(WatchLink wlink) except +topyexc:
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:
return wlink.sendReq(ctx, req)
......@@ -55,7 +55,7 @@ using std::vector;
const nullptr_t nil = nullptr;
// io::
// io:: XXX -> pygolang
namespace io {
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