本文整理汇总了C++中RAISE_UV_EXCEPTION函数的典型用法代码示例。如果您正苦于以下问题:C++ RAISE_UV_EXCEPTION函数的具体用法?C++ RAISE_UV_EXCEPTION怎么用?C++ RAISE_UV_EXCEPTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RAISE_UV_EXCEPTION函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Pipe_tp_init
static int
Pipe_tp_init(Pipe *self, PyObject *args, PyObject *kwargs)
{
int err;
Loop *loop;
PyObject *ipc = Py_False;
UNUSED_ARG(kwargs);
RAISE_IF_HANDLE_INITIALIZED(self, -1);
if (!PyArg_ParseTuple(args, "O!|O!:__init__", &LoopType, &loop, &PyBool_Type, &ipc)) {
return -1;
}
err = uv_pipe_init(loop->uv_loop, &self->pipe_h, (ipc == Py_True) ? 1 : 0);
if (err < 0) {
RAISE_UV_EXCEPTION(err, PyExc_PipeError);
return -1;
}
initialize_handle(HANDLE(self), loop);
return 0;
}
开发者ID:imclab,项目名称:pyuv,代码行数:25,代码来源:pipe.c
示例2: Pipe_func_getsockname
static PyObject *
Pipe_func_getsockname(Pipe *self)
{
#ifdef _WIN32
/* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */
char buf[MAX_PATH * 4];
#else
char buf[PATH_MAX];
#endif
size_t buf_len;
int err;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
buf_len = sizeof(buf);
err = uv_pipe_getsockname(&self->pipe_h, buf, &buf_len);
if (err < 0) {
RAISE_UV_EXCEPTION(err, PyExc_PipeError);
return NULL;
}
if (buf_len == 0) {
return PyBytes_FromString("");
} else if (buf[0] == '\0') {
/* Linux abstract namespace */
return PyBytes_FromStringAndSize(buf, buf_len);
} else {
return PyBytes_FromStringAndSize(buf, buf_len-1);
}
}
开发者ID:imclab,项目名称:pyuv,代码行数:32,代码来源:pipe.c
示例3: UDP_func_getsockname
static PyObject *
UDP_func_getsockname(UDP *self)
{
int r, namelen;
char ip[INET6_ADDRSTRLEN];
struct sockaddr sockname;
struct sockaddr_in *addr4;
struct sockaddr_in6 *addr6;
namelen = sizeof(sockname);
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
r = uv_udp_getsockname((uv_udp_t *)UV_HANDLE(self), &sockname, &namelen);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_UDPError);
return NULL;
}
if (sockname.sa_family == AF_INET) {
addr4 = (struct sockaddr_in*)&sockname;
uv_ip4_name(addr4, ip, INET_ADDRSTRLEN);
return Py_BuildValue("si", ip, ntohs(addr4->sin_port));
} else if (sockname.sa_family == AF_INET6) {
addr6 = (struct sockaddr_in6*)&sockname;
uv_ip6_name(addr6, ip, INET6_ADDRSTRLEN);
return Py_BuildValue("si", ip, ntohs(addr6->sin6_port));
} else {
PyErr_SetString(PyExc_UDPError, "unknown address type detected");
return NULL;
}
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:33,代码来源:udp.c
示例4: Pipe_func_start_read2
static PyObject *
Pipe_func_start_read2(Pipe *self, PyObject *args)
{
int r;
PyObject *tmp, *callback;
tmp = NULL;
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:start_read2", &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
r = uv_read2_start((uv_stream_t *)UV_HANDLE(self), (uv_alloc_cb)on_stream_alloc, (uv_read2_cb)on_pipe_read2);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_PipeError);
return NULL;
}
tmp = ((Stream *)self)->on_read_cb;
Py_INCREF(callback);
((Stream *)self)->on_read_cb = callback;
Py_XDECREF(tmp);
Py_RETURN_NONE;
}
开发者ID:tempbottle,项目名称:pyuv,代码行数:32,代码来源:pipe.c
示例5: Signal_func_start
static PyObject *
Signal_func_start(Signal *self, PyObject *args)
{
int r, signum;
PyObject *tmp, *callback;
tmp = NULL;
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "Oi:start", &callback, &signum)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
r = uv_signal_start((uv_signal_t *)UV_HANDLE(self), (uv_signal_cb)on_signal_callback, signum);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_SignalError);
return NULL;
}
tmp = self->callback;
Py_INCREF(callback);
self->callback = callback;
Py_XDECREF(tmp);
Py_RETURN_NONE;
}
开发者ID:jppommet,项目名称:pyuv,代码行数:32,代码来源:signal.c
示例6: UDP_func_bind
static PyObject *
UDP_func_bind(UDP *self, PyObject *args)
{
int r, bind_port, address_type;
char *bind_ip;
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "(si):bind", &bind_ip, &bind_port)) {
return NULL;
}
if (bind_port < 0 || bind_port > 65535) {
PyErr_SetString(PyExc_ValueError, "port must be between 0 and 65535");
return NULL;
}
if (pyuv_guess_ip_family(bind_ip, &address_type)) {
PyErr_SetString(PyExc_ValueError, "invalid IP address");
return NULL;
}
if (address_type == AF_INET) {
r = uv_udp_bind((uv_udp_t *)UV_HANDLE(self), uv_ip4_addr(bind_ip, bind_port), 0);
} else {
r = uv_udp_bind6((uv_udp_t *)UV_HANDLE(self), uv_ip6_addr(bind_ip, bind_port), UV_UDP_IPV6ONLY);
}
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_UDPError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:jppommet,项目名称:pyuv,代码行数:35,代码来源:udp.c
示例7: TCP_func_accept
static PyObject *
TCP_func_accept(TCP *self, PyObject *args)
{
int r;
PyObject *client;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:accept", &client)) {
return NULL;
}
if (!PyObject_IsSubclass((PyObject *)client->ob_type, (PyObject *)&StreamType)) {
PyErr_SetString(PyExc_TypeError, "Only stream objects are supported for accept");
return NULL;
}
r = uv_accept((uv_stream_t *)&self->tcp_h, (uv_stream_t *)UV_HANDLE(client));
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TCPError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:eagles125,项目名称:pyuv,代码行数:26,代码来源:tcp.c
示例8: UDP_func_set_ttl
static PyObject *
UDP_func_set_ttl(UDP *self, PyObject *args)
{
int r, ttl;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "i:set_multicast_ttl", &ttl)) {
return NULL;
}
if (ttl < 0 || ttl > 255) {
PyErr_SetString(PyExc_ValueError, "ttl must be between 0 and 255");
return NULL;
}
r = uv_udp_set_ttl((uv_udp_t *)UV_HANDLE(self), ttl);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_UDPError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:25,代码来源:udp.c
示例9: Prepare_func_start
static PyObject *
Prepare_func_start(Prepare *self, PyObject *args)
{
int r;
PyObject *tmp, *callback;
tmp = NULL;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:start", &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
r = uv_prepare_start(&self->prepare_h, on_prepare_callback);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_PrepareError);
return NULL;
}
tmp = self->callback;
Py_INCREF(callback);
self->callback = callback;
Py_XDECREF(tmp);
Py_RETURN_NONE;
}
开发者ID:eagles125,项目名称:pyuv,代码行数:33,代码来源:prepare.c
示例10: Idle_func_start
static PyObject *
Idle_func_start(Idle *self, PyObject *args)
{
int err;
PyObject *tmp, *callback;
tmp = NULL;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:start", &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
err = uv_idle_start(&self->idle_h, pyuv__idle_cb);
if (err < 0) {
RAISE_UV_EXCEPTION(err, PyExc_IdleError);
return NULL;
}
tmp = self->callback;
Py_INCREF(callback);
self->callback = callback;
Py_XDECREF(tmp);
PYUV_HANDLE_INCREF(self);
Py_RETURN_NONE;
}
开发者ID:ConchLikeSun,项目名称:pyuv,代码行数:35,代码来源:idle.c
示例11: TCP_func_bind
static PyObject *
TCP_func_bind(TCP *self, PyObject *args)
{
int r;
struct sockaddr sa;
PyObject *addr;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:bind", &addr)) {
return NULL;
}
if (pyuv_parse_addr_tuple(addr, &sa) < 0) {
/* Error is set by the function itself */
return NULL;
}
if (sa.sa_family == AF_INET) {
r = uv_tcp_bind(&self->tcp_h, *(struct sockaddr_in *)&sa);
} else {
r = uv_tcp_bind6(&self->tcp_h, *(struct sockaddr_in6 *)&sa);
}
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TCPError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:eagles125,项目名称:pyuv,代码行数:32,代码来源:tcp.c
示例12: Async_tp_init
static int
Async_tp_init(Async *self, PyObject *args, PyObject *kwargs)
{
int r;
Loop *loop;
PyObject *callback, *tmp;
UNUSED_ARG(kwargs);
RAISE_IF_HANDLE_INITIALIZED(self, -1);
if (!PyArg_ParseTuple(args, "O!O:__init__", &LoopType, &loop, &callback)) {
return -1;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return -1;
}
r = uv_async_init(loop->uv_loop, (uv_async_t *)UV_HANDLE(self), on_async_callback);
if (r != 0) {
RAISE_UV_EXCEPTION(loop->uv_loop, PyExc_AsyncError);
return -1;
}
tmp = self->callback;
Py_INCREF(callback);
self->callback = callback;
Py_XDECREF(tmp);
initialize_handle(HANDLE(self), loop);
return 0;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:35,代码来源:async.c
示例13: Pipe_func_accept
static PyObject *
Pipe_func_accept(Pipe *self, PyObject *args)
{
int r;
PyObject *client;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:accept", &client)) {
return NULL;
}
if (PyObject_IsSubclass((PyObject *)client->ob_type, (PyObject *)&StreamType)) {
if (UV_HANDLE(client)->type != UV_TCP && UV_HANDLE(client)->type != UV_NAMED_PIPE) {
PyErr_SetString(PyExc_TypeError, "Only TCP and Pipe objects are supported for accept");
return NULL;
}
} else if (PyObject_IsSubclass((PyObject *)client->ob_type, (PyObject *)&UDPType)) {
/* empty */
} else {
PyErr_SetString(PyExc_TypeError, "Only Stream and UDP objects are supported for accept");
return NULL;
}
r = uv_accept((uv_stream_t *)UV_HANDLE(self), (uv_stream_t *)UV_HANDLE(client));
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_PipeError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:33,代码来源:pipe.c
示例14: UDP_func_bind
static PyObject *
UDP_func_bind(UDP *self, PyObject *args)
{
int err, flags;
struct sockaddr_storage ss;
PyObject *addr;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
flags = 0;
if (!PyArg_ParseTuple(args, "O|i:bind", &addr, &flags)) {
return NULL;
}
if (pyuv_parse_addr_tuple(addr, &ss) < 0) {
/* Error is set by the function itself */
return NULL;
}
err = uv_udp_bind(&self->udp_h, (struct sockaddr *)&ss, flags);
if (err < 0) {
RAISE_UV_EXCEPTION(err, PyExc_UDPError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:imclab,项目名称:pyuv,代码行数:29,代码来源:udp.c
示例15: SignalChecker_tp_init
static int
SignalChecker_tp_init(SignalChecker *self, PyObject *args, PyObject *kwargs)
{
int err;
long fd;
Loop *loop;
UNUSED_ARG(kwargs);
RAISE_IF_HANDLE_INITIALIZED(self, -1);
if (!PyArg_ParseTuple(args, "O!l:__init__", &LoopType, &loop, &fd)) {
return -1;
}
err = uv_poll_init_socket(loop->uv_loop, &self->poll_h, (uv_os_sock_t)fd);
if (err < 0) {
RAISE_UV_EXCEPTION(err, PyExc_UVError);
return -1;
}
self->fd = fd;
initialize_handle(HANDLE(self), loop);
return 0;
}
开发者ID:Sevenops,项目名称:pyuv,代码行数:27,代码来源:util.c
示例16: UDP_func_start_recv
static PyObject *
UDP_func_start_recv(UDP *self, PyObject *args)
{
int r;
PyObject *tmp, *callback;
tmp = NULL;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O:start_recv", &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
r = uv_udp_recv_start((uv_udp_t *)UV_HANDLE(self), (uv_alloc_cb)on_udp_alloc, (uv_udp_recv_cb)on_udp_read);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_UDPError);
return NULL;
}
tmp = self->on_read_cb;
Py_INCREF(callback);
self->on_read_cb = callback;
Py_XDECREF(tmp);
Py_RETURN_NONE;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:33,代码来源:udp.c
示例17: TCP_func_connect
static PyObject *
TCP_func_connect(TCP *self, PyObject *args)
{
int r;
struct sockaddr sa;
uv_connect_t *connect_req = NULL;
PyObject *addr, *callback;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "OO:connect", &addr, &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
if (pyuv_parse_addr_tuple(addr, &sa) < 0) {
/* Error is set by the function itself */
return NULL;
}
Py_INCREF(callback);
connect_req = PyMem_Malloc(sizeof *connect_req);
if (!connect_req) {
PyErr_NoMemory();
goto error;
}
connect_req->data = callback;
if (sa.sa_family == AF_INET) {
r = uv_tcp_connect(connect_req, &self->tcp_h, *(struct sockaddr_in *)&sa, on_tcp_client_connection);
} else {
r = uv_tcp_connect6(connect_req, &self->tcp_h, *(struct sockaddr_in6 *)&sa, on_tcp_client_connection);
}
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TCPError);
goto error;
}
/* Increase refcount so that object is not removed before the callback is called */
Py_INCREF(self);
Py_RETURN_NONE;
error:
Py_DECREF(callback);
PyMem_Free(connect_req);
return NULL;
}
开发者ID:eagles125,项目名称:pyuv,代码行数:56,代码来源:tcp.c
示例18: TTY_func_get_winsize
static PyObject *
TTY_func_get_winsize(TTY *self)
{
int r, width, height;
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
r = uv_tty_get_winsize((uv_tty_t *)UV_HANDLE(self), &width, &height);
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TTYError);
return NULL;
}
return Py_BuildValue("(ii)", width, height);
}
开发者ID:benoitc,项目名称:pyuv,代码行数:15,代码来源:tty.c
示例19: Signal_func_stop
static PyObject *
Signal_func_stop(Signal *self)
{
int r;
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
r = uv_signal_stop((uv_signal_t *)UV_HANDLE(self));
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_SignalError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:jppommet,项目名称:pyuv,代码行数:15,代码来源:signal.c
示例20: Timer_func_again
static PyObject *
Timer_func_again(Timer *self)
{
int r;
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
r = uv_timer_again((uv_timer_t *)UV_HANDLE(self));
if (r != 0) {
RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TimerError);
return NULL;
}
Py_RETURN_NONE;
}
开发者ID:SongJLG,项目名称:johan-doc,代码行数:15,代码来源:timer.c
注:本文中的RAISE_UV_EXCEPTION函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论