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]: ...@@ -486,10 +486,9 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
# cython doesn't enforce async as a keyword # cython doesn't enforce async as a keyword
async = async_ async = async_
#ifdef _WIN32
#else
def child(self, int pid, bint trace=0, ref=True): 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) return child(self, pid, trace, ref)
def install_sigchld(self): def install_sigchld(self):
...@@ -498,8 +497,6 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: ...@@ -498,8 +497,6 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
def reset_sigchld(self): def reset_sigchld(self):
libev.gevent_reset_sigchld_handler() libev.gevent_reset_sigchld_handler()
#endif
def stat(self, str path, float interval=0.0, ref=True, priority=None): def stat(self, str path, float interval=0.0, ref=True, priority=None):
return stat(self, path, interval, ref, priority) return stat(self, path, interval, ref, priority)
...@@ -963,14 +960,13 @@ cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsyn ...@@ -963,14 +960,13 @@ cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsyn
async = async_ async = async_
#ifdef _WIN32
#else
cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]: cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]:
WATCHER(child) WATCHER(child)
def __cinit__(self, loop loop, int pid, bint trace=0, ref=True): 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: if not loop.default:
raise TypeError('child watchers are only available on the default loop') raise TypeError('child watchers are only available on the default loop')
libev.gevent_install_sigchld_handler() libev.gevent_install_sigchld_handler()
...@@ -1003,8 +999,6 @@ cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild ...@@ -1003,8 +999,6 @@ cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild
def rstatus(self, int value): def rstatus(self, int value):
self._watcher.rstatus = value self._watcher.rstatus = value
#endif
cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]:
......
...@@ -62,5 +62,10 @@ static void gevent_reset_sigchld_handler(void) { ...@@ -62,5 +62,10 @@ static void gevent_reset_sigchld_handler(void) {
#define gevent_ev_default_loop ev_default_loop #define gevent_ev_default_loop ev_default_loop
static void gevent_install_sigchld_handler(void) { } 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 */ #endif /* _WIN32 */
...@@ -61,6 +61,9 @@ cython_header_re = re.compile(r'^/\* (generated by cython [^\s*]+)[^*]+\*/$', re ...@@ -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.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' #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): class Configuration(frozenset):
""" """
A set of CPP conditions that apply to a given sequence A set of CPP conditions that apply to a given sequence
...@@ -74,11 +77,12 @@ class Configuration(frozenset): ...@@ -74,11 +77,12 @@ class Configuration(frozenset):
def __new__(cls, iterable): def __new__(cls, iterable):
sorted_iterable = tuple(sorted(frozenset(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 sorted_iterable not in cls._cache:
if not all(isinstance(x, Condition) for x in sorted_iterable): if not all(isinstance(x, Condition) for x in sorted_iterable):
raise TypeError("Must be iterable of conditions") raise TypeError("Must be iterable of conditions")
if not sorted_iterable:
raise TypeError("Empty configurations not allowed")
self = frozenset.__new__(cls, sorted_iterable) self = frozenset.__new__(cls, sorted_iterable)
self._sorted = sorted_iterable self._sorted = sorted_iterable
cls._cache[sorted_iterable] = self cls._cache[sorted_iterable] = self
...@@ -92,7 +96,11 @@ class Configuration(frozenset): ...@@ -92,7 +96,11 @@ class Configuration(frozenset):
return self.union(conditions) return self.union(conditions)
def difference(self, other): 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): def __sub__(self, other):
return self.difference(other) return self.difference(other)
...@@ -377,6 +385,13 @@ class ConfigurationGroups(tuple): ...@@ -377,6 +385,13 @@ class ConfigurationGroups(tuple):
if self._simplified: if self._simplified:
return self 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)): for tag1, tag2 in sorted(combinations(self, 2)):
if tag1 == tag2: if tag1 == tag2:
tags = list(self) tags = list(self)
...@@ -385,6 +400,8 @@ class ConfigurationGroups(tuple): ...@@ -385,6 +400,8 @@ class ConfigurationGroups(tuple):
for condition in tag1: for condition in tag1:
inverted_condition = condition.inverted() inverted_condition = condition.inverted()
if inverted_condition == tag2:
continue
if inverted_condition in tag2: if inverted_condition in tag2:
tag1_copy = tag1 - {inverted_condition} tag1_copy = tag1 - {inverted_condition}
tag2_copy = tag2 - {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