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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
fa2d65b8
Commit
fa2d65b8
authored
Jun 26, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct code to avoid useless optarg presence when doing message (un)locking
parent
e9367c94
Changes
1
Show 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 @
fa2d65b8
...
...
@@ -1227,7 +1227,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
:
...
...
@@ -1244,6 +1245,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
:
...
...
@@ -1347,10 +1351,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"++%s;"
%
trylock_result
)
num_trylock
+=
1
if
opt_arg_count
:
num_optional_if
=
0
code
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
if
opt_arg_count
:
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"
...
...
@@ -1371,6 +1375,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
num_trylock
+=
1
for
_
in
range
(
num_optional_if
):
code
.
putln
(
"}"
)
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
(
"}"
)
...
...
@@ -1388,15 +1394,18 @@ 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
for
_
in
range
(
num_unlock
):
# 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
(
"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