Commit 4e6e9f4d authored by Robert Bradshaw's avatar Robert Bradshaw

Fix CythonUtilityCode equality to avoid duplication.

parent 6224744e
...@@ -1302,6 +1302,7 @@ class CVarDefNode(StatNode): ...@@ -1302,6 +1302,7 @@ class CVarDefNode(StatNode):
if 'staticmethod' in env.directives: if 'staticmethod' in env.directives:
type.is_static_method = True type.is_static_method = True
if create_extern_wrapper: if create_extern_wrapper:
self.entry.type.create_to_py_utility_code(env)
self.entry.create_wrapper = True self.entry.create_wrapper = True
else: else:
if self.directive_locals: if self.directive_locals:
......
...@@ -87,6 +87,18 @@ class CythonUtilityCode(Code.UtilityCodeBase): ...@@ -87,6 +87,18 @@ class CythonUtilityCode(Code.UtilityCodeBase):
self.outer_module_scope = outer_module_scope self.outer_module_scope = outer_module_scope
self.compiler_directives = compiler_directives self.compiler_directives = compiler_directives
def __eq__(self, other):
if isinstance(other, CythonUtilityCode):
return self._equality_params() == other._equality_params()
else:
return False
def _equality_params(self):
return self.impl, self.outer_module_scope, self.compiler_directives
def __hash__(self):
return hash(self.impl)
def get_tree(self, entries_only=False, cython_scope=None): def get_tree(self, entries_only=False, cython_scope=None):
from .AnalysedTreeTransforms import AutoTestDictTransform from .AnalysedTreeTransforms import AutoTestDictTransform
# The AutoTestDictTransform creates the statement "__test__ = {}", # The AutoTestDictTransform creates the statement "__test__ = {}",
......
...@@ -8,13 +8,20 @@ from libc.math cimport sqrt ...@@ -8,13 +8,20 @@ from libc.math cimport sqrt
cdef void empty_cfunc(): cdef void empty_cfunc():
print "here" print "here"
# same signature
cdef void another_empty_cfunc():
print "there"
def call_empty_cfunc(): def call_empty_cfunc():
""" """
>>> call_empty_cfunc() >>> call_empty_cfunc()
here here
there
""" """
cdef object py_func = empty_cfunc cdef object py_func = empty_cfunc
py_func() py_func()
cdef object another_py_func = another_empty_cfunc
another_py_func()
cdef double square_c(double x): cdef double square_c(double x):
......
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