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
Gwenaël Samain
cython
Commits
f719d11c
Commit
f719d11c
authored
Jan 14, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generalize unop cython special methods.
parent
7de6fd50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+13
-12
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
f719d11c
...
...
@@ -323,7 +323,13 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
duplication of functionality has to occur: We manually track cimports
and which names the "cython" module may have been imported to.
"""
special_methods
=
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
'typeof'
,
'cast'
,
'address'
,
'pointer'
,
'compiled'
,
'NULL'
])
unop_method_nodes
=
{
'typeof'
:
TypeofNode
,
'address'
:
AmpersandNode
,
}
special_methods
=
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
'cast'
,
'pointer'
,
'compiled'
,
'NULL'
]
+
unop_method_nodes
.
keys
())
def
__init__
(
self
,
context
,
compilation_directive_defaults
):
super
(
InterpretCompilerDirectives
,
self
).
__init__
(
context
)
...
...
@@ -998,7 +1004,12 @@ class TransformBuiltinMethods(EnvTransform):
# cython.foo
function
=
node
.
function
.
as_cython_attribute
()
if
function
:
if
function
==
u'cast'
:
if
function
in
InterpretCompilerDirectives
.
unop_method_nodes
:
if
len
(
node
.
args
)
!=
1
:
error
(
node
.
function
.
pos
,
u"%s() takes exactly one argument"
%
function
)
else
:
node
=
InterpretCompilerDirectives
.
unop_method_nodes
[
function
](
node
.
function
.
pos
,
operand
=
node
.
args
[
0
])
elif
function
==
u'cast'
:
if
len
(
node
.
args
)
!=
2
:
error
(
node
.
function
.
pos
,
u"cast() takes exactly two arguments"
)
else
:
...
...
@@ -1016,16 +1027,6 @@ class TransformBuiltinMethods(EnvTransform):
node
=
SizeofTypeNode
(
node
.
function
.
pos
,
arg_type
=
type
)
else
:
node
=
SizeofVarNode
(
node
.
function
.
pos
,
operand
=
node
.
args
[
0
])
elif
function
==
'typeof'
:
if
len
(
node
.
args
)
!=
1
:
error
(
node
.
function
.
pos
,
u"typeof() takes exactly one argument"
%
function
)
else
:
node
=
TypeofNode
(
node
.
function
.
pos
,
operand
=
node
.
args
[
0
])
elif
function
==
'address'
:
if
len
(
node
.
args
)
!=
1
:
error
(
node
.
function
.
pos
,
u"address() takes exactly one argument"
%
function
)
else
:
node
=
AmpersandNode
(
node
.
function
.
pos
,
operand
=
node
.
args
[
0
])
elif
function
==
'cmod'
:
if
len
(
node
.
args
)
!=
2
:
error
(
node
.
function
.
pos
,
u"cmod() takes exactly one argument"
%
function
)
...
...
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