本文整理汇总了C++中RAISE_IF_HANDLE_NOT_INITIALIZED函数的典型用法代码示例。如果您正苦于以下问题:C++ RAISE_IF_HANDLE_NOT_INITIALIZED函数的具体用法?C++ RAISE_IF_HANDLE_NOT_INITIALIZED怎么用?C++ RAISE_IF_HANDLE_NOT_INITIALIZED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RAISE_IF_HANDLE_NOT_INITIALIZED函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Stream_func_write
static PyObject *
Stream_func_write(Stream *self, PyObject *args)
{
uv_buf_t buf;
stream_write_ctx *ctx;
Py_buffer *view;
PyObject *callback = Py_None;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
ctx = PyMem_Malloc(sizeof *ctx);
if (!ctx) {
PyErr_NoMemory();
return NULL;
}
view = &ctx->view[0];
if (!PyArg_ParseTuple(args, PYUV_BYTES"*|O:write", view, &callback)) {
PyMem_Free(ctx);
return NULL;
}
if (callback != Py_None && !PyCallable_Check(callback)) {
PyBuffer_Release(view);
PyMem_Free(ctx);
PyErr_SetString(PyExc_TypeError, "a callable or None is required");
return NULL;
}
buf = uv_buf_init(view->buf, view->len);
return pyuv_stream_write(self, ctx, view, &buf, 1, callback, NULL);
}
开发者ID:imclab,项目名称:pyuv,代码行数:35,代码来源:stream.c
示例2: 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
示例3: Stream_func_try_write
static PyObject *
Stream_func_try_write(Stream *self, PyObject *args)
{
int err;
uv_buf_t buf;
Py_buffer view;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, PYUV_BYTES"*:try_write", &view)) {
return NULL;
}
buf = uv_buf_init(view.buf, view.len);
err = uv_try_write((uv_stream_t *)UV_HANDLE(self), &buf, 1);
if (err < 0) {
RAISE_STREAM_EXCEPTION(err, UV_HANDLE(self));
PyBuffer_Release(&view);
return NULL;
}
PyBuffer_Release(&view);
return PyInt_FromLong((long)err);
}
开发者ID:ConchLikeSun,项目名称:pyuv,代码行数:25,代码来源:stream.c
示例4: 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
示例5: Stream_func_write
static PyObject *
Stream_func_write(Stream *self, PyObject *args)
{
PyObject *data;
PyObject *callback = Py_None;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "O|O:write", &data, &callback)) {
return NULL;
}
if (callback != Py_None && !PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "'callback' must be a callable or None");
return NULL;
}
if (PyObject_CheckBuffer(data)) {
return pyuv__stream_write_bytes(self, data, callback, NULL);
} else if (!PyUnicode_Check(data) && PySequence_Check(data)) {
return pyuv__stream_write_sequence(self, data, callback, NULL);
} else {
PyErr_SetString(PyExc_TypeError, "only bytes and sequences are supported");
return NULL;
}
}
开发者ID:ConchLikeSun,项目名称:pyuv,代码行数:27,代码来源:stream.c
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: Handle_func_close
static PyObject *
Handle_func_close(Handle *self, PyObject *args)
{
PyObject *callback = Py_None;
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
if (!PyArg_ParseTuple(args, "|O:close", &callback)) {
return NULL;
}
if (callback != Py_None && !PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable or None is required");
return NULL;
}
Py_INCREF(callback);
self->on_close_cb = callback;
/* Increase refcount so that object is not removed before the callback is called */
Py_INCREF(self);
uv_close(self->uv_handle, on_handle_close);
Py_RETURN_NONE;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:27,代码来源:handle.c
示例14: 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
示例15: Stream_func_start_read
static PyObject *
Stream_func_start_read(Stream *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_read", &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "a callable is required");
return NULL;
}
err = uv_read_start((uv_stream_t *)UV_HANDLE(self), (uv_alloc_cb)pyuv__alloc_cb, (uv_read_cb)pyuv__stream_read_cb);
if (err < 0) {
RAISE_STREAM_EXCEPTION(err, UV_HANDLE(self));
return NULL;
}
tmp = self->on_read_cb;
Py_INCREF(callback);
self->on_read_cb = callback;
Py_XDECREF(tmp);
PYUV_HANDLE_INCREF(self);
Py_RETURN_NONE;
}
开发者ID:ConchLikeSun,项目名称:pyuv,代码行数:35,代码来源:stream.c
示例16: Timer_repeat_set
static int
Timer_repeat_set(Timer *self, PyObject *value, void *closure)
{
double repeat;
UNUSED_ARG(closure);
RAISE_IF_HANDLE_NOT_INITIALIZED(self, -1);
if (!value) {
PyErr_SetString(PyExc_TypeError, "cannot delete attribute");
return -1;
}
repeat = PyFloat_AsDouble(value);
if (repeat == -1 && PyErr_Occurred()) {
return -1;
}
if (repeat < 0.0) {
PyErr_SetString(PyExc_ValueError, "a positive float or 0.0 is required");
return -1;
}
uv_timer_set_repeat(&self->timer_h, (uint64_t)(repeat * 1000));
return 0;
}
开发者ID:iyedb,项目名称:pyuv,代码行数:28,代码来源:timer.c
示例17: Pipe_func_pending_handle_type
static PyObject *
Pipe_func_pending_handle_type(Pipe *self)
{
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
return PyInt_FromLong(uv_pipe_pending_type(&self->pipe_h));
}
开发者ID:imclab,项目名称:pyuv,代码行数:8,代码来源:pipe.c
示例18: Handle_func_unref
static PyObject *
Handle_func_unref(Handle *self)
{
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);
uv_unref(self->uv_handle);
Py_RETURN_NONE;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:8,代码来源:handle.c
示例19: Timer_repeat_get
static PyObject *
Timer_repeat_get(Timer *self, void *closure)
{
UNUSED_ARG(closure);
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
return PyFloat_FromDouble(uv_timer_get_repeat(&self->timer_h)/1000.0);
}
开发者ID:iyedb,项目名称:pyuv,代码行数:9,代码来源:timer.c
示例20: Handle_closed_get
static PyObject *
Handle_closed_get(Handle *self, void *closure)
{
UNUSED_ARG(closure);
RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);
return PyBool_FromLong((long)uv_is_closing(self->uv_handle));
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:9,代码来源:handle.c
注:本文中的RAISE_IF_HANDLE_NOT_INITIALIZED函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论