Commit ea0bd827 authored by Jason Madden's avatar Jason Madden

We should be able to use dummy functions to link the child watchers on...

We should be able to use dummy functions to link the child watchers on windows, and forbid them from being created. This gets us down to only one CPP def, LIBEV_EMBED
parent e25f1a0a
......@@ -486,10 +486,9 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
# cython doesn't enforce async as a keyword
async = async_
#ifdef _WIN32
#else
def child(self, int pid, bint trace=0, ref=True):
if sys.platform == 'win32':
raise AttributeError("Child watchers are not supported on Windows")
return child(self, pid, trace, ref)
def install_sigchld(self):
......@@ -498,8 +497,6 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
def reset_sigchld(self):
libev.gevent_reset_sigchld_handler()
#endif
def stat(self, str path, float interval=0.0, ref=True, priority=None):
return stat(self, path, interval, ref, priority)
......@@ -963,14 +960,13 @@ cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsyn
async = async_
#ifdef _WIN32
#else
cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]:
WATCHER(child)
def __cinit__(self, loop loop, int pid, bint trace=0, ref=True):
if sys.platform == 'win32':
raise AttributeError("Child watchers are not supported on Windows")
if not loop.default:
raise TypeError('child watchers are only available on the default loop')
libev.gevent_install_sigchld_handler()
......@@ -1003,8 +999,6 @@ cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild
def rstatus(self, int value):
self._watcher.rstatus = value
#endif
cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]:
......
......@@ -62,5 +62,10 @@ static void gevent_reset_sigchld_handler(void) {
#define gevent_ev_default_loop ev_default_loop
static void gevent_install_sigchld_handler(void) { }
static void gevent_reset_sigchld_handler(void) { }
// Fake child functions that we can link to.
static void ev_child_start(struct ev_loop* loop, ev_child* w) {};
static void ev_child_stop(struct ev_loop* loop, ev_child* w) {};
#endif /* _WIN32 */
......@@ -61,6 +61,9 @@ cython_header_re = re.compile(r'^/\* (generated by cython [^\s*]+)[^*]+\*/$', re
#assert cython_header_re.match('/* Generated by Cython 0.21.1 */').group(1) == 'Generated by Cython 0.21.1'
#assert cython_header_re.match('/* Generated by Cython 0.19 on 55-555-555 */').group(1) == 'Generated by Cython 0.19'
class EmptyConfigurationError(TypeError):
pass
class Configuration(frozenset):
"""
A set of CPP conditions that apply to a given sequence
......@@ -74,11 +77,12 @@ class Configuration(frozenset):
def __new__(cls, iterable):
sorted_iterable = tuple(sorted(frozenset(iterable)))
if not sorted_iterable:
raise EmptyConfigurationError("Empty configurations not allowed")
if sorted_iterable not in cls._cache:
if not all(isinstance(x, Condition) for x in sorted_iterable):
raise TypeError("Must be iterable of conditions")
if not sorted_iterable:
raise TypeError("Empty configurations not allowed")
self = frozenset.__new__(cls, sorted_iterable)
self._sorted = sorted_iterable
cls._cache[sorted_iterable] = self
......@@ -92,7 +96,11 @@ class Configuration(frozenset):
return self.union(conditions)
def difference(self, other):
return Configuration(frozenset.difference(self, other))
try:
return Configuration(frozenset.difference(self, other))
except EmptyConfigurationError:
raise EmptyConfigurationError(
"Couldn't subtract %r from %r" % (self, other))
def __sub__(self, other):
return self.difference(other)
......@@ -377,6 +385,13 @@ class ConfigurationGroups(tuple):
if self._simplified:
return self
if (len(self) == 2
and len(self[0]) == len(self[1]) == 1
and list(self[0])[0] == list(self[1])[0].inverted()):
# This trivially simplifies to the empty group
# Its defined(foo, True) || defined(foo, False)
return ConfigurationGroups(()).simplify_tags()
for tag1, tag2 in sorted(combinations(self, 2)):
if tag1 == tag2:
tags = list(self)
......@@ -385,6 +400,8 @@ class ConfigurationGroups(tuple):
for condition in tag1:
inverted_condition = condition.inverted()
if inverted_condition == tag2:
continue
if inverted_condition in tag2:
tag1_copy = tag1 - {inverted_condition}
tag2_copy = tag2 - {inverted_condition}
......
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