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
8bc46f37
Commit
8bc46f37
authored
Mar 21, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable temps for C functions by using function pointers instead.
Closes GH-3418.
parent
6c9996c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+3
-0
tests/run/if_else_expr.pyx
tests/run/if_else_expr.pyx
+12
-0
No files found.
CHANGES.rst
View file @
8bc46f37
...
@@ -21,6 +21,9 @@ Bugs fixed
...
@@ -21,6 +21,9 @@ Bugs fixed
implemented
functions
.
implemented
functions
.
Patch
by
David
Woods
.
(
Github
issue
#
3384
)
Patch
by
David
Woods
.
(
Github
issue
#
3384
)
*
Using
C
functions
as
temporary
values
lead
to
invalid
C
code
.
Original
patch
by
David
Woods
.
(
Github
issue
#
3418
)
*
Fix
an
unhandled
C
++
exception
in
comparisons
.
*
Fix
an
unhandled
C
++
exception
in
comparisons
.
Patch
by
David
Woods
.
(
Github
issue
#
3361
)
Patch
by
David
Woods
.
(
Github
issue
#
3361
)
...
...
Cython/Compiler/Code.py
View file @
8bc46f37
...
@@ -832,6 +832,9 @@ class FunctionState(object):
...
@@ -832,6 +832,9 @@ class FunctionState(object):
type = type.const_base_type
type = type.const_base_type
elif type.is_reference and not type.is_fake_reference:
elif type.is_reference and not type.is_fake_reference:
type = type.ref_base_type
type = type.ref_base_type
elif type.is_cfunction:
from . import PyrexTypes
type = PyrexTypes.c_ptr_type(type) # A function itself isn'
t
an
l
-
value
if
not
type
.
is_pyobject
and
not
type
.
is_memoryviewslice
:
if
not
type
.
is_pyobject
and
not
type
.
is_memoryviewslice
:
# Make manage_ref canonical, so that manage_ref will always mean
# Make manage_ref canonical, so that manage_ref will always mean
# a decref is needed.
# a decref is needed.
...
...
tests/run/if_else_expr.pyx
View file @
8bc46f37
...
@@ -55,3 +55,15 @@ def test_syntax():
...
@@ -55,3 +55,15 @@ def test_syntax():
y
=
0
if
1.0
else
1
y
=
0
if
1.0
else
1
z
=
0
if
1.
else
1
z
=
0
if
1.
else
1
return
x
,
y
,
z
return
x
,
y
,
z
from
libc
cimport
math
def
test_cfunc_ptrs
(
double
x
,
bint
round_down
):
"""
>>> test_cfunc_ptrs(2.5, round_down=True)
2.0
>>> test_cfunc_ptrs(2.5, round_down=False)
3.0
"""
return
(
math
.
floor
if
round_down
else
math
.
ceil
)(
x
)
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