PageRenderTime 58ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 3ms

/zmq/core/socket.c

https://bitbucket.org/fatbox/pyzmq-static
C | 11745 lines | 7798 code | 802 blank | 3145 comment | 1486 complexity | 9ae7b613a714132098158c41a6419f43 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. /* Generated by Cython 0.15.1 on Mon Dec 19 01:21:36 2011 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #else
  7. #include <stddef.h> /* For offsetof */
  8. #ifndef offsetof
  9. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  10. #endif
  11. #if !defined(WIN32) && !defined(MS_WINDOWS)
  12. #ifndef __stdcall
  13. #define __stdcall
  14. #endif
  15. #ifndef __cdecl
  16. #define __cdecl
  17. #endif
  18. #ifndef __fastcall
  19. #define __fastcall
  20. #endif
  21. #endif
  22. #ifndef DL_IMPORT
  23. #define DL_IMPORT(t) t
  24. #endif
  25. #ifndef DL_EXPORT
  26. #define DL_EXPORT(t) t
  27. #endif
  28. #ifndef PY_LONG_LONG
  29. #define PY_LONG_LONG LONG_LONG
  30. #endif
  31. #if PY_VERSION_HEX < 0x02040000
  32. #define METH_COEXIST 0
  33. #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  34. #define PyDict_Contains(d,o) PySequence_Contains(d,o)
  35. #endif
  36. #if PY_VERSION_HEX < 0x02050000
  37. typedef int Py_ssize_t;
  38. #define PY_SSIZE_T_MAX INT_MAX
  39. #define PY_SSIZE_T_MIN INT_MIN
  40. #define PY_FORMAT_SIZE_T ""
  41. #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  42. #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o)
  43. #define PyNumber_Index(o) PyNumber_Int(o)
  44. #define PyIndex_Check(o) PyNumber_Check(o)
  45. #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  46. #endif
  47. #if PY_VERSION_HEX < 0x02060000
  48. #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  49. #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
  50. #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
  51. #define PyVarObject_HEAD_INIT(type, size) \
  52. PyObject_HEAD_INIT(type) size,
  53. #define PyType_Modified(t)
  54. typedef struct {
  55. void *buf;
  56. PyObject *obj;
  57. Py_ssize_t len;
  58. Py_ssize_t itemsize;
  59. int readonly;
  60. int ndim;
  61. char *format;
  62. Py_ssize_t *shape;
  63. Py_ssize_t *strides;
  64. Py_ssize_t *suboffsets;
  65. void *internal;
  66. } Py_buffer;
  67. #define PyBUF_SIMPLE 0
  68. #define PyBUF_WRITABLE 0x0001
  69. #define PyBUF_FORMAT 0x0004
  70. #define PyBUF_ND 0x0008
  71. #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  72. #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  73. #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  74. #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  75. #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  76. #endif
  77. #if PY_MAJOR_VERSION < 3
  78. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  79. #else
  80. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  81. #endif
  82. #if PY_MAJOR_VERSION >= 3
  83. #define Py_TPFLAGS_CHECKTYPES 0
  84. #define Py_TPFLAGS_HAVE_INDEX 0
  85. #endif
  86. #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  87. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  88. #endif
  89. #if PY_MAJOR_VERSION >= 3
  90. #define PyBaseString_Type PyUnicode_Type
  91. #define PyStringObject PyUnicodeObject
  92. #define PyString_Type PyUnicode_Type
  93. #define PyString_Check PyUnicode_Check
  94. #define PyString_CheckExact PyUnicode_CheckExact
  95. #endif
  96. #if PY_VERSION_HEX < 0x02060000
  97. #define PyBytesObject PyStringObject
  98. #define PyBytes_Type PyString_Type
  99. #define PyBytes_Check PyString_Check
  100. #define PyBytes_CheckExact PyString_CheckExact
  101. #define PyBytes_FromString PyString_FromString
  102. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  103. #define PyBytes_FromFormat PyString_FromFormat
  104. #define PyBytes_DecodeEscape PyString_DecodeEscape
  105. #define PyBytes_AsString PyString_AsString
  106. #define PyBytes_AsStringAndSize PyString_AsStringAndSize
  107. #define PyBytes_Size PyString_Size
  108. #define PyBytes_AS_STRING PyString_AS_STRING
  109. #define PyBytes_GET_SIZE PyString_GET_SIZE
  110. #define PyBytes_Repr PyString_Repr
  111. #define PyBytes_Concat PyString_Concat
  112. #define PyBytes_ConcatAndDel PyString_ConcatAndDel
  113. #endif
  114. #if PY_VERSION_HEX < 0x02060000
  115. #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
  116. #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
  117. #endif
  118. #ifndef PySet_CheckExact
  119. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  120. #endif
  121. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  122. #if PY_MAJOR_VERSION >= 3
  123. #define PyIntObject PyLongObject
  124. #define PyInt_Type PyLong_Type
  125. #define PyInt_Check(op) PyLong_Check(op)
  126. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  127. #define PyInt_FromString PyLong_FromString
  128. #define PyInt_FromUnicode PyLong_FromUnicode
  129. #define PyInt_FromLong PyLong_FromLong
  130. #define PyInt_FromSize_t PyLong_FromSize_t
  131. #define PyInt_FromSsize_t PyLong_FromSsize_t
  132. #define PyInt_AsLong PyLong_AsLong
  133. #define PyInt_AS_LONG PyLong_AS_LONG
  134. #define PyInt_AsSsize_t PyLong_AsSsize_t
  135. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  136. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  137. #endif
  138. #if PY_MAJOR_VERSION >= 3
  139. #define PyBoolObject PyLongObject
  140. #endif
  141. #if PY_VERSION_HEX < 0x03020000
  142. typedef long Py_hash_t;
  143. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  144. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  145. #else
  146. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  147. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  148. #endif
  149. #if PY_MAJOR_VERSION >= 3
  150. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  151. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  152. #else
  153. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  154. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  155. #endif
  156. #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  157. #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  158. #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  159. #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
  160. #else
  161. #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
  162. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
  163. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
  164. (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  165. #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
  166. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  167. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
  168. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  169. #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
  170. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  171. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
  172. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
  173. #endif
  174. #if PY_MAJOR_VERSION >= 3
  175. #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  176. #endif
  177. #if PY_VERSION_HEX < 0x02050000
  178. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
  179. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  180. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
  181. #else
  182. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
  183. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  184. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
  185. #endif
  186. #if PY_VERSION_HEX < 0x02050000
  187. #define __Pyx_NAMESTR(n) ((char *)(n))
  188. #define __Pyx_DOCSTR(n) ((char *)(n))
  189. #else
  190. #define __Pyx_NAMESTR(n) (n)
  191. #define __Pyx_DOCSTR(n) (n)
  192. #endif
  193. #ifndef __PYX_EXTERN_C
  194. #ifdef __cplusplus
  195. #define __PYX_EXTERN_C extern "C"
  196. #else
  197. #define __PYX_EXTERN_C extern
  198. #endif
  199. #endif
  200. #if defined(WIN32) || defined(MS_WINDOWS)
  201. #define _USE_MATH_DEFINES
  202. #endif
  203. #include <math.h>
  204. #define __PYX_HAVE__zmq__core__socket
  205. #define __PYX_HAVE_API__zmq__core__socket
  206. #include "allocate.h"
  207. #include "errno.h"
  208. #include "string.h"
  209. #include "zmq_compat.h"
  210. #include "zmq.h"
  211. #include "zmq_utils.h"
  212. #include "pyversion_compat.h"
  213. #include "stdio.h"
  214. #include "pythread.h"
  215. #ifdef _OPENMP
  216. #include <omp.h>
  217. #endif /* _OPENMP */
  218. #ifdef PYREX_WITHOUT_ASSERTIONS
  219. #define CYTHON_WITHOUT_ASSERTIONS
  220. #endif
  221. /* inline attribute */
  222. #ifndef CYTHON_INLINE
  223. #if defined(__GNUC__)
  224. #define CYTHON_INLINE __inline__
  225. #elif defined(_MSC_VER)
  226. #define CYTHON_INLINE __inline
  227. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  228. #define CYTHON_INLINE inline
  229. #else
  230. #define CYTHON_INLINE
  231. #endif
  232. #endif
  233. /* unused attribute */
  234. #ifndef CYTHON_UNUSED
  235. # if defined(__GNUC__)
  236. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  237. # define CYTHON_UNUSED __attribute__ ((__unused__))
  238. # else
  239. # define CYTHON_UNUSED
  240. # endif
  241. # elif defined(__ICC) || defined(__INTEL_COMPILER)
  242. # define CYTHON_UNUSED __attribute__ ((__unused__))
  243. # else
  244. # define CYTHON_UNUSED
  245. # endif
  246. #endif
  247. typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
  248. /* Type Conversion Predeclarations */
  249. #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
  250. #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
  251. #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
  252. #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
  253. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  254. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
  255. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  256. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  257. static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
  258. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  259. #ifdef __GNUC__
  260. /* Test for GCC > 2.95 */
  261. #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
  262. #define likely(x) __builtin_expect(!!(x), 1)
  263. #define unlikely(x) __builtin_expect(!!(x), 0)
  264. #else /* __GNUC__ > 2 ... */
  265. #define likely(x) (x)
  266. #define unlikely(x) (x)
  267. #endif /* __GNUC__ > 2 ... */
  268. #else /* __GNUC__ */
  269. #define likely(x) (x)
  270. #define unlikely(x) (x)
  271. #endif /* __GNUC__ */
  272. static PyObject *__pyx_m;
  273. static PyObject *__pyx_b;
  274. static PyObject *__pyx_empty_tuple;
  275. static PyObject *__pyx_empty_bytes;
  276. static int __pyx_lineno;
  277. static int __pyx_clineno = 0;
  278. static const char * __pyx_cfilenm= __FILE__;
  279. static const char *__pyx_filename;
  280. static const char *__pyx_f[] = {
  281. "socket.pyx",
  282. "socket.pxd",
  283. "buffers.pxd",
  284. "message.pxd",
  285. "context.pxd",
  286. "bool.pxd",
  287. "complex.pxd",
  288. };
  289. /*--- Type declarations ---*/
  290. struct __pyx_obj_3zmq_4core_6socket_Socket;
  291. struct __pyx_obj_3zmq_4core_7context_Context;
  292. struct __pyx_obj_3zmq_4core_7message_MessageTracker;
  293. struct __pyx_obj_3zmq_4core_7message_Message;
  294. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send;
  295. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv;
  296. struct __pyx_opt_args_3zmq_4core_6socket__recv_message;
  297. struct __pyx_opt_args_3zmq_4core_6socket__recv_copy;
  298. struct __pyx_opt_args_3zmq_4core_6socket__send_message;
  299. struct __pyx_opt_args_3zmq_4core_6socket__send_copy;
  300. /* "zmq/core/socket.pxd":47
  301. *
  302. * # cpdef methods for direct-cython access:
  303. * cpdef object send(self, object data, int flags=*, copy=*, track=*) # <<<<<<<<<<<<<<
  304. * cpdef object recv(self, int flags=*, copy=*, track=*)
  305. *
  306. */
  307. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send {
  308. int __pyx_n;
  309. int flags;
  310. PyObject *copy;
  311. PyObject *track;
  312. };
  313. /* "zmq/core/socket.pxd":48
  314. * # cpdef methods for direct-cython access:
  315. * cpdef object send(self, object data, int flags=*, copy=*, track=*)
  316. * cpdef object recv(self, int flags=*, copy=*, track=*) # <<<<<<<<<<<<<<
  317. *
  318. */
  319. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv {
  320. int __pyx_n;
  321. int flags;
  322. PyObject *copy;
  323. PyObject *track;
  324. };
  325. /* "zmq/core/socket.pyx":99
  326. * return False
  327. *
  328. * cdef inline Message _recv_message(void *handle, int flags=0, track=False): # <<<<<<<<<<<<<<
  329. * """Receive a message in a non-copying manner and return a Message."""
  330. * cdef int rc
  331. */
  332. struct __pyx_opt_args_3zmq_4core_6socket__recv_message {
  333. int __pyx_n;
  334. int flags;
  335. PyObject *track;
  336. };
  337. /* "zmq/core/socket.pyx":112
  338. * return msg
  339. *
  340. * cdef inline object _recv_copy(void *handle, int flags=0): # <<<<<<<<<<<<<<
  341. * """Recieve a message and return a copy"""
  342. * cdef zmq_msg_t zmq_msg
  343. */
  344. struct __pyx_opt_args_3zmq_4core_6socket__recv_copy {
  345. int __pyx_n;
  346. int flags;
  347. };
  348. /* "zmq/core/socket.pyx":125
  349. * return msg_bytes
  350. *
  351. * cdef inline object _send_message(void *handle, Message msg, int flags=0): # <<<<<<<<<<<<<<
  352. * """Send a Message on this socket in a non-copy manner."""
  353. * cdef int rc
  354. */
  355. struct __pyx_opt_args_3zmq_4core_6socket__send_message {
  356. int __pyx_n;
  357. int flags;
  358. };
  359. /* "zmq/core/socket.pyx":144
  360. *
  361. *
  362. * cdef inline object _send_copy(void *handle, object msg, int flags=0): # <<<<<<<<<<<<<<
  363. * """Send a message on this socket by copying its content."""
  364. * cdef int rc, rc2
  365. */
  366. struct __pyx_opt_args_3zmq_4core_6socket__send_copy {
  367. int __pyx_n;
  368. int flags;
  369. };
  370. /* "zmq/core/socket.pxd":35
  371. *
  372. *
  373. * cdef class Socket: # <<<<<<<<<<<<<<
  374. * """A 0MQ socket."""
  375. *
  376. */
  377. struct __pyx_obj_3zmq_4core_6socket_Socket {
  378. PyObject_HEAD
  379. struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *__pyx_vtab;
  380. void *handle;
  381. int socket_type;
  382. struct __pyx_obj_3zmq_4core_7context_Context *context;
  383. int _closed;
  384. PyObject *_attrs;
  385. };
  386. /* "context.pxd":26
  387. * #-----------------------------------------------------------------------------
  388. *
  389. * cdef class Context: # <<<<<<<<<<<<<<
  390. * """Manage the lifecycle of a 0MQ context."""
  391. *
  392. */
  393. struct __pyx_obj_3zmq_4core_7context_Context {
  394. PyObject_HEAD
  395. struct __pyx_vtabstruct_3zmq_4core_7context_Context *__pyx_vtab;
  396. void *handle;
  397. void **_sockets;
  398. size_t n_sockets;
  399. size_t max_sockets;
  400. PyObject *closed;
  401. };
  402. /* "message.pxd":32
  403. * #-----------------------------------------------------------------------------
  404. *
  405. * cdef class MessageTracker(object): # <<<<<<<<<<<<<<
  406. * """A class for tracking if 0MQ is done using one or more messages."""
  407. *
  408. */
  409. struct __pyx_obj_3zmq_4core_7message_MessageTracker {
  410. PyObject_HEAD
  411. PyObject *events;
  412. PyObject *peers;
  413. };
  414. /* "message.pxd":39
  415. *
  416. *
  417. * cdef class Message: # <<<<<<<<<<<<<<
  418. * """A Message class for non-copy send/recvs."""
  419. *
  420. */
  421. struct __pyx_obj_3zmq_4core_7message_Message {
  422. PyObject_HEAD
  423. struct __pyx_vtabstruct_3zmq_4core_7message_Message *__pyx_vtab;
  424. zmq_msg_t zmq_msg;
  425. PyObject *_data;
  426. PyObject *_buffer;
  427. PyObject *_bytes;
  428. int _failed_init;
  429. PyObject *tracker_event;
  430. PyObject *tracker;
  431. };
  432. /* "zmq/core/socket.pyx":171
  433. *
  434. *
  435. * cdef class Socket: # <<<<<<<<<<<<<<
  436. * """Socket(context, socket_type)
  437. *
  438. */
  439. struct __pyx_vtabstruct_3zmq_4core_6socket_Socket {
  440. PyObject *(*send)(struct __pyx_obj_3zmq_4core_6socket_Socket *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args);
  441. PyObject *(*recv)(struct __pyx_obj_3zmq_4core_6socket_Socket *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args);
  442. };
  443. static struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *__pyx_vtabptr_3zmq_4core_6socket_Socket;
  444. /* "message.pxd":39
  445. *
  446. *
  447. * cdef class Message: # <<<<<<<<<<<<<<
  448. * """A Message class for non-copy send/recvs."""
  449. *
  450. */
  451. struct __pyx_vtabstruct_3zmq_4core_7message_Message {
  452. struct __pyx_obj_3zmq_4core_7message_Message *(*fast_copy)(struct __pyx_obj_3zmq_4core_7message_Message *);
  453. PyObject *(*_getbuffer)(struct __pyx_obj_3zmq_4core_7message_Message *);
  454. };
  455. static struct __pyx_vtabstruct_3zmq_4core_7message_Message *__pyx_vtabptr_3zmq_4core_7message_Message;
  456. /* "context.pxd":26
  457. * #-----------------------------------------------------------------------------
  458. *
  459. * cdef class Context: # <<<<<<<<<<<<<<
  460. * """Manage the lifecycle of a 0MQ context."""
  461. *
  462. */
  463. struct __pyx_vtabstruct_3zmq_4core_7context_Context {
  464. void (*_add_socket)(struct __pyx_obj_3zmq_4core_7context_Context *, void *);
  465. void (*_remove_socket)(struct __pyx_obj_3zmq_4core_7context_Context *, void *);
  466. };
  467. static struct __pyx_vtabstruct_3zmq_4core_7context_Context *__pyx_vtabptr_3zmq_4core_7context_Context;
  468. #ifndef CYTHON_REFNANNY
  469. #define CYTHON_REFNANNY 0
  470. #endif
  471. #if CYTHON_REFNANNY
  472. typedef struct {
  473. void (*INCREF)(void*, PyObject*, int);
  474. void (*DECREF)(void*, PyObject*, int);
  475. void (*GOTREF)(void*, PyObject*, int);
  476. void (*GIVEREF)(void*, PyObject*, int);
  477. void* (*SetupContext)(const char*, int, const char*);
  478. void (*FinishContext)(void**);
  479. } __Pyx_RefNannyAPIStruct;
  480. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  481. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  482. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  483. #define __Pyx_RefNannySetupContext(name) __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  484. #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  485. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  486. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  487. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  488. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  489. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  490. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  491. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  492. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  493. #else
  494. #define __Pyx_RefNannyDeclarations
  495. #define __Pyx_RefNannySetupContext(name)
  496. #define __Pyx_RefNannyFinishContext()
  497. #define __Pyx_INCREF(r) Py_INCREF(r)
  498. #define __Pyx_DECREF(r) Py_DECREF(r)
  499. #define __Pyx_GOTREF(r)
  500. #define __Pyx_GIVEREF(r)
  501. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  502. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  503. #define __Pyx_XGOTREF(r)
  504. #define __Pyx_XGIVEREF(r)
  505. #endif /* CYTHON_REFNANNY */
  506. static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
  507. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  508. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  509. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
  510. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  511. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
  512. static void __Pyx_RaiseDoubleKeywordsError(
  513. const char* func_name, PyObject* kw_name); /*proto*/
  514. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/
  515. static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
  516. const char *name, int exact); /*proto*/
  517. static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) {
  518. return unlikely(b < 0) ? b : !b;
  519. }
  520. static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
  521. return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
  522. }
  523. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  524. static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
  525. #if PY_MAJOR_VERSION >= 3
  526. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
  527. PyObject *value;
  528. if (unlikely(d == Py_None)) {
  529. __Pyx_RaiseNoneIndexingError();
  530. return NULL;
  531. }
  532. value = PyDict_GetItemWithError(d, key);
  533. if (unlikely(!value)) {
  534. if (!PyErr_Occurred())
  535. PyErr_SetObject(PyExc_KeyError, key);
  536. return NULL;
  537. }
  538. Py_INCREF(value);
  539. return value;
  540. }
  541. #else
  542. #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
  543. #endif
  544. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
  545. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  546. PyObject *r;
  547. if (!j) return NULL;
  548. r = PyObject_GetItem(o, j);
  549. Py_DECREF(j);
  550. return r;
  551. }
  552. #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
  553. __Pyx_GetItemInt_List_Fast(o, i) : \
  554. __Pyx_GetItemInt_Generic(o, to_py_func(i)))
  555. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
  556. if (likely(o != Py_None)) {
  557. if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  558. PyObject *r = PyList_GET_ITEM(o, i);
  559. Py_INCREF(r);
  560. return r;
  561. }
  562. else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
  563. PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
  564. Py_INCREF(r);
  565. return r;
  566. }
  567. }
  568. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  569. }
  570. #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
  571. __Pyx_GetItemInt_Tuple_Fast(o, i) : \
  572. __Pyx_GetItemInt_Generic(o, to_py_func(i)))
  573. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
  574. if (likely(o != Py_None)) {
  575. if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  576. PyObject *r = PyTuple_GET_ITEM(o, i);
  577. Py_INCREF(r);
  578. return r;
  579. }
  580. else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
  581. PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
  582. Py_INCREF(r);
  583. return r;
  584. }
  585. }
  586. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  587. }
  588. #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
  589. __Pyx_GetItemInt_Fast(o, i) : \
  590. __Pyx_GetItemInt_Generic(o, to_py_func(i)))
  591. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
  592. PyObject *r;
  593. if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  594. r = PyList_GET_ITEM(o, i);
  595. Py_INCREF(r);
  596. }
  597. else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  598. r = PyTuple_GET_ITEM(o, i);
  599. Py_INCREF(r);
  600. }
  601. else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
  602. r = PySequence_GetItem(o, i);
  603. }
  604. else {
  605. r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  606. }
  607. return r;
  608. }
  609. static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
  610. PyObject* value;
  611. #if PY_MAJOR_VERSION >= 3
  612. value = PyDict_GetItemWithError(d, key);
  613. if (unlikely(!value)) {
  614. if (unlikely(PyErr_Occurred()))
  615. return NULL;
  616. value = default_value;
  617. }
  618. Py_INCREF(value);
  619. #else
  620. if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
  621. /* these presumably have safe hash functions */
  622. value = PyDict_GetItem(d, key);
  623. if (unlikely(!value)) {
  624. value = default_value;
  625. }
  626. Py_INCREF(value);
  627. } else {
  628. PyObject *m;
  629. m = __Pyx_GetAttrString(d, "get");
  630. if (!m) return NULL;
  631. value = PyObject_CallFunctionObjArgs(m, key,
  632. (default_value == Py_None) ? NULL : default_value, NULL);
  633. Py_DECREF(m);
  634. }
  635. #endif
  636. return value;
  637. }
  638. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  639. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  640. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
  641. #ifndef __PYX_FORCE_INIT_THREADS
  642. #if PY_VERSION_HEX < 0x02040200
  643. #define __PYX_FORCE_INIT_THREADS 1
  644. #else
  645. #define __PYX_FORCE_INIT_THREADS 0
  646. #endif
  647. #endif
  648. static CYTHON_INLINE pyzmq_int64_t __Pyx_PyInt_from_py_pyzmq_int64_t(PyObject *);
  649. static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_pyzmq_int64_t(pyzmq_int64_t);
  650. static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_ZMQ_FD_T(ZMQ_FD_T);
  651. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/
  652. #include <string.h>
  653. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  654. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  655. #if PY_MAJOR_VERSION >= 3
  656. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  657. #else
  658. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  659. #endif
  660. static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
  661. static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
  662. static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
  663. static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
  664. static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
  665. static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
  666. static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
  667. static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
  668. static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
  669. static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
  670. static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
  671. static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
  672. static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
  673. static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
  674. static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
  675. static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
  676. static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
  677. static int __Pyx_check_binary_version(void);
  678. static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
  679. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/
  680. static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
  681. static void* __Pyx_GetVtable(PyObject *dict); /*proto*/
  682. static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
  683. static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
  684. int __pyx_lineno, const char *__pyx_filename); /*proto*/
  685. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
  686. /* Module declarations from 'zmq.core.libzmq' */
  687. /* Module declarations from 'zmq.core.message' */
  688. static PyTypeObject *__pyx_ptype_3zmq_4core_7message_MessageTracker = 0;
  689. static PyTypeObject *__pyx_ptype_3zmq_4core_7message_Message = 0;
  690. static PyObject *(*__pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes)(zmq_msg_t *); /*proto*/
  691. /* Module declarations from 'zmq.core.context' */
  692. static PyTypeObject *__pyx_ptype_3zmq_4core_7context_Context = 0;
  693. /* Module declarations from 'cpython.version' */
  694. /* Module declarations from 'cpython.ref' */
  695. /* Module declarations from 'cpython.exc' */
  696. /* Module declarations from 'cpython.module' */
  697. /* Module declarations from 'cpython.mem' */
  698. /* Module declarations from 'cpython.tuple' */
  699. /* Module declarations from 'cpython.list' */
  700. /* Module declarations from 'libc.stdio' */
  701. /* Module declarations from 'cpython.object' */
  702. /* Module declarations from 'cpython.sequence' */
  703. /* Module declarations from 'cpython.mapping' */
  704. /* Module declarations from 'cpython.iterator' */
  705. /* Module declarations from 'cpython.type' */
  706. /* Module declarations from 'cpython.number' */
  707. /* Module declarations from 'cpython.int' */
  708. /* Module declarations from '__builtin__' */
  709. /* Module declarations from 'cpython.bool' */
  710. static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
  711. /* Module declarations from 'cpython.long' */
  712. /* Module declarations from 'cpython.float' */
  713. /* Module declarations from '__builtin__' */
  714. /* Module declarations from 'cpython.complex' */
  715. static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
  716. /* Module declarations from 'cpython.string' */
  717. /* Module declarations from 'cpython.unicode' */
  718. /* Module declarations from 'cpython.dict' */
  719. /* Module declarations from 'cpython.instance' */
  720. /* Module declarations from 'cpython.function' */
  721. /* Module declarations from 'cpython.method' */
  722. /* Module declarations from 'cpython.weakref' */
  723. /* Module declarations from 'cpython.getargs' */
  724. /* Module declarations from 'cpython.pythread' */
  725. /* Module declarations from 'cpython.pystate' */
  726. /* Module declarations from 'cpython.cobject' */
  727. /* Module declarations from 'cpython.oldbuffer' */
  728. /* Module declarations from 'cpython.set' */
  729. /* Module declarations from 'cpython.buffer' */
  730. /* Module declarations from 'cpython.bytes' */
  731. /* Module declarations from 'cpython.pycapsule' */
  732. /* Module declarations from 'cpython' */
  733. /* Module declarations from 'buffers' */
  734. static CYTHON_INLINE int __pyx_f_7buffers_newstyle_available(void); /*proto*/
  735. static CYTHON_INLINE int __pyx_f_7buffers_memoryview_available(void); /*proto*/
  736. static CYTHON_INLINE int __pyx_f_7buffers_oldstyle_available(void); /*proto*/
  737. static CYTHON_INLINE int __pyx_f_7buffers_check_buffer(PyObject *); /*proto*/
  738. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer(PyObject *, int, int, void **, Py_ssize_t *, Py_ssize_t *); /*proto*/
  739. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_r(PyObject *, void **, Py_ssize_t *); /*proto*/
  740. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_w(PyObject *, void **, Py_ssize_t *); /*proto*/
  741. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_3(void *, Py_ssize_t, int); /*proto*/
  742. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_2(void *, Py_ssize_t, int); /*proto*/
  743. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer(void *, Py_ssize_t, int); /*proto*/
  744. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_r(void *, Py_ssize_t); /*proto*/
  745. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_w(void *, Py_ssize_t); /*proto*/
  746. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject(PyObject *, int); /*proto*/
  747. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_r(PyObject *); /*proto*/
  748. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_w(PyObject *); /*proto*/
  749. /* Module declarations from 'zmq.core.socket' */
  750. static PyTypeObject *__pyx_ptype_3zmq_4core_6socket_Socket = 0;
  751. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__check_closed(struct __pyx_obj_3zmq_4core_6socket_Socket *, int); /*proto*/
  752. static CYTHON_INLINE struct __pyx_obj_3zmq_4core_7message_Message *__pyx_f_3zmq_4core_6socket__recv_message(void *, struct __pyx_opt_args_3zmq_4core_6socket__recv_message *__pyx_optional_args); /*proto*/
  753. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__recv_copy(void *, struct __pyx_opt_args_3zmq_4core_6socket__recv_copy *__pyx_optional_args); /*proto*/
  754. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_message(void *, struct __pyx_obj_3zmq_4core_7message_Message *, struct __pyx_opt_args_3zmq_4core_6socket__send_message *__pyx_optional_args); /*proto*/
  755. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_copy(void *, PyObject *, struct __pyx_opt_args_3zmq_4core_6socket__send_copy *__pyx_optional_args); /*proto*/
  756. #define __Pyx_MODULE_NAME "zmq.core.socket"
  757. int __pyx_module_is_main_zmq__core__socket = 0;
  758. /* Implementation of 'zmq.core.socket' */
  759. static PyObject *__pyx_builtin_property;
  760. static PyObject *__pyx_builtin_TypeError;
  761. static PyObject *__pyx_builtin_AttributeError;
  762. static PyObject *__pyx_builtin_xrange;
  763. static PyObject *__pyx_builtin_ValueError;
  764. static PyObject *__pyx_builtin_ImportError;
  765. static PyObject *__pyx_builtin_NotImplementedError;
  766. static char __pyx_k_2[] = "unicode not allowed, use setsockopt_unicode";
  767. static char __pyx_k_4[] = "expected bytes, got: %r";
  768. static char __pyx_k_5[] = "expected int, got: %r";
  769. static char __pyx_k_6[] = "utf-8";
  770. static char __pyx_k_7[] = "unicode strings only";
  771. static char __pyx_k_9[] = "option %i will not return a string to be decoded";
  772. static char __pyx_k_10[] = "zmq.core.socket";
  773. static char __pyx_k_11[] = "Socket has no such option: %s";
  774. static char __pyx_k_13[] = "expected str, got: %r";
  775. static char __pyx_k_14[] = "%s:%s";
  776. static char __pyx_k_15[] = "Could not bind socket to random port.";
  777. static char __pyx_k_20[] = "unicode not allowed, use send_unicode";
  778. static char __pyx_k_22[] = "Not a tracked message";
  779. static char __pyx_k_31[] = "unicode/str objects only";
  780. static char __pyx_k_33[] = "jsonlib{1,2}, json or simplejson library is required.";
  781. static char __pyx_k_36[] = "%r does not provide a buffer interface.";
  782. static char __pyx_k_37[] = "";
  783. static char __pyx_k_38[] = "New style buffers not available.";
  784. static char __pyx_k_40[] = "Old style buffers not available.";
  785. static char __pyx_k_42[] = "0MQ Socket class.";
  786. static char __pyx_k_43[] = "zmq.utils";
  787. static char __pyx_k_44[] = "zmq.core";
  788. static char __pyx_k_45[] = "zmq.core.constants";
  789. static char __pyx_k_46[] = "*";
  790. static char __pyx_k_47[] = "zmq.core.error";
  791. static char __pyx_k_48[] = "zmq.utils.strtypes";
  792. static char __pyx_k__B[] = "B";
  793. static char __pyx_k__u[] = "u";
  794. static char __pyx_k__obj[] = "obj";
  795. static char __pyx_k__sys[] = "sys";
  796. static char __pyx_k__zmq[] = "zmq";
  797. static char __pyx_k__addr[] = "addr";
  798. static char __pyx_k__bind[] = "bind";
  799. static char __pyx_k__char[] = "char";
  800. static char __pyx_k__copy[] = "copy";
  801. static char __pyx_k__data[] = "data";
  802. static char __pyx_k__poll[] = "poll";
  803. static char __pyx_k__recv[] = "recv";
  804. static char __pyx_k__send[] = "send";
  805. static char __pyx_k__time[] = "time";
  806. static char __pyx_k__bytes[] = "bytes";
  807. static char __pyx_k__close[] = "close";
  808. static char __pyx_k__dtype[] = "dtype";
  809. static char __pyx_k__dumps[] = "dumps";
  810. static char __pyx_k__flags[] = "flags";
  811. static char __pyx_k__loads[] = "loads";
  812. static char __pyx_k__range[] = "range";
  813. static char __pyx_k__track[] = "track";
  814. static char __pyx_k__upper[] = "upper";
  815. static char __pyx_k__POLLIN[] = "POLLIN";
  816. static char __pyx_k__Poller[] = "Poller";
  817. static char __pyx_k__Socket[] = "Socket";
  818. static char __pyx_k__buffer[] = "buffer";
  819. static char __pyx_k__closed[] = "closed";
  820. static char __pyx_k__codecs[] = "codecs";
  821. static char __pyx_k__decode[] = "decode";
  822. static char __pyx_k__encode[] = "encode";
  823. static char __pyx_k__linger[] = "linger";
  824. static char __pyx_k__option[] = "option";
  825. static char __pyx_k__optval[] = "optval";
  826. static char __pyx_k__pickle[] = "pickle";
  827. static char __pyx_k__prefix[] = "prefix";
  828. static char __pyx_k__random[] = "random";
  829. static char __pyx_k__struct[] = "struct";
  830. static char __pyx_k__xrange[] = "xrange";
  831. static char __pyx_k__ENOTSUP[] = "ENOTSUP";
  832. static char __pyx_k__POLLERR[] = "POLLERR";
  833. static char __pyx_k__SNDMORE[] = "SNDMORE";
  834. static char __pyx_k____all__[] = "__all__";
  835. static char __pyx_k___handle[] = "_handle";
  836. static char __pyx_k__cPickle[] = "cPickle";
  837. static char __pyx_k__context[] = "context";
  838. static char __pyx_k__jsonapi[] = "jsonapi";
  839. static char __pyx_k__jsonmod[] = "jsonmod";
  840. static char __pyx_k__timeout[] = "timeout";
  841. static char __pyx_k__tracker[] = "tracker";
  842. static char __pyx_k__unicode[] = "unicode";
  843. static char __pyx_k__ENOTSOCK[] = "ENOTSOCK";
  844. static char __pyx_k__ZMQError[] = "ZMQError";
  845. static char __pyx_k____main__[] = "__main__";
  846. static char __pyx_k____test__[] = "__test__";
  847. static char __pyx_k__copy_mod[] = "copy_mod";
  848. static char __pyx_k__encoding[] = "encoding";
  849. static char __pyx_k__itemsize[] = "itemsize";
  850. static char __pyx_k__max_port[] = "max_port";
  851. static char __pyx_k__min_port[] = "min_port";
  852. static char __pyx_k__property[] = "property";
  853. static char __pyx_k__protocol[] = "protocol";
  854. static char __pyx_k__register[] = "register";
  855. static char __pyx_k__typecode[] = "typecode";
  856. static char __pyx_k__TypeError[] = "TypeError";
  857. static char __pyx_k____class__[] = "__class__";
  858. static char __pyx_k__constants[] = "constants";
  859. static char __pyx_k__max_tries[] = "max_tries";
  860. static char __pyx_k__msg_parts[] = "msg_parts";
  861. static char __pyx_k__randrange[] = "randrange";
  862. static char __pyx_k__ValueError[] = "ValueError";
  863. static char __pyx_k____module__[] = "__module__";
  864. static char __pyx_k__basestring[] = "basestring";
  865. static char __pyx_k__getsockopt[] = "getsockopt";
  866. static char __pyx_k__setsockopt[] = "setsockopt";
  867. static char __pyx_k__ImportError[] = "ImportError";
  868. static char __pyx_k__socket_type[] = "socket_type";
  869. static char __pyx_k__ZMQBindError[] = "ZMQBindError";
  870. static char __pyx_k__AttributeError[] = "AttributeError";
  871. static char __pyx_k__bytes_sockopts[] = "bytes_sockopts";
  872. static char __pyx_k__int64_sockopts[] = "int64_sockopts";
  873. static char __pyx_k__NotImplementedError[] = "NotImplementedError";
  874. static PyObject *__pyx_kp_s_10;
  875. static PyObject *__pyx_kp_s_11;
  876. static PyObject *__pyx_kp_s_13;
  877. static PyObject *__pyx_kp_s_14;
  878. static PyObject *__pyx_kp_s_15;
  879. static PyObject *__pyx_kp_s_2;
  880. static PyObject *__pyx_kp_s_20;
  881. static PyObject *__pyx_kp_s_22;
  882. static PyObject *__pyx_kp_s_31;
  883. static PyObject *__pyx_kp_s_33;
  884. static PyObject *__pyx_kp_s_36;
  885. static PyObject *__pyx_kp_s_37;
  886. static PyObject *__pyx_kp_s_38;
  887. static PyObject *__pyx_kp_s_4;
  888. static PyObject *__pyx_kp_s_40;
  889. static PyObject *__pyx_n_s_43;
  890. static PyObject *__pyx_n_s_44;
  891. static PyObject *__pyx_n_s_45;
  892. static PyObject *__pyx_n_s_46;
  893. static PyObject *__pyx_n_s_47;
  894. static PyObject *__pyx_n_s_48;
  895. static PyObject *__pyx_kp_s_5;
  896. static PyObject *__pyx_kp_s_6;
  897. static PyObject *__pyx_kp_s_7;
  898. static PyObject *__pyx_kp_s_9;
  899. static PyObject *__pyx_n_s__AttributeError;
  900. static PyObject *__pyx_n_s__B;
  901. static PyObject *__pyx_n_s__ENOTSOCK;
  902. static PyObject *__pyx_n_s__ENOTSUP;
  903. static PyObject *__pyx_n_s__ImportError;
  904. static PyObject *__pyx_n_s__NotImplementedError;
  905. static PyObject *__pyx_n_s__POLLERR;
  906. static PyObject *__pyx_n_s__POLLIN;
  907. static PyObject *__pyx_n_s__Poller;
  908. static PyObject *__pyx_n_s__SNDMORE;
  909. static PyObject *__pyx_n_s__Socket;
  910. static PyObject *__pyx_n_s__TypeError;
  911. static PyObject *__pyx_n_s__ValueError;
  912. static PyObject *__pyx_n_s__ZMQBindError;
  913. static PyObject *__pyx_n_s__ZMQError;
  914. static PyObject *__pyx_n_s____all__;
  915. static PyObject *__pyx_n_s____class__;
  916. static PyObject *__pyx_n_s____main__;
  917. static PyObject *__pyx_n_s____module__;
  918. static PyObject *__pyx_n_s____test__;
  919. static PyObject *__pyx_n_s___handle;
  920. static PyObject *__pyx_n_s__addr;
  921. static PyObject *__pyx_n_s__basestring;
  922. static PyObject *__pyx_n_s__bind;
  923. static PyObject *__pyx_n_s__buffer;
  924. static PyObject *__pyx_n_s__bytes;
  925. static PyObject *__pyx_n_s__bytes_sockopts;
  926. static PyObject *__pyx_n_s__cPickle;
  927. static PyObject *__pyx_n_s__char;
  928. static PyObject *__pyx_n_s__close;
  929. static PyObject *__pyx_n_s__closed;
  930. static PyObject *__pyx_n_s__codecs;
  931. static PyObject *__pyx_n_s__constants;
  932. static PyObject *__pyx_n_s__context;
  933. static PyObject *__pyx_n_s__copy;
  934. static PyObject *__pyx_n_s__copy_mod;
  935. static PyObject *__pyx_n_s__data;
  936. static PyObject *__pyx_n_s__decode;
  937. static PyObject *__pyx_n_s__dtype;
  938. static PyObject *__pyx_n_s__dumps;
  939. static PyObject *__pyx_n_s__encode;
  940. static PyObject *__pyx_n_s__encoding;
  941. static PyObject *__pyx_n_s__flags;
  942. static PyObject *__pyx_n_s__getsockopt;
  943. static PyObject *__pyx_n_s__int64_sockopts;
  944. static PyObject *__pyx_n_s__itemsize;
  945. static PyObject *__pyx_n_s__jsonapi;
  946. static PyObject *__pyx_n_s__jsonmod;
  947. static PyObject *__pyx_n_s__linger;
  948. static PyObject *__pyx_n_s__loads;
  949. static PyObject *__pyx_n_s__max_port;
  950. static PyObject *__pyx_n_s__max_tries;
  951. static PyObject *__pyx_n_s__min_port;
  952. static PyObject *__pyx_n_s__msg_parts;
  953. static PyObject *__pyx_n_s__obj;
  954. static PyObject *__pyx_n_s__option;
  955. static PyObject *__pyx_n_s__optval;
  956. static PyObject *__pyx_n_s__pickle;
  957. static PyObject *__pyx_n_s__poll;
  958. static PyObject *__pyx_n_s__prefix;
  959. static PyObject *__pyx_n_s__property;
  960. static PyObject *__pyx_n_s__protocol;
  961. static PyObject *__pyx_n_s__random;
  962. static PyObject *__pyx_n_s__randrange;
  963. static PyObject *__pyx_n_s__range;
  964. static PyObject *__pyx_n_s__recv;
  965. static PyObject *__pyx_n_s__register;
  966. static PyObject *__pyx_n_s__send;
  967. static PyObject *__pyx_n_s__setsockopt;
  968. static PyObject *__pyx_n_s__socket_type;
  969. static PyObject *__pyx_n_s__struct;
  970. static PyObject *__pyx_n_s__sys;
  971. static PyObject *__pyx_n_s__time;
  972. static PyObject *__pyx_n_s__timeout;
  973. static PyObject *__pyx_n_s__track;
  974. static PyObject *__pyx_n_s__tracker;
  975. static PyObject *__pyx_n_s__typecode;
  976. static PyObject *__pyx_n_s__u;
  977. static PyObject *__pyx_n_s__unicode;
  978. static PyObject *__pyx_n_s__upper;
  979. static PyObject *__pyx_n_s__xrange;
  980. static PyObject *__pyx_n_s__zmq;
  981. static PyObject *__pyx_int_0;
  982. static PyObject *__pyx_int_neg_1;
  983. static PyObject *__pyx_int_100;
  984. static PyObject *__pyx_int_49152;
  985. static PyObject *__pyx_int_65536;
  986. static PyObject *__pyx_k_1;
  987. static PyObject *__pyx_k_18;
  988. static PyObject *__pyx_k_19;
  989. static PyObject *__pyx_k_24;
  990. static PyObject *__pyx_k_25;
  991. static PyObject *__pyx_k_26;
  992. static PyObject *__pyx_k_27;
  993. static PyObject *__pyx_k_28;
  994. static PyObject *__pyx_k_29;
  995. static PyObject *__pyx_k_30;
  996. static PyObject *__pyx_k_tuple_3;
  997. static PyObject *__pyx_k_tuple_8;
  998. static PyObject *__pyx_k_tuple_12;
  999. static PyObject *__pyx_k_tuple_16;
  1000. static PyObject *__pyx_k_tuple_17;
  1001. static PyObject *__pyx_k_tuple_21;
  1002. static PyObject *__pyx_k_tuple_23;
  1003. static PyObject *__pyx_k_tuple_32;
  1004. static PyObject *__pyx_k_tuple_34;
  1005. static PyObject *__pyx_k_tuple_35;
  1006. static PyObject *__pyx_k_tuple_39;
  1007. static PyObject *__pyx_k_tuple_41;
  1008. /* "zmq/core/socket.pyx":77
  1009. * # true methods frequently cannot be inlined, acc. Cython docs
  1010. *
  1011. * cdef inline _check_closed(Socket s, bint raise_notsup): # <<<<<<<<<<<<<<
  1012. * cdef int rc
  1013. * cdef int errno
  1014. */
  1015. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__check_closed(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_s, int __pyx_v_raise_notsup) {
  1016. int __pyx_v_rc;
  1017. int __pyx_v_stype;
  1018. size_t __pyx_v_sz;
  1019. PyObject *__pyx_r = NULL;
  1020. __Pyx_RefNannyDeclarations
  1021. PyObject *__pyx_t_1 = NULL;
  1022. PyObject *__pyx_t_2 = NULL;
  1023. PyObject *__pyx_t_3 = NULL;
  1024. int __pyx_t_4;
  1025. int __pyx_t_5;
  1026. int __pyx_lineno = 0;
  1027. const char *__pyx_filename = NULL;
  1028. int __pyx_clineno = 0;
  1029. __Pyx_RefNannySetupContext("_check_closed");
  1030. /* "zmq/core/socket.pyx":81
  1031. * cdef int errno
  1032. * cdef int stype
  1033. * cdef size_t sz=sizeof(int) # <<<<<<<<<<<<<<
  1034. * if s._closed:
  1035. * if raise_notsup:
  1036. */
  1037. __pyx_v_sz = (sizeof(int));
  1038. /* "zmq/core/socket.pyx":82
  1039. * cdef int stype
  1040. * cdef size_t sz=sizeof(int)
  1041. * if s._closed: # <<<<<<<<<<<<<<
  1042. * if raise_notsup:
  1043. * raise ZMQError(ENOTSUP)
  1044. */
  1045. if (__pyx_v_s->_closed) {
  1046. /* "zmq/core/socket.pyx":83
  1047. * cdef size_t sz=sizeof(int)
  1048. * if s._closed:
  1049. * if raise_notsup: # <<<<<<<<<<<<<<
  1050. * raise ZMQError(ENOTSUP)
  1051. * else:
  1052. */
  1053. if (__pyx_v_raise_notsup) {
  1054. /* "zmq/core/socket.pyx":84
  1055. * if s._closed:
  1056. * if raise_notsup:
  1057. * raise ZMQError(ENOTSUP) # <<<<<<<<<<<<<<
  1058. * else:
  1059. * return True
  1060. */
  1061. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1062. __Pyx_GOTREF(__pyx_t_1);
  1063. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSUP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1064. __Pyx_GOTREF(__pyx_t_2);
  1065. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1066. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  1067. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  1068. __Pyx_GIVEREF(__pyx_t_2);
  1069. __pyx_t_2 = 0;
  1070. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1071. __Pyx_GOTREF(__pyx_t_2);
  1072. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1073. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  1074. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  1075. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1076. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1077. goto __pyx_L4;
  1078. }
  1079. /*else*/ {
  1080. /* "zmq/core/socket.pyx":86
  1081. * raise ZMQError(ENOTSUP)
  1082. * else:
  1083. * return True # <<<<<<<<<<<<<<
  1084. * else:
  1085. * rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)
  1086. */
  1087. __Pyx_XDECREF(__pyx_r);
  1088. __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1089. __Pyx_GOTREF(__pyx_t_2);
  1090. __pyx_r = __pyx_t_2;
  1091. __pyx_t_2 = 0;
  1092. goto __pyx_L0;
  1093. }
  1094. __pyx_L4:;
  1095. goto __pyx_L3;
  1096. }
  1097. /*else*/ {
  1098. /* "zmq/core/socket.pyx":88
  1099. * return True
  1100. * else:
  1101. * rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz) # <<<<<<<<<<<<<<
  1102. * if rc and zmq_errno() == ENOTSOCK:
  1103. * s._closed = True
  1104. */
  1105. __pyx_v_rc = zmq_getsockopt(__pyx_v_s->handle, ZMQ_TYPE, ((void *)(&__pyx_v_stype)), (&__pyx_v_sz));
  1106. /* "zmq/core/socket.pyx":89
  1107. * else:
  1108. * rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)
  1109. * if rc and zmq_errno() == ENOTSOCK: # <<<<<<<<<<<<<<
  1110. * s._closed = True
  1111. * if raise_notsup:
  1112. */
  1113. if (__pyx_v_rc) {
  1114. __pyx_t_2 = PyInt_FromLong(zmq_errno()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1115. __Pyx_GOTREF(__pyx_t_2);
  1116. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSOCK); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1117. __Pyx_GOTREF(__pyx_t_3);
  1118. __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1119. __Pyx_GOTREF(__pyx_t_1);
  1120. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1121. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1122. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1123. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1124. __pyx_t_5 = __pyx_t_4;
  1125. } else {
  1126. __pyx_t_5 = __pyx_v_rc;
  1127. }
  1128. if (__pyx_t_5) {
  1129. /* "zmq/core/socket.pyx":90
  1130. * rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)
  1131. * if rc and zmq_errno() == ENOTSOCK:
  1132. * s._closed = True # <<<<<<<<<<<<<<
  1133. * if raise_notsup:
  1134. * raise ZMQError(ENOTSUP)
  1135. */
  1136. __pyx_v_s->_closed = 1;
  1137. /* "zmq/core/socket.pyx":91
  1138. * if rc and zmq_errno() == ENOTSOCK:
  1139. * s._closed = True
  1140. * if raise_notsup: # <<<<<<<<<<<<<<
  1141. * raise ZMQError(ENOTSUP)
  1142. * else:
  1143. */
  1144. if (__pyx_v_raise_notsup) {
  1145. /* "zmq/core/socket.pyx":92
  1146. * s._closed = True
  1147. * if raise_notsup:
  1148. * raise ZMQError(ENOTSUP) # <<<<<<<<<<<<<<
  1149. * else:
  1150. * return True
  1151. */
  1152. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1153. __Pyx_GOTREF(__pyx_t_1);
  1154. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSUP); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1155. __Pyx_GOTREF(__pyx_t_3);
  1156. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1157. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  1158. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  1159. __Pyx_GIVEREF(__pyx_t_3);
  1160. __pyx_t_3 = 0;
  1161. __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1162. __Pyx_GOTREF(__pyx_t_3);
  1163. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1164. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  1165. __Pyx_Raise(__pyx_t_

Large files files are truncated, but you can click here to view the full file