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
e352a0b3
Commit
e352a0b3
authored
Oct 10, 2007
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rdef keyword for overridable methods
parent
bc3427ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
14 deletions
+21
-14
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-7
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+17
-6
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+1
-1
No files found.
Cython/Compiler/Nodes.py
View file @
e352a0b3
...
...
@@ -714,9 +714,7 @@ class CFuncDefNode(FuncDefNode):
defining
=
self
.
body
is
not
None
)
self
.
return_type
=
type
.
return_type
if
'overrideable'
in
self
.
modifiers
or
'visible'
in
self
.
modifiers
:
if
'visible'
in
self
.
modifiers
:
self
.
modifiers
.
remove
(
'visible'
)
if
self
.
overridable
:
import
ExprNodes
arg_names
=
[
arg
.
name
for
arg
in
self
.
type
.
args
]
self_arg
=
ExprNodes
.
NameNode
(
self
.
pos
,
name
=
arg_names
[
0
])
...
...
@@ -735,10 +733,8 @@ class CFuncDefNode(FuncDefNode):
env
.
entries
[
name
]
=
self
.
entry
if
Options
.
intern_names
:
self
.
py_func
.
interned_attr_cname
=
env
.
intern
(
self
.
py_func
.
entry
.
name
)
if
'overrideable'
in
self
.
modifiers
:
self
.
modifiers
.
remove
(
'overrideable'
)
self
.
override
=
OverrideCheckNode
(
self
.
pos
,
py_func
=
self
.
py_func
)
self
.
body
.
stats
.
insert
(
0
,
self
.
override
)
self
.
override
=
OverrideCheckNode
(
self
.
pos
,
py_func
=
self
.
py_func
)
self
.
body
.
stats
.
insert
(
0
,
self
.
override
)
def
declare_arguments
(
self
,
env
):
...
...
Cython/Compiler/Parsing.py
View file @
e352a0b3
...
...
@@ -1211,11 +1211,19 @@ def p_statement(s, level, cdef_flag = 0, visibility = 'private'):
return
p_ctypedef_statement
(
s
,
level
,
visibility
)
if
s
.
sy
==
'cdef'
:
cdef_flag
=
1
overridable
=
0
s
.
next
()
if
s
.
sy
==
'rdef'
:
cdef_flag
=
1
overridable
=
1
s
.
next
()
if
cdef_flag
:
if
level
not
in
(
'module'
,
'module_pxd'
,
'function'
,
'c_class'
,
'c_class_pxd'
):
s
.
error
(
'cdef statement not allowed here'
)
return
p_cdef_statement
(
s
,
level
,
visibility
)
return
p_cdef_statement
(
s
,
level
,
visibility
,
overridable
=
overridable
)
# elif s.sy == 'rdef':
# s.next()
# return p_c_func_or_var_declaration(s, level, s.position(), visibility = visibility, overridable = True)
elif
s
.
sy
==
'def'
:
if
level
not
in
(
'module'
,
'class'
,
'c_class'
,
'property'
):
s
.
error
(
'def statement not allowed here'
)
...
...
@@ -1570,8 +1578,10 @@ def p_c_arg_decl(s, in_pyfunc, cmethod_flag = 0, kw_only = 0):
default
=
default
,
kw_only
=
kw_only
)
def
p_cdef_statement
(
s
,
level
,
visibility
=
'private'
):
def
p_cdef_statement
(
s
,
level
,
visibility
=
'private'
,
overridable
=
False
):
pos
=
s
.
position
()
if
overridable
and
level
not
in
(
'c_class'
,
'c_class_pxd'
):
error
(
pos
,
"Overridable cdef function not allowed here"
)
visibility
=
p_visibility
(
s
,
visibility
)
if
visibility
==
'extern'
and
s
.
sy
in
(
'from'
,
':'
):
return
p_cdef_extern_block
(
s
,
level
,
pos
)
...
...
@@ -1593,7 +1603,7 @@ def p_cdef_statement(s, level, visibility = 'private'):
s
.
expect_newline
(
'Expected a newline'
)
return
node
else
:
return
p_c_func_or_var_declaration
(
s
,
level
,
pos
,
visibility
)
return
p_c_func_or_var_declaration
(
s
,
level
,
pos
,
visibility
,
overridable
)
def
p_cdef_extern_block
(
s
,
level
,
pos
):
include_file
=
None
...
...
@@ -1698,13 +1708,13 @@ def p_visibility(s, prev_visibility):
return
visibility
def
p_c_modifiers
(
s
):
if
s
.
sy
==
'IDENT'
and
s
.
systring
in
(
'inline'
,
'visible'
,
'overrideable'
):
if
s
.
sy
==
'IDENT'
and
s
.
systring
in
(
'inline'
,):
modifier
=
s
.
systring
s
.
next
()
return
[
modifier
]
+
p_c_modifiers
(
s
)
return
[]
def
p_c_func_or_var_declaration
(
s
,
level
,
pos
,
visibility
=
'private'
):
def
p_c_func_or_var_declaration
(
s
,
level
,
pos
,
visibility
=
'private'
,
overridable
=
False
):
cmethod_flag
=
level
in
(
'c_class'
,
'c_class_pxd'
)
modifiers
=
p_c_modifiers
(
s
)
base_type
=
p_c_base_type
(
s
)
...
...
@@ -1718,7 +1728,8 @@ def p_c_func_or_var_declaration(s, level, pos, visibility = 'private'):
base_type
=
base_type
,
declarator
=
declarator
,
body
=
suite
,
modifiers
=
modifiers
)
modifiers
=
modifiers
,
overridable
=
overridable
)
else
:
if
level
==
'module_pxd'
and
visibility
<>
'extern'
:
error
(
pos
,
...
...
Cython/Compiler/Scanning.py
View file @
e352a0b3
...
...
@@ -138,7 +138,7 @@ reserved_words = [
"raise"
,
"import"
,
"exec"
,
"try"
,
"except"
,
"finally"
,
"while"
,
"if"
,
"elif"
,
"else"
,
"for"
,
"in"
,
"assert"
,
"and"
,
"or"
,
"not"
,
"is"
,
"in"
,
"lambda"
,
"from"
,
"NULL"
,
"cimport"
,
"by"
,
"with"
"NULL"
,
"cimport"
,
"by"
,
"with"
,
"rdef"
]
function_contexts
=
[
# allowed arguments to the "with" option
...
...
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