Commit 43744711 authored by Robert Bradshaw's avatar Robert Bradshaw

Use cython.operator for operators.

parent 1d5d18ff
......@@ -325,12 +325,16 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
"""
unop_method_nodes = {
'typeof': TypeofNode,
'operator.address': AmpersandNode,
'operator.dereference': DereferenceNode,
'operator.preincrement' : inc_dec_constructor(True, '++'),
'operator.predecrement' : inc_dec_constructor(True, '--'),
'operator.postincrement': inc_dec_constructor(False, '++'),
'operator.postdecrement': inc_dec_constructor(False, '--'),
# For backwards compatability.
'address': AmpersandNode,
'dereference': DereferenceNode,
'preincrement' : inc_dec_constructor(True, '++'),
'predecrement' : inc_dec_constructor(True, '--'),
'postincrement': inc_dec_constructor(False, '++'),
'postdecrement': inc_dec_constructor(False, '--'),
}
special_methods = set(['declare', 'union', 'struct', 'typedef', 'sizeof', 'cast', 'pointer', 'compiled', 'NULL']
......@@ -379,10 +383,9 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
self.cython_module_names.add(modname)
elif node.module_name.startswith(u"cython."):
if node.as_name:
modname = node.as_name
self.directive_names[node.as_name] = node.module_name[7:]
else:
modname = u"cython"
self.directive_names[modname] = node.module_name[7:]
self.cython_module_names.add(u"cython")
else:
return node
......@@ -393,6 +396,8 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
elif node.module_name == u"cython":
is_cython_module = True
submodule = u""
else:
is_cython_module = False
if is_cython_module:
newimp = []
for pos, name, as_name, kind in node.imported_names:
......@@ -420,6 +425,8 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
elif node.module.module_name.value == u"cython":
is_cython_module = True
submodule = u""
else:
is_cython_module = False
if is_cython_module:
newimp = []
for name, name_node in node.items:
......
cimport cython
from cython cimport dereference as deref
cimport cython.operator
from cython.operator cimport dereference as deref
cdef extern from "cpp_operators_helper.h":
cdef cppclass TestOps:
......@@ -61,10 +61,10 @@ def test_incdec():
post --
"""
cdef TestOps* t = new TestOps()
print cython.preincrement(t[0])
print cython.predecrement(t[0])
print cython.postincrement(t[0])
print cython.postdecrement(t[0])
print cython.operator.preincrement(t[0])
print cython.operator.predecrement(t[0])
print cython.operator.postincrement(t[0])
print cython.operator.postdecrement(t[0])
del t
def test_binop():
......
from cython import dereference as deref
from cython.operator import dereference as deref
cdef extern from "cpp_templates_helper.h":
cdef cppclass Wrap[T]:
......
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