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
Xavier Thompson
cython
Commits
c8f2ec23
Commit
c8f2ec23
authored
Jun 26, 2019
by
gsamain
Committed by
Xavier Thompson
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct code to avoid useless optarg presence when doing message (un)locking
parent
5be9876a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+16
-7
No files found.
Cython/Compiler/ModuleNode.py
View file @
c8f2ec23
...
...
@@ -1300,7 +1300,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"%s(this->%s);"
%
(
op_lbda
(
narg
),
narg
.
cname
))
if
opt_arg_count
:
code
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
opt_arg_guard
=
code
.
insertion_point
()
code
.
increase_indent
()
num_if
=
0
for
opt_idx
,
optarg
in
enumerate
(
func_type
.
args
[
narg_count
:]):
if
optarg
.
type
.
is_cyp_class
:
...
...
@@ -1317,6 +1318,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
num_if
+=
1
for
_
in
range
(
num_if
):
code
.
putln
(
"}"
)
if
num_if
:
opt_arg_guard
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
for
reifying_class_entry
in
entry
.
type
.
scope
.
reifying_entries
:
...
...
@@ -1420,10 +1424,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"++%s;"
%
trylock_result
)
num_trylock
+=
1
num_optional_if
=
0
if
opt_arg_count
:
num_optional_if
=
0
code
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
opt_arg_guard
=
code
.
insertion_point
()
code
.
increase_indent
(
)
for
opt_idx
,
optarg
in
enumerate
(
func_type
.
args
[
narg_count
:]):
if
optarg
.
type
.
is_cyp_class
:
try_op
=
"Cy_TRYRLOCK"
if
optarg
.
type
.
is_const
else
"Cy_TRYWLOCK"
...
...
@@ -1444,7 +1448,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
num_trylock
+=
1
for
_
in
range
(
num_optional_if
):
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
# The check for optional_args != NULL
if
num_optional_if
>
0
:
opt_arg_guard
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
code
.
putln
(
"}"
)
# The check for optional_args != NULL
for
_
in
range
(
num_trylock
):
code
.
putln
(
"}"
)
...
...
@@ -1461,16 +1467,19 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"if (%s > %s) {"
%
(
trylock_result
,
num_unlock
))
code
.
putln
(
"Cy_UNLOCK(this->%s);"
%
narg
.
cname
)
num_unlock
+=
1
if
opt_arg_count
:
if
opt_arg_count
and
num_optional_if
:
code
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
for
opt_idx
,
optarg
in
enumerate
(
func_type
.
args
[
narg_count
:]):
if
optarg
.
type
.
is_cyp_class
:
code
.
putln
(
"if (%s > %s) {"
%
(
trylock_result
,
num_unlock
))
code
.
putln
(
"Cy_UNLOCK(this->%s->%s);"
%
(
opt_arg_name
,
func_type
.
opt_arg_cname
(
optarg
.
name
)))
num_unlock
+=
1
# Note: we do not respect the semantic order of end-blocks here for simplification purpose.
# This one is for the "not NULL opt arg" check
code
.
putln
(
"}"
)
# These ones are all the checks for mandatory and optional arguments
for
_
in
range
(
num_unlock
):
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
code
.
putln
(
"return 0;"
)
code
.
putln
(
"}"
)
...
...
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