* from the other direction. If a Python thread calls a C function
* Py_BEGIN_ALLOW_THREADS is used to allow other python threads to run because
* we don't intend to call any Python functions.
* from the other direction. If a Python thread calls a C function
* Py_BEGIN_ALLOW_THREADS is used to allow other python threads to run because
* we don't intend to call any Python functions.
* These two macros are used whenever a C thread intends to call some Python
* function, usually because some registered callback was triggered.
* Just like Py_BEGIN_ALLOW_THREADS it opens a block so these macros have to be
* These two macros are used whenever a C thread intends to call some Python
* function, usually because some registered callback was triggered.
* Just like Py_BEGIN_ALLOW_THREADS it opens a block so these macros have to be
- * used in pairs. They acquire the GIL, create a new Python thread state and swap
- * the current thread state with the new one. This means this thread is now allowed
+ * used in pairs. They acquire the GIL, create a new Python thread state and
+ * swap
+ * the current thread state with the new one. This means this thread is now
+ * allowed
-#define CPY_LOCK_THREADS {\
- PyGILState_STATE gil_state;\
- gil_state = PyGILState_Ensure();
+#define CPY_LOCK_THREADS \
+ { \
+ PyGILState_STATE gil_state; \
+ gil_state = PyGILState_Ensure();
* This calling syntax is less than elegant but it works, saves
* a lot of lines and avoids potential refcount errors. */
* This calling syntax is less than elegant but it works, saves
* a lot of lines and avoids potential refcount errors. */
-#define CPY_SUBSTITUTE(func, a, ...) do {\
- if ((a) != NULL) {\
- PyObject *__tmp = (a);\
- (a) = func(__VA_ARGS__);\
- Py_DECREF(__tmp);\
- }\
-} while(0)
+#define CPY_SUBSTITUTE(func, a, ...) \
+ do { \
+ if ((a) != NULL) { \
+ PyObject *__tmp = (a); \
+ (a) = func(__VA_ARGS__); \
+ Py_DECREF(__tmp); \
+ } \
+ } while (0)
/* Python3 compatibility layer. To keep the actual code as clean as possible
* do a lot of defines here. */
/* Python3 compatibility layer. To keep the actual code as clean as possible
* do a lot of defines here. */
#define IS_BYTES_OR_UNICODE(o) (PyUnicode_Check(o) || PyString_Check(o))
#define CPY_STRCAT_AND_DEL PyString_ConcatAndDel
#define CPY_STRCAT PyString_Concat
#define IS_BYTES_OR_UNICODE(o) (PyUnicode_Check(o) || PyString_Check(o))
#define CPY_STRCAT_AND_DEL PyString_ConcatAndDel
#define CPY_STRCAT PyString_Concat
- if (PyUnicode_Check(*o)) {
- PyObject *tmp;
- tmp = PyUnicode_AsEncodedString(*o, NULL, NULL); /* New reference. */
- if (tmp == NULL)
- return NULL;
- Py_DECREF(*o);
- *o = tmp;
- }
+ if (PyUnicode_Check(*o)) {
+ PyObject *tmp;
+ tmp = PyUnicode_AsEncodedString(*o, NULL, NULL); /* New reference. */
+ if (tmp == NULL)
+ return NULL;
+ Py_DECREF(*o);
+ *o = tmp;
+ }
-/* Python3 preferrs unicode */
- PyObject *ret;
- ret = PyUnicode_Decode(buf, strlen(buf), NULL, NULL);
- if (ret != NULL)
- return ret;
- PyErr_Clear();
- return PyBytes_FromString(buf);
+ /* Python3 preferrs unicode */
+ PyObject *ret;
+ ret = PyUnicode_Decode(buf, strlen(buf), NULL, NULL);
+ if (ret != NULL)
+ return ret;
+ PyErr_Clear();
+ return PyBytes_FromString(buf);
- PyObject_HEAD /* No semicolon! */
- PyObject *parent; /* Config */
- PyObject *key; /* String */
- PyObject *values; /* Sequence */
- PyObject *children; /* Sequence */
+ // clang-format off
+ PyObject_HEAD /* No semicolon! */
+ PyObject *parent; /* Config */
+ PyObject *key; /* String */
+ PyObject *values; /* Sequence */
+ PyObject *children; /* Sequence */
+ // clang-format on
- PyObject_HEAD /* No semicolon! */
- double time;
- char host[DATA_MAX_NAME_LEN];
- char plugin[DATA_MAX_NAME_LEN];
- char plugin_instance[DATA_MAX_NAME_LEN];
- char type[DATA_MAX_NAME_LEN];
- char type_instance[DATA_MAX_NAME_LEN];
+ // clang-format off
+ PyObject_HEAD /* No semicolon! */
+ double time;
+ // clang-format on
+ char host[DATA_MAX_NAME_LEN];
+ char plugin[DATA_MAX_NAME_LEN];
+ char plugin_instance[DATA_MAX_NAME_LEN];
+ char type[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN];
-#define Notification_New() PyObject_CallFunctionObjArgs((PyObject *) &NotificationType, (void *) 0)
+#define Notification_New() \
+ PyObject_CallFunctionObjArgs((PyObject *)&NotificationType, (void *)0)
typedef PyLongObject Signed;
extern PyTypeObject SignedType;
typedef PyLongObject Unsigned;
extern PyTypeObject UnsignedType;
typedef PyLongObject Signed;
extern PyTypeObject SignedType;
typedef PyLongObject Unsigned;
extern PyTypeObject UnsignedType;