Commit cdc1d6dd authored by Jason Madden's avatar Jason Madden

Start breaking apart the WATCHER macro to share code.

Move to the safer __cinit__ for all watchers.

Now that the base watcher has access to its libev ev_watcher pointer, start moving the properties there, starting with ref.
parent 045afd00
...@@ -179,11 +179,16 @@ static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallback ...@@ -179,11 +179,16 @@ static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallback
Py_DECREF(loop); Py_DECREF(loop);
} }
/*
* PyGeventWatcherObject is the first member of all the structs, so
* it is the same in all of them and they can all safely be cast to
* it. We could also use the *data member of the libev watcher objects.
*/
#undef DEFINE_CALLBACK #undef DEFINE_CALLBACK
#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ #define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \
static void gevent_callback_##WATCHER_LC(struct ev_loop *_loop, void *c_watcher, int revents) { \ static void gevent_callback_##WATCHER_LC(struct ev_loop *_loop, void *c_watcher, int revents) { \
struct PyGevent##WATCHER_TYPE##Object* watcher = GET_OBJECT(PyGevent##WATCHER_TYPE##Object, c_watcher, _watcher); \ struct PyGeventWatcherObject* watcher = GET_OBJECT(PyGevent##WATCHER_TYPE##Object, c_watcher, _watcher); \
gevent_callback(watcher->loop, watcher->_callback, watcher->args, (PyObject*)watcher, c_watcher, revents); \ gevent_callback(watcher->loop, watcher->_callback, watcher->args, (PyObject*)watcher, c_watcher, revents); \
} }
......
This diff is collapsed.
...@@ -87,6 +87,9 @@ cdef extern from "libev.h": ...@@ -87,6 +87,9 @@ cdef extern from "libev.h":
int sigfd int sigfd
unsigned int origflags unsigned int origflags
struct ev_watcher:
void* data;
struct ev_io: struct ev_io:
int fd int fd
int events int events
......
...@@ -15,6 +15,7 @@ import subprocess ...@@ -15,6 +15,7 @@ import subprocess
import multiprocessing import multiprocessing
import tempfile import tempfile
import shutil import shutil
from collections import OrderedDict
import threading import threading
...@@ -376,7 +377,7 @@ class ConfigurationGroups(tuple): ...@@ -376,7 +377,7 @@ class ConfigurationGroups(tuple):
if self._simplified: if self._simplified:
return self return self
for tag1, tag2 in combinations(self, 2): for tag1, tag2 in sorted(combinations(self, 2)):
if tag1 == tag2: if tag1 == tag2:
tags = list(self) tags = list(self)
tags.remove(tag1) tags.remove(tag1)
...@@ -555,7 +556,7 @@ def preprocess_filename(filename, config): ...@@ -555,7 +556,7 @@ def preprocess_filename(filename, config):
""" """
linecount = 0 linecount = 0
current_name = None current_name = None
definitions = {} definitions = OrderedDict()
result = [] result = []
including_section = [] including_section = []
with open(filename) as f: with open(filename) as f:
......
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