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
Kirill Smelkov
cython
Commits
38e9cde5
Commit
38e9cde5
authored
Aug 28, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline cdef class method support, see ticket #474
parent
1c187e8b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
4 deletions
+43
-4
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+9
-3
tests/run/cmethod_inline_T474.pxd
tests/run/cmethod_inline_T474.pxd
+3
-0
tests/run/cmethod_inline_T474.pyx
tests/run/cmethod_inline_T474.pyx
+29
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
38e9cde5
...
...
@@ -567,7 +567,8 @@ class PxdPostParse(CythonTransform, SkipDeclarations):
err
=
None
# allow these slots
if
isinstance
(
node
,
Nodes
.
CFuncDefNode
):
if
u'inline'
in
node
.
modifiers
and
self
.
scope_type
==
'pxd'
:
if
(
u'inline'
in
node
.
modifiers
and
self
.
scope_type
in
(
'pxd'
,
'cclass'
)):
node
.
inline_in_pxd
=
True
if
node
.
visibility
!=
'private'
:
err
=
self
.
ERR_NOGO_WITH_INLINE
%
node
.
visibility
...
...
Cython/Compiler/Symtab.py
View file @
38e9cde5
...
...
@@ -70,7 +70,8 @@ class Entry(object):
# is_cmethod boolean Is a C method of an extension type
# is_builtin_cmethod boolean Is a C method of a builtin type (implies is_cmethod)
# is_unbound_cmethod boolean Is an unbound C method of an extension type
# is_final_cmethod boolean Is non-overridable C method
# is_final_cmethod boolean Is non-overridable C method
# is_inline_cmethod boolean Is inlined C method
# is_anonymous boolean Is a anonymous pyfunction entry
# is_type boolean Is a type definition
# is_cclass boolean Is an extension class
...
...
@@ -141,6 +142,7 @@ class Entry(object):
is_builtin_cmethod = False
is_unbound_cmethod = 0
is_final_cmethod = 0
is_inline_cmethod = 0
is_anonymous = 0
is_type = 0
is_cclass = 0
...
...
@@ -1821,7 +1823,9 @@ class CClassScope(ClassScope):
if
defining
:
entry
.
func_cname
=
self
.
mangle
(
Naming
.
func_prefix
,
name
)
entry
.
utility_code
=
utility_code
if
self
.
directives
.
get
(
'final'
):
if
u'inline'
in
modifiers
:
entry
.
is_inline_cmethod
=
True
if
self
.
directives
.
get
(
'final'
)
or
entry
.
is_inline_cmethod
:
entry
.
is_final_cmethod
=
True
entry
.
final_func_cname
=
entry
.
func_cname
return
entry
...
...
@@ -1884,7 +1888,9 @@ class CClassScope(ClassScope):
entry
.
is_inherited
=
1
if
base_entry
.
is_final_cmethod
:
entry
.
is_final_cmethod
=
True
if
self
.
parent_scope
==
base_scope
.
parent_scope
:
entry
.
is_inline_cmethod
=
base_entry
.
is_inline_cmethod
if
(
self
.
parent_scope
==
base_scope
.
parent_scope
or
entry
.
is_inline_cmethod
):
entry
.
final_func_cname
=
base_entry
.
final_func_cname
if
is_builtin
:
entry
.
is_builtin_cmethod
=
True
...
...
tests/run/cmethod_inline_T474.pxd
0 → 100644
View file @
38e9cde5
cdef
class
TestInlineMethod
(
object
):
cdef
inline
int
cdef
_inline_method
(
self
):
return
0
tests/run/cmethod_inline_T474.pyx
0 → 100644
View file @
38e9cde5
# mode: run
# ticket: 474
cimport
cython
cdef
class
TestInlineMethod
(
object
):
"""
>>> test = TestInlineMethod()
>>> test.test_cdef_method()
0
"""
@
cython
.
test_assert_path_exists
(
"//AttributeNode[@entry.is_final_cmethod=True]"
)
@
cython
.
test_assert_path_exists
(
"//AttributeNode[@entry.is_inline_cmethod=True]"
)
def
test_cdef_method
(
self
):
return
self
.
cdef
_inline_method
()
cdef
class
Subtyping
(
TestInlineMethod
):
"""
>>> test = Subtyping()
>>> test.test_cdef_subtyping()
0
"""
@
cython
.
test_assert_path_exists
(
"//AttributeNode[@entry.is_final_cmethod=True]"
)
@
cython
.
test_assert_path_exists
(
"//AttributeNode[@entry.is_inline_cmethod=True]"
)
def
test_cdef_subtyping
(
self
):
return
self
.
cdef
_inline_method
()
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