提交 11c7bab8 authored 作者: James Bergstra's avatar James Bergstra

added is_valid_value to the Type interface

上级 70c02dbb
...@@ -218,6 +218,10 @@ class PureType(object): ...@@ -218,6 +218,10 @@ class PureType(object):
""" """
raise AbstractFunctionError() raise AbstractFunctionError()
def is_valid_value(self, a):
"""Required: Return True for any python object `a` that would be a legal value for a Result of this Type"""
raise AbstractFunctionError()
def make_result(self, name = None): def make_result(self, name = None):
"""Return a new `Result` instance of Type `self`. """Return a new `Result` instance of Type `self`.
...@@ -325,6 +329,9 @@ class Generic(SingletonType): ...@@ -325,6 +329,9 @@ class Generic(SingletonType):
def filter(self, data, strict = False): def filter(self, data, strict = False):
return data return data
def is_valid_value(self, a):
return True
def c_declare(self, name, sub): def c_declare(self, name, sub):
return """ return """
PyObject* %(name)s; PyObject* %(name)s;
...@@ -348,6 +355,7 @@ class Generic(SingletonType): ...@@ -348,6 +355,7 @@ class Generic(SingletonType):
Py_XINCREF(py_%(name)s); Py_XINCREF(py_%(name)s);
""" % locals() """ % locals()
generic = Generic() generic = Generic()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论