Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
43744711
Commit
43744711
authored
Feb 03, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use cython.operator for operators.
parent
1d5d18ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
15 deletions
+22
-15
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+15
-8
tests/run/cpp_operators.pyx
tests/run/cpp_operators.pyx
+6
-6
tests/run/cpp_templates.pyx
tests/run/cpp_templates.pyx
+1
-1
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
43744711
...
...
@@ -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
:
...
...
tests/run/cpp_operators.pyx
View file @
43744711
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
():
...
...
tests/run/cpp_templates.pyx
View file @
43744711
from
cython
import
dereference
as
deref
from
cython
.operator
import
dereference
as
deref
cdef
extern
from
"cpp_templates_helper.h"
:
cdef
cppclass
Wrap
[
T
]:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment